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

  Рет қаралды 10,189

Algovibes

Algovibes

Күн бұрын

Пікірлер: 90
@yellowboat8773
@yellowboat8773 2 жыл бұрын
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 2 жыл бұрын
I am a programmer. Python is easy enough to learn, do it and you'll enjoy these videos even more
@CaarabaloneDZN
@CaarabaloneDZN 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@yellowboat8773 like a BOSS 👨🏽‍💼
@m4ryou5h
@m4ryou5h Жыл бұрын
I love your vids mate. Explanation, introduction, coding, result of the algo - great stuff really.
@Algovibes
@Algovibes Жыл бұрын
Thanks a lot. Appreciate your comment!
@jerrywang3225
@jerrywang3225 2 жыл бұрын
The strategies are getting more advanced in the new year. Thanks again for sharing.
@Algovibes
@Algovibes 2 жыл бұрын
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 2 жыл бұрын
These videos are the best on youtube, no doubt.
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot my mate
@thomasli341
@thomasli341 Жыл бұрын
Do you have any other source for this nasdaq historical component data? The link isn't working.
@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 2 жыл бұрын
Thank you very much for your kind words my mate
@GlebKretinin
@GlebKretinin 2 жыл бұрын
Excellent stuff. Loving the vectorised approach. Thank you for sharing!
@Algovibes
@Algovibes 2 жыл бұрын
Thanks a lot for watching my man
@bryan-9742
@bryan-9742 2 жыл бұрын
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 2 жыл бұрын
Also a good way to solve that!
@MrHypeGFX
@MrHypeGFX Жыл бұрын
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?
@gustavozambrana116
@gustavozambrana116 Жыл бұрын
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.
@ytuser7967
@ytuser7967 2 жыл бұрын
Thank you Bro, have a great and healthy new year!
@Algovibes
@Algovibes 2 жыл бұрын
Thank you so much , same for you!
@narendersingh4206
@narendersingh4206 Жыл бұрын
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!
@DevAtul
@DevAtul 2 жыл бұрын
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 2 жыл бұрын
That's awesome to read. Thanks a lot my friend!
@lokeshsalujas
@lokeshsalujas 2 жыл бұрын
I echo Atul’s sentiment. In the same position. Thankyou AlgoVibes
@assafcohen3173
@assafcohen3173 2 жыл бұрын
Great video as always!
@Algovibes
@Algovibes 2 жыл бұрын
Thanks buddy, appreciate your comment
@bryan-9742
@bryan-9742 2 жыл бұрын
Happy new year!!
@Algovibes
@Algovibes 2 жыл бұрын
Happy New Year buddy
@lorenzobaggi161
@lorenzobaggi161 2 жыл бұрын
Happy new year boss
@Algovibes
@Algovibes 2 жыл бұрын
Happy new year my mate!
@denizhan1010
@denizhan1010 2 жыл бұрын
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
@ויקטוראייזקוביץ
@ויקטוראייזקוביץ Жыл бұрын
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
@mattchannel7075
@mattchannel7075 2 жыл бұрын
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!
@isaacharmon488
@isaacharmon488 2 жыл бұрын
So far what has been your favorite strategy or the one you currently use?
@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 2 жыл бұрын
Sorry, can you elaborate on that? Didn't quite get the question. Thanks!
@stephenyip5827
@stephenyip5827 2 жыл бұрын
@@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😃
@fg0611
@fg0611 Жыл бұрын
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 Жыл бұрын
thanks my mate. Talked about this here: kzbin.info/www/bejne/jZbQaIN_nblsa7c and I think I made some book recommendations in my live stream as far as I rememember: kzbin.info/www/bejne/inuuXnaqbryhedk
@fg0611
@fg0611 Жыл бұрын
@@Algovibes checking out both vids right now. Thanks!
@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 2 жыл бұрын
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.
@fabriziofumagalli357
@fabriziofumagalli357 2 жыл бұрын
interesting. thank you for showing us! but with this approach there is still survivorship bias on delisted stocks?
@Algovibes
@Algovibes 2 жыл бұрын
Welcome mate! No, why do you think so?
@fabriziofumagalli357
@fabriziofumagalli357 2 жыл бұрын
@@Algovibes in kzbin.info/www/bejne/hXm8dquGa7eJfLc, 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
@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.
@jean-marcducommun8185
@jean-marcducommun8185 Жыл бұрын
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 :-)
@Elvis00026
@Elvis00026 2 жыл бұрын
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 2 жыл бұрын
@@Algovibes I did it (version with survivor bias) and results were great.
@mumbai59
@mumbai59 Жыл бұрын
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.
@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 2 жыл бұрын
Welchen IDE benutzen Sie?
@Algovibes
@Algovibes 2 жыл бұрын
Jupyter Notebook ☺️
@Shreendg
@Shreendg 2 жыл бұрын
@@Algovibes danke!
@Shreendg
@Shreendg 2 жыл бұрын
@@Algovibes Ich studiere Quantitativ Finanz. Leider habe ich keine Vorgrunde von Programierung. Ihre Videos haben mir dabei viel gehölfen. Vielen Dank!
@rraul
@rraul 2 жыл бұрын
Like before watching!
@Algovibes
@Algovibes 2 жыл бұрын
Man of honor 🏅
@LowQuant
@LowQuant 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
@@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).
@arunkamath
@arunkamath 2 жыл бұрын
Bro, I hope you got my mail. Looking forward for your insights.
@Algovibes
@Algovibes 2 жыл бұрын
Got it, thanks a lot! Will actually be covered in one of my future videos.
@popovichrush
@popovichrush 2 жыл бұрын
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 2 жыл бұрын
Sure, you can drop me a mail and if the strategy is interesting enough I will make a video on it! :-)
@popovichrush
@popovichrush 2 жыл бұрын
@@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
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Step-by-Step Guide: Time Series Momentum Trading with Python
20:32
Walk Forward Optimization with VectorBT and Alpaca
36:06
Part Time Larry
Рет қаралды 19 М.
How to Build a Systematic Relative Momentum Trading Strategy
1:15:30
The Chartist
Рет қаралды 19 М.
DUAL MOMENTUM | Momentum Trading Strategy by Gary Antonacci
8:03
Financial Wisdom
Рет қаралды 77 М.
LSTM Top Mistake In Price Movement Predictions For Trading
9:48
CodeTrading
Рет қаралды 106 М.
Stop Losses in Backtesting.py
27:08
Chad Thackray
Рет қаралды 17 М.
Trading with Python: Simple Scalping Strategy
13:47
CodeTrading
Рет қаралды 106 М.