Hi everyone, thanks for watching. if you want to see how those kind of strategies can be implemented in live real money trading be kindly invited to check out my video: ruclips.net/video/rc_Y6rdBqXM/видео.html
I'm trying to learn Python for backtesting strats and although this is a bit advanced for my level right now (I started from 0 a few weeks ago), it's explained in an extremely clear and eloquent fashion. Would you recommend any other material on this exact topic? Thanks and keep up the amazing work!
Hi, thanks a lot for your comment! I personally learned a lot through university/internships but can also recommend Sentdex - a RUclips legend with incredible resources on his channel.
Well, you can learn Python from different sources. I've learned its basics from Coursera and Datacamp. It won't be enough by itself though, you should practice everything you've learned in different scenarios be it a web scraping program that crawls through a huge website or simple pandas dataframe analytics. You could also practice R for a bit, it has a similar to pandas behavior. If you're just starting coding, language shouldn't be that much of a difficulty, on the other hand your problem solving skill would be put to a real test. Btw you probably shouldn't even touch other people's code until you have a firm understanding of what's going on.
I have back-tested this code with the intraday data of 30+ indian stocks for the last 8 years and these are the results, On an average the strategy works well till 2017, The strategy has a 8 to 10% engagement rate per year, the returns are 5 to 6%.. which is really very good. (No. of trading days are 15 to 20 only, per year). So the capital is engaged for a very less time during any given year and the returns are 5 to 6%. But after 2017.., The strategy doesn't perform well. The overall returns in most of the cases are negative.. (-6 to -8%) This is a living proof of the fact that you can't rely on a very few strategies for eternity. Sooner or later, a lot of people will try to trade them in a very similar fashion, which will lead to mean reversion of the strategy returns.
Excellent tutorial as usual...Would be awesome to see such a strategy run for say 4weeks, and to see and analyse the daily performance with something like the pyfolio package.
Hi, this is great and thank you for creating this video. The main thing that is missing for me here is how to implement this so it runs in real time? right now we're just looking back and checking "what if...", but how would you go about making this live?
Great video. I got a problem executing the code. My code is stuck at cumulated [buytime:], the notification suggests the timestamp cant be calculated with the numerical operator. can anyone help me out?
@@Algovibes This may or may not be related but I'm going to ask here. I'm still confused as to where/when use of a database can expedite the backtesting process. I'm looking to get roughly 20 years of EOD data and then use that to study for the next year or so. I don't need to update it or maintain it after I get it. What's the difference between reading those daily .csv files in vs. creating a database after which I would then--have to import the database to dataframes? Read the database directly without need for dataframes? I don't know. And--if the database route is best with regard to speed, then can you explain how that is accomplished? Thanks!
Thanks a lot for your appreciative comment. Yes you are absolutely right! One should account for that. I am actually applying a similar strategy in one of my crypto videos where I am accounting for counter movements. Be kindly invited to check that out and let me know what you think: ruclips.net/video/rc_Y6rdBqXM/видео.html
@@AlgovibesI will definitely see it, I've already checked a bunch of your videos. I wanted to add that, yahoo finance has new limits on data windows, your trick didn't work and may be will never do.
Really Amazing ! Can you guide us how we can use this in the live market. Do we just need to update the dates ? I mean I want a BUY or SELL signal based on the parameters I have defined in the real time market. How can I do that? Thanks in advance!
Thank you very much for watching and your comment. Appreciate it :-) I recently uploaded a video where I am doing that with cryptocurrencies using live data and store that in a SQL database. Be kindly invited to check that out: ruclips.net/video/rc_Y6rdBqXM/видео.html There will be videos on live trading stocks as well in the future. Before that I will do some technical analysis with cryptos using real time data.
Hi mate, very glad to have you onboard! :-) You are kindly invited to check out my Python Introduction playlist if you like. In general there are a lot of beginner tutorials here on RUclips - number one for me personally is Sentdex. I personally learned the basics in university - so I have no good first hand reference. For starting out I can also recommend DataCamp.
Well I actually planned to do a tutorial on solving the Riemann Hypothesis beforehand and after that tell James Simons on how he should improve his portfolio structure ;-) No my friend, I am just kidding. (Deep) Reinforcement learning will not be covered at least in the near future. To give you realistic expectations - topics on my list are among others: - Implementation of trading strategies in Python (and maybe R) like initial move reversal, momentum in the Indian stock market, stock recommender system (based on technical indicators) and so on but ALSO some DL stuff like LSTM. - basic tutorials in R / Python / SQL / Pandas / Numpy / Sklearn / Julia - (basic) machine learning tutorials - some cryptocurrency trading stuff - Things I find interesting - Deployment stuff and actually going live with some trading strategies with real money - Stocks in general / stock market analysis in Python NEVERTHELESS thank you so much for sharing FinRL. I never heard it before and it is an absolutely incredible library from what I have just read. I will definitely have a closer look to that! Always be kindly invited to make suggestions. I didn't mean to turn you down, just want to give you realistic expectations. I am very thankful for your suggestions so far :-) A lot of text but I found this important to clarify. Best regards
@@SP-db6sh Unfortunately not on trading but the channel 'Machine Learning with Phil' has great content on Deep Q Learning. He also has courses and seems like a nice guy. Can recommend him definitely!
Thank you very much for watching and your comment. Yes, this is also applicable to cryptos. There will be some crypto trading coverage as I am doing that myself in the near future. Thanks for your patience :-)
Could you show us how to work with real time data? I am confused how to take the code from these videos and apply them to live trading data from a WebSocket
First of all thanks a lot for watching and your question! You are absolutely right. The videos are field tests and the main objective is to construct and backtest trading ideas with the help of (python) programming. Nevertheless I am happy to announce going live with a trading strategy will be covered in this channel within this year. Thanks for your patience.
I had issues with this line: exit_price = df.loc[exit_time + dt.timedelta(minutes=1)].Open For PENN on March 1, there is no next 1 minute time interval, so I was getting a indexer error. Not sure why yf was missing this data. Either have to search for the next available interval or use the close of the current bar.
Are you really sure? I just tested it and there is data for March 1st. I had to take 5 minute intervals as first march is now too far in the past for the 1 minute intervals. But yes as you already suggested one could also just take the next row. Might be even better. Thanks a lot for sharing!
great video, just came on my time line somehow. thanks for the simple explanation. do you have an email ID where I can reach out to you to get some doubts cleared for a similar strategy am trying to code ? cheers and god bless.
Hey mate, thanks a lot for your kind comment :-) Unfortunately I don't have a RUclips related mail yet but I will provide one in the about me section very soon.
All of your videos make the (understandable) German mistake that all markets and activity are rational and can be understood with logic and reason. This is true maybe 80-90% of the time but that 10-20% can really fuck you over if you have no way to adjust or control for it which you never seem to do. And that small percent can wipe out all of someone’s gains.
Hi Algovibes, Thank you very much for all the helpful videos you make. I am trying to backtest a strategy where the asset is sold when my tp percentage is met or when the chart goes for example 1 bar in the other direction. And then I want to convert the trade to a trade in the other direction. I've tried this code, but it only calculates the first exit. I also tried the code from the video ruclips.net/video/rc_Y6rdBqXM/видео.html but it also doesn't work the way I want. I modified the codes to my liking, but unfortunately it still doesn't work the way I want. I've been searching for the right code or combination of code for several days now. I also watched all your videos in the Python for Finance playlist. What could I change in one of your codes to get this working? I hope you have time to help. Thanks again.
Thanks a lot Taya, well I can't tell. But let me tell you it is nothing unusual to come across things not working. To figure out why it doesn't work can take days or even weeks. Just try to understand why it doesn't work and try to slice the problem in as small chunks as possible.
@@Algovibes Thanks for the reply. It's so frustrating sometimes when something doesn't work out and when you've been doing it for so long. I solved the problem for now by adding extra columns with new conditions. We are now testing and fine-tuning the strategy. If this is a profitable strategy, we are happy to share it with you. Your videos are really helpful, thanks again for all you do.
Hi everyone,
thanks for watching.
if you want to see how those kind of strategies can be implemented in live real money trading be kindly invited to check out my video:
ruclips.net/video/rc_Y6rdBqXM/видео.html
I had to stop everything I was doing to watch this because I already know it's going to be awesome
What a legendary comment :-D Thanks for that and also thanks everyone liking the comment. Really appreciate it.
Duuuuuuude! Awesome job! Keep it up!!
Thanks a lot buddy. Appreciate your kind words :-)
Thank you very much, I hope more to come ! All Love and stay safe
Thank YOU for watching and your kind words.
Love ❤️ back and you stay safe as well please!
absolutely great work , you are better and better, thx much, I am very interested in these trading techniques and backtesting
Thank you so much :-)
Like intraday strategy videos a lot! Thank you for sharing!
Thank YOU for watching and commenting :-)
Superb video again
Thank you very much :-)
I'm trying to learn Python for backtesting strats and although this is a bit advanced for my level right now (I started from 0 a few weeks ago), it's explained in an extremely clear and eloquent fashion. Would you recommend any other material on this exact topic? Thanks and keep up the amazing work!
Hi, thanks a lot for your comment! I personally learned a lot through university/internships but can also recommend Sentdex - a RUclips legend with incredible resources on his channel.
Well, you can learn Python from different sources. I've learned its basics from Coursera and Datacamp. It won't be enough by itself though, you should practice everything you've learned in different scenarios be it a web scraping program that crawls through a huge website or simple pandas dataframe analytics.
You could also practice R for a bit, it has a similar to pandas behavior.
If you're just starting coding, language shouldn't be that much of a difficulty, on the other hand your problem solving skill would be put to a real test.
Btw you probably shouldn't even touch other people's code until you have a firm understanding of what's going on.
I have back-tested this code with the intraday data of 30+ indian stocks for the last 8 years and these are the results,
On an average the strategy works well till 2017,
The strategy has a 8 to 10% engagement rate per year, the returns are 5 to 6%.. which is really very good. (No. of trading days are 15 to 20 only, per year).
So the capital is engaged for a very less time during any given year and the returns are 5 to 6%.
But after 2017..,
The strategy doesn't perform well. The overall returns in most of the cases are negative.. (-6 to -8%)
This is a living proof of the fact that you can't rely on a very few strategies for eternity. Sooner or later, a lot of people will try to trade them in a very similar fashion, which will lead to mean reversion of the strategy returns.
Excellent tutorial as usual...Would be awesome to see such a strategy run for say 4weeks, and to see and analyse the daily performance with something like the pyfolio package.
Master of algo trading..
Far away from that but I am working on it 😛 Thanks for your comment tho, appreciate it :-)
I love your videos! You are so explicit, so accurate and very much comprehensive! Totally learning a lot from you bro! Thank you so much! ♥️♥️♥️
Really appreciate your comment and your positive attitude. Thank you so much!
Anohet thank commen , dude you rock
This is great. Could you show in some videos, how to iterate and find solid entry and exit values and show the statistics?
Thanks a lot for watching and your comment :-) Appreciate it. I will see what I can do! Thanks a bunch for the suggestion. Always helps me!
Another excellent video.
Thank you so much! 😊
Hi, this is great and thank you for creating this video. The main thing that is missing for me here is how to implement this so it runs in real time? right now we're just looking back and checking "what if...", but how would you go about making this live?
Hi mate,
Among others I am using these strategies in my cryptobots in live trading. Be invited to check out the cryptobot playlist.
You are awesome, man! Thanks. Based on your momentum video i have finded a great strategy to profit in brazilian market.
No, u are for supporting me :-) That's really great to hear! Thank you very much for watching.
can you also test the opening range breakout strat in python
Thanks for the suggestion man!
Great video. I got a problem executing the code. My code is stuck at cumulated [buytime:], the notification suggests the timestamp cant be calculated with the numerical operator. can anyone help me out?
Hi man, thanks a lot.
did you somewhere deviate from my code?
If not can you provide me a timestamp where you are struggling?
Great video as usual! This code is good for backtesting. Can you make a video about london breakout trading strategy?
Awesome suggestion. Noted that. Thank you very much for watching! :-)
sir can we use sqlite in this scanner for fast getting results.
Yes sure. If you are scanning a huge amount of assets I would even recommend a more efficient solution than scraping.
@@Algovibes This may or may not be related but I'm going to ask here. I'm still confused as to where/when use of a database can expedite the backtesting process. I'm looking to get roughly 20 years of EOD data and then use that to study for the next year or so. I don't need to update it or maintain it after I get it. What's the difference between reading those daily .csv files in vs. creating a database after which I would then--have to import the database to dataframes? Read the database directly without need for dataframes? I don't know. And--if the database route is best with regard to speed, then can you explain how that is accomplished? Thanks!
Amazing work dude. The strategy gives me tiny results since it doesn't account for the down trend.
Thanks a lot for your appreciative comment. Yes you are absolutely right! One should account for that.
I am actually applying a similar strategy in one of my crypto videos where I am accounting for counter movements. Be kindly invited to check that out and let me know what you think:
ruclips.net/video/rc_Y6rdBqXM/видео.html
@@AlgovibesI will definitely see it, I've already checked a bunch of your videos. I wanted to add that, yahoo finance has new limits on data windows, your trick didn't work and may be will never do.
Really Amazing ! Can you guide us how we can use this in the live market. Do we just need to update the dates ? I mean I want a BUY or SELL signal based on the parameters I have defined in the real time market. How can I do that?
Thanks in advance!
Thank you very much for watching and your comment. Appreciate it :-)
I recently uploaded a video where I am doing that with cryptocurrencies using live data and store that in a SQL database.
Be kindly invited to check that out:
ruclips.net/video/rc_Y6rdBqXM/видео.html
There will be videos on live trading stocks as well in the future. Before that I will do some technical analysis with cryptos using real time data.
@@Algovibes can you share your email id please ?
@@manishagarwal8737 I will in the upcoming weeks in the about page on my channel. Thanks for your patience.
it would be great if you could put up a multi time Frame intraday strategy
Thanks for the suggestion! :-) Really appreciate it and would be indeed quite interesting.
Hey brother i have been checking your channel since past few days , can you please tell me from where should i start learning python programming .
Hi mate, very glad to have you onboard! :-) You are kindly invited to check out my Python Introduction playlist if you like. In general there are a lot of beginner tutorials here on RUclips - number one for me personally is Sentdex.
I personally learned the basics in university - so I have no good first hand reference. For starting out I can also recommend DataCamp.
@@Algovibes okay thanks man
Is it possible to backtest intraday data older than 60 days in python?
Yes it is! I am showing in some video how you can do that with database storage.
@@Algovibes Do you mind telling me which video in particular? Thanks for your response.
sir create a video of creating scanner using Talib technical indicator liabrary, how we get result faster from getting live data from api.
Awesome suggestion! Thank you very much :-)
Next topic can be, Process to build & optimize a swing trading strategy through FinRL platform for implemention of DRL on trading.
Well I actually planned to do a tutorial on solving the Riemann Hypothesis beforehand and after that tell James Simons on how he should improve his portfolio structure ;-)
No my friend, I am just kidding. (Deep) Reinforcement learning will not be covered at least in the near future. To give you realistic expectations - topics on my list are among others:
- Implementation of trading strategies in Python (and maybe R) like initial move reversal, momentum in the Indian stock market, stock recommender system (based on technical indicators) and so on but ALSO some DL stuff like LSTM.
- basic tutorials in R / Python / SQL / Pandas / Numpy / Sklearn / Julia
- (basic) machine learning tutorials
- some cryptocurrency trading stuff
- Things I find interesting
- Deployment stuff and actually going live with some trading strategies with real money
- Stocks in general / stock market analysis in Python
NEVERTHELESS thank you so much for sharing FinRL. I never heard it before and it is an absolutely incredible library from what I have just read. I will definitely have a closer look to that!
Always be kindly invited to make suggestions. I didn't mean to turn you down, just want to give you realistic expectations. I am very thankful for your suggestions so far :-)
A lot of text but I found this important to clarify.
Best regards
@@Algovibes Can you mention someone working on DRL implementation on trading perspective ?
@@SP-db6sh Unfortunately not on trading but the channel 'Machine Learning with Phil' has great content on Deep Q Learning. He also has courses and seems like a nice guy. Can recommend him definitely!
Can we apply this strategy on crypto?
Thank you very much for watching and your comment. Yes, this is also applicable to cryptos. There will be some crypto trading coverage as I am doing that myself in the near future. Thanks for your patience :-)
@@Algovibes i appreciate your work
Could you show us how to work with real time data? I am confused how to take the code from these videos and apply them to live trading data from a WebSocket
First of all thanks a lot for watching and your question!
You are absolutely right. The videos are field tests and the main objective is to construct and backtest trading ideas with the help of (python) programming.
Nevertheless I am happy to announce going live with a trading strategy will be covered in this channel within this year. Thanks for your patience.
Could you give a python code for my strategy for fee ?
No but you can send me the strategy per mail and if it is interesting enough I am happy to cover it in one of my future videos.
I had issues with this line:
exit_price = df.loc[exit_time + dt.timedelta(minutes=1)].Open
For PENN on March 1, there is no next 1 minute time interval, so I was getting a indexer error. Not sure why yf was missing this data. Either have to search for the next available interval or use the close of the current bar.
Are you really sure? I just tested it and there is data for March 1st. I had to take 5 minute intervals as first march is now too far in the past for the 1 minute intervals. But yes as you already suggested one could also just take the next row. Might be even better. Thanks a lot for sharing!
@@Algovibes Yes, it happened for several tickers, not just PENN. But then, this is yahoo finance, so not the most reliable data source.
@@Algovibes Are 5m and longer intraday intervals available on yf more than one month back?
How to backtest 1 min data of indices over last 5 years??
I have covered that in this video:
ruclips.net/video/HB1CLz0Z1NY/видео.html
It is on cryptos but maybe you will find something of value there as well!
@@Algovibes What should be changed as per video in code for Banknifty indices??
For stock market
great video, just came on my time line somehow. thanks for the simple explanation. do you have an email ID where I can reach out to you to get some doubts cleared for a similar strategy am trying to code ? cheers and god bless.
Hey mate, thanks a lot for your kind comment :-)
Unfortunately I don't have a RUclips related mail yet but I will provide one in the about me section very soon.
All of your videos make the (understandable) German mistake that all markets and activity are rational and can be understood with logic and reason. This is true maybe 80-90% of the time but that 10-20% can really fuck you over if you have no way to adjust or control for it which you never seem to do. And that small percent can wipe out all of someone’s gains.
Wait. Wasn't it the Americans who crashed our finance system and not the germans? 😛
Hi Algovibes, Can you please share your email ID please, for enquiry ? if you are interested in project related with your skills ?
Hi and thank you very much for the request. Appreciate it. I will add an email in the upcoming weeks in the about me page.
Hi Algovibes,
Thank you very much for all the helpful videos you make.
I am trying to backtest a strategy where the asset is sold when my tp percentage is met or when the chart goes for example 1 bar in the other direction. And then I want to convert the trade to a trade in the other direction. I've tried this code, but it only calculates the first exit. I also tried the code from the video ruclips.net/video/rc_Y6rdBqXM/видео.html but it also doesn't work the way I want. I modified the codes to my liking, but unfortunately it still doesn't work the way I want. I've been searching for the right code or combination of code for several days now. I also watched all your videos in the Python for Finance playlist.
What could I change in one of your codes to get this working? I hope you have time to help.
Thanks again.
Thanks a lot Taya,
well I can't tell. But let me tell you it is nothing unusual to come across things not working. To figure out why it doesn't work can take days or even weeks. Just try to understand why it doesn't work and try to slice the problem in as small chunks as possible.
@@Algovibes Thanks for the reply. It's so frustrating sometimes when something doesn't work out and when you've been doing it for so long. I solved the problem for now by adding extra columns with new conditions. We are now testing and fine-tuning the strategy. If this is a profitable strategy, we are happy to share it with you.
Your videos are really helpful, thanks again for all you do.