Backtesting OVER 500 stocks using VECTORIZATION [Do NOT skip this]
HTML-код
- Опубликовано: 21 май 2024
- Sign up to enroll for a 7-day free trial of this course now!
Google Data Analytics - imp.i384100.net/c/4063581/134...
Many thanks to @coursera for sponsoring this video!
In this video I am going over vectorizing the iterative Backtest from the previous video and also taking care of mark to market valuation of the assets. The improvement is roughly 50x speed.
Get the Notebook/Source code by becoming a Tier-3 Channel member:
/ @algovibes
Please be so kind supporting the channel by hitting like, subscribe and leaving a comment. Thanks a lot!
Please check out Part I before:
• The BIGGEST Backtest &...
Python for Finance playlist:
• Python for Finance
Interested in automated trading? Check out the Cryptobot playlist here:
• Cryptocurrency Bots / ...
Disclaimer: This video is not an investment advice and is for educational and entertainment purposes only!
00:00 - 01:15 Introduction / Disclaimer
01:15 - 02:37 Awesome Sponsor! :-)
02:37 - 03:57 Recap on the Backtest function
03:57 - 06:10 First occurrence of buying signal
06:10 - 12:42 Finding ALL signals
12:42 - 15:10 Trades / Comparison with Iterative
15:10 - 21:50 Mark to Market & Profit calculation
21:50 - 22:58 Mark to Market iterative approach
22:58 - 24:57 Wrapping it all in a function
24:57 - 26:08 Running the Backtest / Speed performance
#Coursera #CourseraPartner #python #stockmarket #backtest - Наука
Excellent one.speed results are astonishing. I will try to follow this vectorized approach in future 😊
Thanks Anil for watching and leaving a comment!
Your code is always so straight to the point, the easiest, and most efficient solutions, which is great sign of professionalism and experience! Absolutely lovely to watch your videos bro! You are just the best! 🙌♥️
Thank you very much ❤️ Appreciate your comment and having you on board!
my brain is sizzling from this one
It's an advanced topic and perfectly fine to use the iterative approach as well! I tried my best to explain it in detail 😛
great tutorial as always, can you explain why we need to find the first signal separately instead of using the diff() function to get all the signals.
Thanks mate! Sure: If you do not do it your first signal could be a selling signal. With that you are blowing up your backtest and the profit calculation.
@@Algovibes thanks for the explanation.
Can you solve this by using 1 for buys and -1 for sells, instead of True or False.
Btw thank you for the great content!!
would it be possible to use this approach to backtest a portfolio of say 5-10 stocks at a time, where you always spend like 10% of your current balance?
Sure, that's definetly possible!
can we applied reinforcement learning
I wouldn't see the application in this specific case. But RL could learn the best parameters in a realtime trade scenario.
Amazing speed, but for more sophisticated logic(Take Profit, Stop Loss, etc.) I doubt there's any way around iterative approach.
Unfortunately
It actually is possible. The thing with vectorization is: There more complex the trading logic, the harder it get's to design it using a vectorized approach.
@@Algovibes Wow! I would love to see that!
This got to be some master wizzard pandas coding +logic
AlgoKing
:-)
🙋♂
🙋🏻 😁
great! marginal gains like in cycling :-) lol
🚴🏽♂️
Loop through the df is much easier to understand 😂
And perfectly fine to use! Don't worry about it - Vectorization is an advanced topic.
Great video, as always! I have a request, can you create a video to explain walk-forward backtesting in Python. The topic explained by Kevin J. Davey in "Building Winning Algorithmic Trading System" , also you can find it here en.wikipedia.org/wiki/Walk_forward_optimization
Sure! Noted and will be covered somewhen in the upcoming months. Thanks a lot