MOMENTUM Trading Strategy on the NASDAQ with Python using multiple lookbacks SURVIVORSHIP BIAS FREE

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024

Комментарии • 90

  • @yellowboat8773
    @yellowboat8773 Год назад +8

    I am not a programmer by any means. I have no idea why I watch these videos but they are so insightful on strategies to solve problems. It's like coding is a series of thousands of small problems that you need to solve to achieve your designed outcome. Fascinating.

    • @vladk9152
      @vladk9152 Год назад +3

      I am a programmer. Python is easy enough to learn, do it and you'll enjoy these videos even more

    • @CaarabaloneDZN
      @CaarabaloneDZN Год назад +1

      this is exactly what it is.
      The main ideia with solving complex problems (in programming context, because that's what I know) is divide and conquer. It's literally everywhere.

    • @Algovibes
      @Algovibes  Год назад

      First of all thanks a lot for watching my videos :-) Appreciate it. If you need any help finding something helping you get a better understanding just let me know!

    • @yellowboat8773
      @yellowboat8773 Год назад +2

      @@Algovibes got inspired so i signed up dataquest on their data scientist path. Clocked in 6 hours today and loving it

    • @Algovibes
      @Algovibes  Год назад

      @@yellowboat8773 like a BOSS 👨🏽‍💼

  • @m4ryou5h
    @m4ryou5h Год назад +1

    I love your vids mate. Explanation, introduction, coding, result of the algo - great stuff really.

    • @Algovibes
      @Algovibes  Год назад

      Thanks a lot. Appreciate your comment!

  • @GlebKretinin
    @GlebKretinin Год назад +2

    Excellent stuff. Loving the vectorised approach. Thank you for sharing!

    • @Algovibes
      @Algovibes  Год назад

      Thanks a lot for watching my man

  • @davidh4632
    @davidh4632 Год назад +2

    Love your channel, well done on finding the historical index members without paying. A little secret, whilst momentum can be a great strategy, generally tracking error is higher due to momentum crashes during regime change in the markets. Keep up the great work.

    • @Algovibes
      @Algovibes  Год назад +1

      Thank you very much for your kind words my mate

  • @jerrywang3225
    @jerrywang3225 Год назад +1

    The strategies are getting more advanced in the new year. Thanks again for sharing.

    • @Algovibes
      @Algovibes  Год назад

      Welcome mate! Trying my best to keep a balance between more beginner friendly content but also some advanced topics. Thanks for your feedback.

  • @Joebi1kenobi
    @Joebi1kenobi Год назад +1

    These videos are the best on youtube, no doubt.

  • @bryan-9742
    @bryan-9742 Год назад +1

    This saves me so much time. I was literally creating another boolean matrix from the last videos tickers and making a 1, (in index) 0(not in index) Matrix and mapping the timeseries as the index and then merging with the price series into one big df. From their I was gonna melt, pivot, and groupby but this is much more efficient.

    • @Algovibes
      @Algovibes  Год назад

      Also a good way to solve that!

  • @DevAtul
    @DevAtul Год назад +1

    Happy New Year man! I am following you since a long time and I want to tell you that your videos have inspired me to start something like this of my own. Of course it will take time but thank you for posting such insightful videos from time to time.

    • @Algovibes
      @Algovibes  Год назад

      That's awesome to read. Thanks a lot my friend!

    • @lokeshsalujas
      @lokeshsalujas Год назад

      I echo Atul’s sentiment. In the same position. Thankyou AlgoVibes

  • @narendersingh4206
    @narendersingh4206 Год назад +1

    Hey!!! Thats a wonderful addon to the previous cascade momentum video. many queries are solved by this video pertaining to the previous one. Thanks again for your time and effort. Also, I would also request you to please do add one more tutorial video to it where in you can share further addon like CAPM, Ann returns, CAGR, Sharpe, Sortino, alpha, Beta, and certain functions which can show portfolio elements on that specific date with prices of stocks selected on creation day and exit day. what i mean to say that once the portfolio is created and on the day of rebalancing it must be able to clearly show the symbol, new entry, exit and final portfolio. Regards Narender

    • @Algovibes
      @Algovibes  Год назад

      Thanks a lot Narender. Appreciate your comment!

  • @ytuser7967
    @ytuser7967 Год назад +1

    Thank you Bro, have a great and healthy new year!

    • @Algovibes
      @Algovibes  Год назад

      Thank you so much , same for you!

  • @assafcohen3173
    @assafcohen3173 Год назад +1

    Great video as always!

    • @Algovibes
      @Algovibes  Год назад

      Thanks buddy, appreciate your comment

  • @lorenzobaggi161
    @lorenzobaggi161 Год назад +2

    Happy new year boss

  • @MrHypeGFX
    @MrHypeGFX Год назад +1

    Hi, just want to start by saying, great video - these videos are a great tool for learning. I too did the same strat with the SP500 and i don't understand fully how survivorship bias affects the case - as we are dropping all the columns with any NaNs when you did the first part of the video.
    So any current day performers, if we use a date to pull the tickers using yf where they were not present in the sp500, they will have NaNs present in their column. As we drop these columns, the list of stocks decreases slightly. But how does it affect the strategy and backtesting then?

  • @osylphx
    @osylphx Год назад +2

    Excellent work Algovibes, keep it up! Can you please make a video on how to take this strategy, and short the nsmallest performing tickers, instead of longing the nlargest in the 3 time frames? I have tried this myself, but everything I do, I end up with a 3.5x (with 1% slippage) if I would LONG the nsmallest performing tickers! This leads me to believe my code is not correct, but I have reviewed many times. Please take a look at this scenario, because ideally we can combine longing in a bull market, and shorting in a bear market to maximize profit. Thank you!

    • @Algovibes
      @Algovibes  Год назад

      Thanks buddy! Very cool idea. I have noted that. Thanks a lot for the suggestion.

    • @peterodenthal8024
      @peterodenthal8024 Год назад

      I believe that the initial work by Jegadeesh + Titman follows your proposal: buy the winners and short the losers. That makes the strategy self-funding, which is great. Careful with your portfolio sizing though, as you may lose your margin in case of sudden reversals. It would be very interesting to see if such reversals actually occur in a backtest.

  • @bryan-9742
    @bryan-9742 Год назад +1

    Happy new year!!

  • @mattchannel7075
    @mattchannel7075 Год назад +4

    What I would love to know now: what is the outcome of this strategy in the S&P500?

    • @JCNvid
      @JCNvid Год назад +2

      Yes, and beaides that, if there is no positive momentum on the 3 periods of analysis, we stay in chash.

    • @Algovibes
      @Algovibes  Год назад +2

      Awesome idea. Thanks a lot for the suggestion!

  • @amitshewale1594
    @amitshewale1594 Год назад

    By design momentum or market cap strategies include only survivors. The survivorship bias is avoidable for mean reversion strategies

    • @Algovibes
      @Algovibes  Год назад

      That's a wrong statement. E.g. there is also negative Momentum (stocks falling tend to fall further). In the video is shown how you diminish the survivorship bias.

    • @amitshewale1594
      @amitshewale1594 Год назад

      @@Algovibes If a position is taken in a negative momentum stock and it get removed, then the strategy return is under estimated. When backtesting it's not such a drawback as in live environment the performance will be better than backtest.
      But in case of mean reversion a long position is taken when price is in downtrend. If the stock gets removed the backtest will overstate the performance than when it is implemented. A situation which is clearly avoidable.
      Anyway I loved your programming of the strategy.

  • @rraul
    @rraul Год назад +1

    Like before watching!

  • @stephenyip5827
    @stephenyip5827 Год назад +2

    Great video,I m new to your channel,May I know if any video talking about naming variable? Sometimes I confused myself for the variable that I created by myself 😅

    • @Algovibes
      @Algovibes  Год назад

      Sorry, can you elaborate on that? Didn't quite get the question. Thanks!

    • @stephenyip5827
      @stephenyip5827 Год назад

      @@Algovibes I mean how to name a variable in coding. For example, I need to create an integer variable to count how many stocks fulfil my self defined screening criteria,should I name the variable like intFulfilCriteriaA/FulfilCriteriaA/fulfill_criteria_a/int_CriteriaA etc…naming a variable and function and object during coding sometimes might be a difficult task for me🥲hope it is clear😃

  • @isaacharmon488
    @isaacharmon488 Год назад +3

    So far what has been your favorite strategy or the one you currently use?

  • @Elvis00026
    @Elvis00026 Год назад +3

    It would be awsome to get it done on the SP500, where there are different sectors and it may get a 2022 positive year, for example, investing in energy or war related stocks.

    • @Algovibes
      @Algovibes  Год назад +2

      Very cool idea. Noted that! Thanks a lot for the suggestion.

    • @Elvis00026
      @Elvis00026 Год назад +1

      @@Algovibes I did it (version with survivor bias) and results were great.

  • @ויקטוראייזקוביץ
    @ויקטוראייזקוביץ Год назад +1

    thanks for these videos ... I am learning a lot and testing the strategy for S&P.
    I don't understand why the survival-free bias is getting a worse result than the regular momentum strategy.
    my logic says that if we have more stocks to choose from and the strategy picks the best-performing stocks across 12m->6m->3m then the performance should be better and that is not the case
    can you explain ... even in intuition wise why?

    • @Algovibes
      @Algovibes  Год назад

      Welcome man!
      Intuition wise: Imagine you are considering a strategy which is including Tesla, a stock with a 10 year performance of about 10,000%. Now a survivorship bias free dataset only considers Tesla from a certain day on when it was actually in the Nasdaq. If it would include it from the beginning on, it would drive the portfolio performance by a significant amount. That would be the case if it wasn't survivorship bias free.

    • @ויקטוראייזקוביץ
      @ויקטוראייזקוביץ Год назад

      @@Algovibes hi, this is precisely my point.
      In the first momentum strategy, you removed TSLA stock cause it had some NA values so you couldn't use it and gain its performance. In this strategy, you gained its performance so intuition wise the current strategy that includes stocks like TSLA should achieve higher performance. but this is not the case

  • @jean-marcducommun8185
    @jean-marcducommun8185 Год назад +1

    I wish I had your programming skills as I have great knowledge regarding MOMENTUM in financial markets. Back in time I was managing a fund based on this factor but I realized that to overcome some backdrops you need better filters that essentially allows you to distinguish between Alpha and Beta. May be you know ways to get the programming done.

    • @Algovibes
      @Algovibes  Год назад

      That's awesome! Appreciate your comment.
      Yes, that's very interesting as well, agreed.
      Be invited to check out my other stuff then, should be interesting for you :-)

  • @gustavozambrana116
    @gustavozambrana116 Год назад +2

    For those that try the code, the link shared for the Nasdaq 100 historical data no longer works, appears the company made it private.

    • @Algovibes
      @Algovibes  Год назад

      Good to know!

    • @endeavorsu7174
      @endeavorsu7174 Год назад

      @@Algovibes Hi, is there any other way to get the same data? Otherwise it's difficult to follow this brilliant video.

    • @endeavorsu7174
      @endeavorsu7174 Год назад

      Hi, is there any other way to get the same data? Otherwise it's difficult to follow this brilliant video.

    • @gustavozambrana116
      @gustavozambrana116 Год назад

      @@endeavorsu7174 I had to pay for it , subscribed for a month then cancel, it is worth it to examine results across different market regimes, and for other algos.

  • @fg0611
    @fg0611 Год назад +1

    Loving all your content thanks for sharing your knowledge (I leave my question here because it is your most recent video but I am watching everything from the beginning). I am a software engineer and at the moment I only work with JavaScript, typescript, dart, css, html and sql making applications for a fintech, however all this subject of algorithmic trading seems fascinating to me. Do you know of any material such as a digital book that you can share or mention that is dedicated to explaining the mathematics behind the indicators?

    • @Algovibes
      @Algovibes  Год назад +1

      thanks my mate. Talked about this here:
      ruclips.net/video/Wem7PIhT95U/видео.html
      and I think I made some book recommendations in my live stream as far as I rememember:
      ruclips.net/video/TJK-Ct9WnCw/видео.html

    • @fg0611
      @fg0611 Год назад

      @@Algovibes checking out both vids right now. Thanks!

  • @thomasli341
    @thomasli341 Год назад

    Do you have any other source for this nasdaq historical component data? The link isn't working.

  • @fabriziofumagalli357
    @fabriziofumagalli357 Год назад +1

    interesting. thank you for showing us!
    but with this approach there is still survivorship bias on delisted stocks?

    • @Algovibes
      @Algovibes  Год назад +1

      Welcome mate! No, why do you think so?

    • @fabriziofumagalli357
      @fabriziofumagalli357 Год назад

      @@Algovibes in ruclips.net/video/OHYExP6RVFU/видео.html, we are already missing some stocks without investigations.
      it happens to me on other markets that date, ticker_name, delisted stocks creates survivorship bias anyhow unfortunately

  • @denizhan1010
    @denizhan1010 Год назад

    hi bru why not same my getting with pandas on tradingview values? Example IM gettinr rsi value 50 on pandas, but tradingview showing rsi 51.10

  • @mumbai59
    @mumbai59 Год назад +1

    I am getting the error "AttributeError: 'str' object has no attribute 'top_30'"

    • @Algovibes
      @Algovibes  Год назад

      Just stick to the code in the video and you won't have that problem.

  • @LowQuant
    @LowQuant Год назад

    Very nice video! Learned a lot, but the title is still missleading.
    The Nasdaq Index is rebalanced on a quarterly basis in March, June, September and December meaning that tickers that appear to be in the index in your historical component data only made it into the index (probably in september or June), because of their strong performance. By omitting this fact you include a look ahead bias and your backtest is not survivorship bias free.

    • @LowQuant
      @LowQuant Год назад

      it's therefore equally wrong to assume stocks were in the index at the beginning of 2016 if the tickers are in the comp of 12-31-2016

    • @Algovibes
      @Algovibes  Год назад +1

      First of all thanks a lot Johannes. Happy that you learned something.
      Secondly the title is perfectly fine. The wrong thing is your understanding of rebalancing - happy to explain:
      Rebalancing an index means that you are adjusting the weights of the constituent securities.
      That is actually happening quarterly for the Nasdaq and has no impact on the constituents.
      Reconstitution means that you are changing the constituent securities in an index.
      That is happening end of December each year for the Nasdaq.
      Further reading:
      analystprep.com/cfa-level-1-exam/equity/rebalancing-reconstitution-index/
      www.globenewswire.com/news-release/2022/12/10/2571355/0/en/Annual-Changes-to-the-Nasdaq-100-Index.html

    • @LowQuant
      @LowQuant Год назад +1

      @@Algovibes cfa level 1 prep that was embarrasing :D thanks again for educating me. But starting in the beginning of the year makes no sense for me if reconstitution happens end of year.

    • @Algovibes
      @Algovibes  Год назад

      @@LowQuant
      That is not the case (actually explained that in the video)
      I am only going back until the beginning for the data pull to have the lookback covered for 2016. If you build a portfolio at beginning of 2017 (which is the first formation date), you need the prices going back until beginning of 2016 to evaluate the performance of these stocks (max lookback is 12m).

  • @farshidghafarzadeh3759
    @farshidghafarzadeh3759 Год назад

    Hi. I have problem with the line of code that resample the date in month. I get this error:
    TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'

    • @Algovibes
      @Algovibes  Год назад

      Hi :-) Did you transform the index as I did in the video?

    • @farshidghafarzadeh3759
      @farshidghafarzadeh3759 Год назад

      @@Algovibes thanks, i solve the problem

  • @Shreendg
    @Shreendg Год назад +1

    Welchen IDE benutzen Sie?

    • @Algovibes
      @Algovibes  Год назад

      Jupyter Notebook ☺️

    • @Shreendg
      @Shreendg Год назад +1

      @@Algovibes danke!

    • @Shreendg
      @Shreendg Год назад +1

      @@Algovibes Ich studiere Quantitativ Finanz. Leider habe ich keine Vorgrunde von Programierung. Ihre Videos haben mir dabei viel gehölfen. Vielen Dank!

  • @arunkamath
    @arunkamath Год назад +1

    Bro, I hope you got my mail. Looking forward for your insights.

    • @Algovibes
      @Algovibes  Год назад

      Got it, thanks a lot! Will actually be covered in one of my future videos.

  • @popovichrush
    @popovichrush Год назад +1

    Please do you have any contact so i contact you to code my strategy for me...?i really dont know anything about coding and been looking for someone to code for me....

    • @Algovibes
      @Algovibes  Год назад

      Sure, you can drop me a mail and if the strategy is interesting enough I will make a video on it! :-)

    • @popovichrush
      @popovichrush Год назад

      @@Algovibes how can i get you email to send you the strategy...had wanted to learn the code but i got to know that i cant be jack of all trades thats why i want you to help me code it...will be happy to send you screenshots if you dont mind