Dynamic Hurst exponent in Python

Поділитися
Вставка
  • Опубліковано 25 лип 2024
  • How to estimate a rolling-window Hurst exponent to study the dynamic nature of long memory in time series? Today, we are investigating a simple Python script that can be used to efficiently perform this calculation for any financial time series on the example of S&P 500
    Don't forget to subscribe to NEDL and give this video a thumbs up for more videos in Python!
    Please consider supporting NEDL on Patreon: / nedleducation

КОМЕНТАРІ • 32

  • @NEDLeducation
    @NEDLeducation  3 роки тому +4

    You can find the .ipynb for this video and some additional materials here: drive.google.com/drive/folders/1sP40IW0p0w5IETCgo464uhDFfdyR6rh7
    Please consider supporting NEDL on Patreon: www.patreon.com/NEDLeducation

    • @ekolytih
      @ekolytih 3 роки тому +1

      Good stuff! You should consider uploading the notebooks etc onto github. thanks anyway!

  • @plazmafield
    @plazmafield 3 роки тому +2

    Just bumped up my patreon support a tier :), keep up the hard work Savva

  • @nikosje
    @nikosje 2 роки тому

    superb video

  • @jxm262262
    @jxm262262 3 роки тому +1

    First time commenting on UA-cam. This was an awesome watch, I do something similar.
    Will be watching the rest of your videos :)

    • @NEDLeducation
      @NEDLeducation  3 роки тому

      Hi Justin, really appreciate your comment and the kind words! There is plenty of other Python as well as Excel content on the channel, feel free to watch :)

    • @jxm262262
      @jxm262262 3 роки тому +1

      @@NEDLeducation Subscribed! Keep the video's coming, you have a new fan

  • @weiliangzhang6364
    @weiliangzhang6364 2 роки тому +1

    Thanks for the talks, best I've been on this topic. One thing in the code, no.std() by default computes population stdev, needs ddof=1 explicitly.

    • @NEDLeducation
      @NEDLeducation  2 роки тому

      Hi Weiliang, and thanks so much for such kind words! Good point, does not affect the result that much with 1024 observations though :)

    • @weiliangzhang6364
      @weiliangzhang6364 2 роки тому +1

      @@NEDLeducation indeed. Small detail. Great work.

  • @BrunoSchwalbach
    @BrunoSchwalbach 3 роки тому +3

    Great Job, Savva! What are your thoughts regarding practical application of this metric? In my mind, it gives credence to simple longer term moving average type trend indicators (i.e. trust the trend if statistically significantly > 0.50), but it is not clear on indicating whether any specific lag periods have better trend than others. Is there some method you know of that can accomplish this?

    • @NEDLeducation
      @NEDLeducation  3 роки тому +2

      Hi Bruno, and glad you liked the video! Theoretically, such a dynamic Hurst exponent can indeed be used to assist conventional technical analysis, for example, trust the conventional MACD signals if Hurst significantly exceeds 0.5, trust the reverse signal if it is significantly below 0.5, and do not rely on technical signals at all otherwise. Other applications involve computing MACD of Hurst exponents themselves, for example what this paper does: www.scitepress.org/Papers/2018/66670/66670.pdf Their results are however not very robust, but nevertheless the concept is interesting. As for the optimal lag length, I would say there is little theoretical reasoning to prefer one over the other, here is where backtesting can help.

  • @WillyCSchneider
    @WillyCSchneider 2 роки тому

    Hi Savva, thanks a lot for the great video. I am not really sure about the meaning of the deviate variable. Why the cumulative sum? Is there any other name for this calculation that I could look up? Thanks.

  • @stephonhenry-rerrie3997
    @stephonhenry-rerrie3997 Рік тому

    great video. quick question. why do we want to split our subsamples by powers of 2 rather than going linearly? is it because of computational time or are there theoretical considerations for this

  • @andrewbloomfield6905
    @andrewbloomfield6905 Рік тому

    Hello, thanks for the informative video. When estimating the Hurst coefficient (the slope) should we not log both Y (the average rescaled range) *and* X (the number of observations in the subsamples). It looks as though the OLS estimation is estimating log(Y) = a + b(X)?

  • @ianlukan1860
    @ianlukan1860 2 роки тому +1

    Hey Savva! Big fan of your videos - i have a question regarding my master thesis - i am writing about the market efficiency of the companies listed on the S&P 500 and i would like to use the hurst exponent as a proxy for market efficiency. therefore my question, is it possible to put out the daily hurst exponent for every day as a number via python (in the best case 1 data point per excel-cell as i have to use the hurst exponent for further anaylsis in excel...) if so how can i do that using your script
    Best,
    Ian

    • @NEDLeducation
      @NEDLeducation  2 роки тому

      Hi Ian, and glad you are enjoying the channel! Yes, exactly, this is what this code is designed to do. Feel free to use my code and all the best with your thesis!

  • @sabaaminolroaya4452
    @sabaaminolroaya4452 2 роки тому +1

    hi . thank you

  • @ajaykumar-gz4gt
    @ajaykumar-gz4gt 4 місяці тому

    Hello Sir, Very informative video. Please tell me the rationale behind choosing t-statistics over F-tests in statistical analysis or can we use any other test for analysis?

  • @tobiasgeisler6484
    @tobiasgeisler6484 2 роки тому +1

    Hi Savva,
    thanks for showing a python code for the Hurst exponent!
    I am currently analyzing properties of the Volatility Index (VIX) and the VIX futures. Do you have any idea how to adapt your code that the volatility time series can be directly analyzed? Of course, the returns can also be interesting, but the volatility itself is very meaningful.
    When analyzing the returns, I get quite stable results for the VIX (0.325

    • @NEDLeducation
      @NEDLeducation  2 роки тому +1

      Hi Tobias, and happy you enjoyed the video! Thanks for a very thoughtful comment as well. VIX is supposed to be mean-reverting as volatility spikes do relax with time quite quickly. For futures, you can expect mean reversion, but the prices themselves can be too noisy to pick this up. Try applying the same procedure not to returns but rather to the differences between futures and spot returns. This relationship should show more mean-reversion.

    • @tobiasgeisler5157
      @tobiasgeisler5157 2 роки тому

      @@NEDLeducation Hi Savva,
      good idea, but then for me the interpretation becomes inconsistent. Do you see a problem mathematically in using the absolute changes instead of the returns within the code? With certain hyperparameters, the results with the absolute changes are meaningful.

  • @HuyBui-zq2xh
    @HuyBui-zq2xh Рік тому

    Hi Savva. I have a quick question? What is the Dynamic Hurst Exponent? It is different with the Hurst Exponent that you showed us in the Excel calculation of SP500 data? Thank you

  • @MuhammadRehan-zv6se
    @MuhammadRehan-zv6se 2 роки тому

    hey Can you share video on multifractal scaling exponents τ (q) in python ?

  • @noahverner5153
    @noahverner5153 2 роки тому +1

    May you please elaborate on how many observations (days) are taken into consideration for estimating each value of the Hurst exponent?

    • @NEDLeducation
      @NEDLeducation  2 роки тому +1

      Hi Noah, and thanks for the question! Generally, you select a power of 2 and then the rolling sample is 2 raised to this power (which is what this code also does). Common samples for daily data are 128, 256, 512, and 1024 days.

  • @SofenKumarJena
    @SofenKumarJena Рік тому +1

    I have a turbulence time series and interested to compute this one. can you please help me

    • @NEDLeducation
      @NEDLeducation  Рік тому +1

      Hi Sofen, and thanks for the question! Sure, I do offer one-on-one video meetings to my Gold patrons where we can go through any Excel/Python/other stuff, please consider supporting the channel here: www.patreon.com/NEDLeducation/membership

  • @nangbiaksing2622
    @nangbiaksing2622 Рік тому

    Sir, i request you to performed a test on Generalized spectral tests for the martingale difference hypothesis (Escanciano, J. Carlos & Velasco, Carlos, 2006)

  • @leiyuanwan8270
    @leiyuanwan8270 2 роки тому +1

    Hurst Cycle code

    • @NEDLeducation
      @NEDLeducation  2 роки тому

      It is available via the Google drive: drive.google.com/drive/folders/15C_scJ0ndr1c4nyU7Ls4rCZtAm8vYVLr

    • @leiyuanwan8270
      @leiyuanwan8270 2 роки тому

      @@NEDLeducation Is this code that can be run directly?