How to calculate steady/incremental growth?
How to calculate steady/incremental growth?
Loading saved threads...
STEIN · External communityPost link
External question — Data Science Stack Exchange
Author: STEIN
Original post: https://datascience.stackexchange.com/questions/76890
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I have timeseries data for stocks at minute intervals.
What is the best way to calculate incremental growth, for example if I have a stock's price from 9am to 2pm at minute intervals, how can calcule the incremental growth. I don't want to simply calculate the difference between the price at 2pm and 9am, I want to be able to identify stocks which have risen steadily between the two time intervals
Quote
Report
Peter · External communityPost link
External answer — Data Science Stack Exchange
Author: Peter
Original post: https://datascience.stackexchange.com/a/76893
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
What stops you looking at lags?
df = data.frame(c(1,2,3,4,4,3,4,5,6,7))
colnames(df)<-c("price")
df$delta=lag(df$price, 1)
df$inc = df$price-df$delta
df
Would yield:
price delta inc
1 1 NA NA
2 2 1 1
3 3 2 1
4 4 3 1
5 4 4 0
6 3 4 -1
7 4 3 1
8 5 4 1
9 6 5 1
10 7 6 1
The condition here would be that each value of inc (except the first one) must be
$>0$
.
Quote
Report
pcko1 · External communityPost link
External answer — Data Science Stack Exchange
Author: pcko1
Original post: https://datascience.stackexchange.com/a/76894
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Simply calculate the
derivative
of the price level with respect to your time unit (in other words between two subsequent measurements).
If the derivative is 0 at some interval, it means that the price has been stable.
If the derivative is positive, it means that the price has increased in that range.
If the derivative is negative, then the price has decreased.
The value of the derivative (regardless of the sign) shows the slope of the change. In other words, the higher the derivative the more aggressive the change towards the direction that is denoted by the sign.
You can easily do this with
numpy.diff
.
Note
: Differentiation is a "noisy" process and can lead to a very edgy graph of the derivative when you plot it, especially if you have sudden changes in the price level. To solve this, you should consider some smoothing tactics such as a moving average filter applied on the calculated values of the derivative or any other low-pass filter.
Quote
Report
Nate · External communityPost link
External answer — Data Science Stack Exchange
Author: Nate
Original post: https://datascience.stackexchange.com/a/109836
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
You could consider something like the Sharpe Ratio (
https://en.wikipedia.org/wiki/Sharpe_ratio
) with the goal of maximizing that value. Essentially this would translate to finding a stock with the highest return and least volatility. You could calculate a simple version like the following:
$ {Percent Change over Whole Time}/StandardDeviationOfRelativeDifferences $
Relative differences could be the percent change between each minute to minute change divided by the previous minute's value.
Quote
Report
Post Reply
Checking account access…