Hello, I have written some code that calculates the Hurst exponent. Below is just the function for it.
def HurstExponent(self):
#The Hurst Exponent is calculated using the Rescaled Range (R/S) analysis. The formula for the Hurst exponent is:
#Hurst Exponent = (log(Rn/S) / log(n)) - 0.5
#where Rn is the range of the cumulative sum of n data points and S is the standard deviation of the n data points
# Generate vector of prices
prices = np.array([self.closingPrices])
# Calculate log returns
Rn = np.cumsum(prices)
S = np.std(prices)
# Calculate Hurst exponent
hurst = (np.log(Rn/S)) / np.log(prices) - 0.5
return hurst[-1][-1]
self.closingPrices is a python list of the closing prices in a rolling window.
If anyone has any feedback that would be greatly appreciated. I'm open minded.
I have a YT channel where I code this up on video, the video will come out today Channel is called:
EthernetWink
Link to other video:
Critical.Error
Just curious why you choose not to use the rescaled range when calculating the Hurst exponent?
Critical.Error
And thank you for the videos and post! I have noticed that the shorter timeframes (intraday data) appear to have higher hurst exponents for all the products I have tested. Is your experience the same with that? It even gets higher than 1.0 consistently for ES futures on 5m timeframe somehow.
Critical.Error
Here is an example on ES futures 5m data with 276 periods in the rolling window. You can see the chart of the hurst exponent.
Critical.Error
Here is an example of ES futures on a daily timeframe for 90 periods. Much lower HE. I would not expect them to be that similar but it's indicative of the trend I noticed with shorter timeframes consistently producing higher hurst components.
Do you usually use absolute values of hurst in your decision making or the slope or some other derivative of it?
Joseph Matteo Scorsone
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!