Do stock returns follow random walks? Markov chains and trading strategies (Excel)

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 มิ.ย. 2024
  • Markov chains are a useful tool in mathematical statistics that can help you understand and interpret probabilities. Interestingly, Markov chains can also be applied to test whether the market is efficient, and if the test shows it is not, can help develop simple trading strategies to exploit this inefficiencies. Today we are going to explain Markov chains and the Markov chain test for the random walk hypothesis in Excel and simulate some investment strategies based on Markov chains for S&P 500.
    Don't forget to subscribe to NEDL and give this video a thumbs up if you want more videos in Finance!
    Please consider supporting NEDL on Patreon: / nedleducation

ความคิดเห็น • 60

  • @NEDLeducation
    @NEDLeducation  3 ปีที่แล้ว +6

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

    • @ariesclark3272
      @ariesclark3272 2 ปีที่แล้ว

      instablaster...

    • @KarolKapuscinski
      @KarolKapuscinski 4 หลายเดือนก่อน

      wow, thx! subscribed! its the best video about markov ch. I found as far....

  • @vanbach852
    @vanbach852 3 ปีที่แล้ว +16

    Your channel is gold. Please continue to enlighten all of us.

    • @NEDLeducation
      @NEDLeducation  3 ปีที่แล้ว

      Hi, and thank you! Glad you find the videos helpful :)

  • @DavidElstob73
    @DavidElstob73 7 หลายเดือนก่อน +3

    Can't help but admire your amazing Excel skills. Superb!

  • @mikiallen7733
    @mikiallen7733 2 ปีที่แล้ว +4

    rarely I find high quality content such as this one , thanks sir , I may get the chance to work with you in the future on some similar ideas , am working still but not yet finished with the first step , which is data preparation / and variables which may provide a hint in to short-term percentage returns .

  • @dchoudhary5449
    @dchoudhary5449 5 หลายเดือนก่อน

    Thanks for your valuable input. I have been trying to understand the Markova state for long. Thanks for your help.

  • @huskyjohnson31
    @huskyjohnson31 3 ปีที่แล้ว +2

    This is a phenomenal video!

  • @nikosje
    @nikosje 2 ปีที่แล้ว +1

    Absolutely superb video

  • @camkrik5812
    @camkrik5812 2 ปีที่แล้ว +5

    Fantastic video. Your excel skills are amazing!

    • @NEDLeducation
      @NEDLeducation  2 ปีที่แล้ว

      Hi Cam, and thanks so much for such kind words. Stay tuned for more videos!

  • @drsjamesserra
    @drsjamesserra 3 ปีที่แล้ว +1

    So awesome you share the files!

  • @sreedharma
    @sreedharma 2 ปีที่แล้ว +1

    Just Brilliant ! thanks a lot

  • @selvasair
    @selvasair 3 ปีที่แล้ว +2

    Thanks for sharing the spread sheet, it help me in my understanding, by repeating the calculation as i watch the video

    • @NEDLeducation
      @NEDLeducation  3 ปีที่แล้ว

      Hi, thanks for your feedback! Glad you found the spreadsheet helpful :)

  • @joeaoun6321
    @joeaoun6321 3 ปีที่แล้ว

    Thanks for another great video and providing the spreadsheet. If only I could watch it in slo-mo!

    • @Knud451
      @Knud451 2 ปีที่แล้ว

      Just slow down youtube.

  • @muntedme203
    @muntedme203 2 ปีที่แล้ว +1

    Very nice.

  • @philippe2402
    @philippe2402 ปีที่แล้ว

    Thank you!

  • @SurrenderPink
    @SurrenderPink 2 หลายเดือนก่อน

    NEDL, I've learned much from your past python tutorials. Wanted not to learn, but understand Markov Chains and your channel was a logical place to start. Amazing! Mad excel skills! You got it front, back and down! Many thanks for sharing your considerable knowledge as well as taking the time to record, edit and share your expertise. First rate!

  • @lubiaescalante4107
    @lubiaescalante4107 3 ปีที่แล้ว +3

    You should work on fractal Dimension, calculating area of Rectangles that is a good input for trading strategies too.

    • @salardelavarqashqai6361
      @salardelavarqashqai6361 8 หลายเดือนก่อน +1

      please give youtube or book reference for better understanding for me. thanks

  • @ilijagjorgjevic9354
    @ilijagjorgjevic9354 15 วันที่ผ่านมา

    How about using VOM 24:57 (variable order Markov chain). Do you find them more suitable for boosting of prediction accuracy?

  • @onda4165
    @onda4165 3 ปีที่แล้ว

    Thank you very much Savva. I am still impressed by this video and your explanations. However I think there is a future leak in the strategy because you tested starting on 2015 the inefficiency discovered when you have all the data. So the strategy is using information not available at the moment.

    • @NEDLeducation
      @NEDLeducation  3 ปีที่แล้ว

      Hi, and glad you liked the video! You are absolutely right, a robust estimation of such a strategy would revolve around an estimation period and a testing period where information only from the first period would be used. I mainly presented Markov chains as a market efficiency test here and the strategy part was mostly an illustration and not a guide for algorithmic trading :) I started doing tutorials on algorithmic trading recently though, so check it out if you are interested: th-cam.com/video/jvZ0vuC9oJk/w-d-xo.html

  • @yaxunyang8487
    @yaxunyang8487 2 ปีที่แล้ว +1

    Hi NEDL, Thanks for the wonderful video. When you construct your strategy, do you think it's better to apply it in a different data set?

    • @NEDLeducation
      @NEDLeducation  2 ปีที่แล้ว +2

      Hi Yaxun, and glad you liked the video! It is hard to say in advance which strategy would be best applicable to a particular dataset without applying the tests in the first place. As a rule of thumb, however, strategies exploiting dependencies of returns tend to be more profitable on less liquid markets. Hope it helps!

    • @yaxunyang8487
      @yaxunyang8487 2 ปีที่แล้ว

      @@NEDLeducation very helpful!

  • @veshderr
    @veshderr ปีที่แล้ว +1

    Thank you for such great work! Is there a specific paper in your drive folder that goes over the Markov chain test for the random walk hypothesis?

    • @NEDLeducation
      @NEDLeducation  ปีที่แล้ว +1

      Hi Ergys, and glad you liked the video! This paper, for example, provides a quite simple outline of the methodology: dergipark.org.tr/en/download/article-file/50208

    • @veshderr
      @veshderr ปีที่แล้ว

      @@NEDLeducation Thank you!

    • @veshderr
      @veshderr ปีที่แล้ว

      @@NEDLeducation Can you comment on why the runs test, variance ratio, and Markov can sometimes calculate different p-values? Do you have any insight on the nature of the signal itself (for example, length of signal or sampling rate) that may explain some of these differences? Thank you again for such thorough explanation for these tough concepts!!

    • @NEDLeducation
      @NEDLeducation  ปีที่แล้ว +1

      @@veshderr Hi Ergys, and thanks for the excellent follow-up question! These tests conceptualise various facets of efficiency/inefficiency/predictability. For instance, variance ratio is about parametric predictability (here I show how variance ratios can be thought of as aggregated autocorrelation coefficients: th-cam.com/video/6c6m2UPiSZ8/w-d-xo.html). Runs tests are about directional predictability (whether the signs of returns and not necessarily their values can be predicted). Markov chains put this concept further and show whether return quantile buckets are predictable. So long story short, bar multiple testing concerns, if at least one test shows inefficiency, you can conclude the market is inefficient.

    • @veshderr
      @veshderr ปีที่แล้ว

      @@NEDLeducation Thank you!

  • @marekdziubinski850
    @marekdziubinski850 ปีที่แล้ว +1

    Very valuable content! I couln't find the Markov spredsheet in your google folder (?)

    • @NEDLeducation
      @NEDLeducation  ปีที่แล้ว +2

      Hi Marek, and glad you liked the video! The file is called NEDL_Markov, here is the link just in case: docs.google.com/spreadsheets/d/1Fe-qstzOqE40wo4Q28D_gl8-zGWLDV3-/edit?usp=share_link&ouid=113436662715404606257&rtpof=true&sd=true

    • @marekdziubinski850
      @marekdziubinski850 ปีที่แล้ว

      @@NEDLeducation Thanks!

  • @AttilioPitt
    @AttilioPitt 2 ปีที่แล้ว +3

    Amazing video! Could you make this on python? Thank you really much

    • @NEDLeducation
      @NEDLeducation  2 ปีที่แล้ว +3

      Hi Attilio, and glad you enjoyed the video! Yes, I was planning to return to market efficiency tests and Python implementation of these at some point in the future, so stay tuned! :)

    • @salardelavarqashqai6361
      @salardelavarqashqai6361 8 หลายเดือนก่อน

      @@NEDLeducation yes please model this with python

  • @terencewinters2154
    @terencewinters2154 4 หลายเดือนก่อน

    Consider a squirrel reaching a fork in a tree branch . Does he get to the nuts in his hutch most efficiently by following the left fork or the right . But supposing a big wind blows that branch down and he must leap to another . There are variable probabilities of success and not all states can consider all possible variables . N - x variables is possible to give some consistency . But x is not the infinite set. The market isnt. fficient .

  • @empemitheos
    @empemitheos 3 ปีที่แล้ว +1

    Your strategy is somewhat like using a moving average strategy 👍

  • @salardelavarqashqai6361
    @salardelavarqashqai6361 8 หลายเดือนก่อน

    Please model this awesome example with python and plot the result for better explaintion because it was very complex. thanks alot

  • @cathyqinKoreanEnglishSongs
    @cathyqinKoreanEnglishSongs 9 หลายเดือนก่อน

    what is the meaning by the number of states

  • @annmaryalexander
    @annmaryalexander 3 ปีที่แล้ว +1

    As part of the results what all should we report?

    • @NEDLeducation
      @NEDLeducation  3 ปีที่แล้ว +2

      Hi Ann, and thanks for the question. For such analysis, you can report the Chi-squared stat and the p-value as well as, potentially, the transition probability matrix. Hope it helps!

    • @annmaryalexander
      @annmaryalexander 3 ปีที่แล้ว

      Ok Thank you

  • @mikiallen7733
    @mikiallen7733 2 ปีที่แล้ว +1

    I don't think Jim Simons fund uses returns to classify in to states , it must be something else ! am sure soon I will crack this up inschallah

    • @NEDLeducation
      @NEDLeducation  2 ปีที่แล้ว

      Hi Miki, and thanks for the comment! I am pretty sure whatever Jim Simons uses is proprietary :) But you definitely can build state transition matrix on other characteristics rather than returns.

    • @mikiallen7733
      @mikiallen7733 2 ปีที่แล้ว

      @@NEDLeducation we will see but thanks for your prompt response , but do you happen to work on projects related to industry right now ? Or is it just pure academic research though I suspect it , I would really love to know!

  • @MrMcaff
    @MrMcaff 3 หลายเดือนก่อน

    This modeling suffers from look ahead bias, doesn´t it? You do not know now what tomorrow´s return will be in order to calculate the empirical distro.

  • @jasonwayne4647
    @jasonwayne4647 ปีที่แล้ว +1

    I found treasury