How To Build a Trading Strategy in Python [SHORT TERM REVERSAL] - Backtest included

  Рет қаралды 11,575

Algovibes

Algovibes

Күн бұрын

Пікірлер: 50
@petsandpaws8906
@petsandpaws8906 Жыл бұрын
You are the most knowledgeble willing to show other how to do this. Im so thankful!
@Algovibes
@Algovibes Жыл бұрын
Thank you so much for leaving such a nice comment :-)
@hsider
@hsider 3 жыл бұрын
Simple but satisfying strategy 🤠
@Algovibes
@Algovibes 3 жыл бұрын
Well that sounds perfect :D Thanks for watching and your comment. Appreciate it!
@eagleman5063
@eagleman5063 3 жыл бұрын
Great video, bro. If you have a course, I'll enroll on it! Thank you for including the references on this vid. You're amazing.
@Algovibes
@Algovibes 3 жыл бұрын
Thank you so much Paul :-) Appreciate your kind words. I'll let you know once I made one :-P
@BinhKieu82
@BinhKieu82 3 жыл бұрын
Hi Algovibes, I really enjoy your videos, simple approach but extremely efficient. Could you make a video that combine two alpha factors: momentum & mean reversion please, thank you
@Algovibes
@Algovibes 3 жыл бұрын
Thanks again :-) I still want to cover Mean reversion. Didn't cover it yet but it's on my list since one year now :D
@p8queen
@p8queen 3 жыл бұрын
awesome!!
@Algovibes
@Algovibes 3 жыл бұрын
Thanks for your feedback :-)
@DarrylHebbes
@DarrylHebbes 3 жыл бұрын
Dankeschön
@Algovibes
@Algovibes 3 жыл бұрын
Bitteschön
@SantoshLLC
@SantoshLLC 3 жыл бұрын
Thanks!
@Algovibes
@Algovibes 3 жыл бұрын
Thank YOU! :-)
@cooltraderf
@cooltraderf 3 жыл бұрын
Really great and concise too. The monthly returns adjusted by their standard deviations (volatility) for the reversal returns would be an interesting additional step. I just subscribed to your channel. Thank you.
@Algovibes
@Algovibes 3 жыл бұрын
Hi and welcome! Thank you for your subscription. Appreciate it! :-) Also an interesting suggestion. Thanks a lot!
@ihebbibani7122
@ihebbibani7122 3 жыл бұрын
Hello , for what purpose are using that calculation inside the agg() function ? Thank you
@Algovibes
@Algovibes 3 жыл бұрын
Hi :-) To cumulate the returns over one month. I have explained cumulative returns here, be kindly invited to check it out: kzbin.info/www/bejne/nIirgqqniZifhLs
@SP-db6sh
@SP-db6sh 3 жыл бұрын
Now you should initiate a pro quant course ! Salute sir !
@Algovibes
@Algovibes 3 жыл бұрын
Maybe some day. In fact my long term goal is to teach programming/finance topics - one of the reasons why I started KZbin. I appreciate your comment and thank you very much for watching :-)
@SIMONONLY
@SIMONONLY 3 жыл бұрын
any diff between prices.pct_change()resample('M').sum() and .agg(lambda x:(x+1).prod() -1)
@Algovibes
@Algovibes 3 жыл бұрын
Yep. A big difference. I have explained it in this video here: kzbin.info/www/bejne/nIirgqqniZifhLs Let me know if this is clarifying for you!
@lucksimi3320
@lucksimi3320 3 жыл бұрын
Hi How to get the 1 month low and get an sms alert when price above 1% of the 1 month low, thanks
@Algovibes
@Algovibes 3 жыл бұрын
Thank you buddy :-)
@SP-db6sh
@SP-db6sh 3 жыл бұрын
Upcoming : Price action based algo strategy in python ?
@Algovibes
@Algovibes 3 жыл бұрын
As always: Thanks a lot for your valuable suggestion, it really is a huge help :-) Will see what I can do but got some topics beforehand in the pipeline.
@boohoo708
@boohoo708 3 жыл бұрын
54 stocks in long and 54 Stocks in short is to much for a momentum strat… 10 stocks in long is enough….short you dont need… if you would calculate that, you would have much better results… 6 month ranking time is better then 12… skipping you dont need with 6 month holding time of 3 month would be better then 1 month thx for your perfect coding bro… cause this kind of strategies is usual not programmable with normal stockprogramms like tradingview…
@Algovibes
@Algovibes 3 жыл бұрын
Thanks for your comment and sharing your thoughts! :-) Really appreciate it!
@rraul
@rraul 3 жыл бұрын
Man, i Love you despite The 7x1... 😂
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a lot for your nice comment :-) Love u2 :-* What do you mean with 7x1?
@rraul
@rraul 3 жыл бұрын
Germany 7x1 Brazil on Fifa world cup
@Algovibes
@Algovibes 3 жыл бұрын
@@rraul :D Apologies for that. But come on we didn‘t even reach the KO games last time. The 7:1 game wasn‘t representative in my highly uneducated soccer opinion.
@rraul
@rraul 3 жыл бұрын
@@Algovibes lol
@boohoo708
@boohoo708 3 жыл бұрын
what python version do you use?? hopefully python 3.9
@Algovibes
@Algovibes 3 жыл бұрын
Either 3.8 or 3.9. Not quite sure in that video. One of them but for the content of the video it shouldn't make any difference.
@srengodbersen1481
@srengodbersen1481 3 жыл бұрын
Great video! How can this model be so well documented when the contrary momentum strategy is also well documented? It seems a bit odd ;)
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a a lot for your comment. Appreciate it! Maybe it's just too early but what do you mean with well documented?
@srengodbersen1481
@srengodbersen1481 3 жыл бұрын
@@Algovibes It just seem a bit to odd that two investing strategies that are direct opposite seem to work ;)
@Algovibes
@Algovibes 3 жыл бұрын
@@srengodbersen1481 ah got it now :-D Yes, but that's why the short term reversal effect is excluded in a momentum strategy.
@srengodbersen1481
@srengodbersen1481 3 жыл бұрын
@@Algovibes Thanks for your reply! That makes sence now, but still find it a bit odd :D
@kyle_bro
@kyle_bro 3 жыл бұрын
Master of Pandas
@Algovibes
@Algovibes 3 жыл бұрын
🐼 Thanks for watching and your comment mate. I appreciate it :-)
@kyle_bro
@kyle_bro 3 жыл бұрын
@@Algovibes No problem, great content! Really though how did you get so good at pandas lol
@Algovibes
@Algovibes 3 жыл бұрын
@@kyle_bro wrote my thesis mainly using pandas 🐼 for data manipulations, using pandas 🐼 nearly every day both privately and professionally. And I can tell I still have some painful experiences here and there :D
@Nightster333
@Nightster333 2 жыл бұрын
I don't understand the interest of this strategy because 0.018 < 0.613
@Algovibes
@Algovibes 2 жыл бұрын
Could you elaborate? Happy to discuss!
@Nightster333
@Nightster333 2 жыл бұрын
@@Algovibes if the return of the strategy is 0.018 and the buy and hold is 0.613 the strategy is worse than the buy and hold, unless I didn't catch something.
@johnsmith-qc8ud
@johnsmith-qc8ud 3 жыл бұрын
Hi! Great educational content! But i'm here to criticize your math a bit :) Why are you using mean() for average return? It simply gives wrong (too optimistic) results. Consider 2 months with returns -25% and +35%. Mean will result in +5%, but in fact you get sqrt(0.75*1.35) ~= +0.6% average. We get mistaken by an order in this example. You always need more % profit to compensate for negative return, thus the arithmetic mean of 1.8% may result even in negative overall profit in fact. Also the win ratio is only a half of the story when estimating the edge, another half is the average sizes of wins and losses. If they distributed unequally and average loss is greater that average win, you easily may end up with a losing strategy despite the higher than 50% win ratio. On the other hand there are profitable trending strategies with only 25-40% win ratio due to rare large wins.
@Algovibes
@Algovibes 3 жыл бұрын
Thanks a lot for watching and your kind words. Appreciate it! Also thanks a lot for sharing your thoughts. I am taking the mean return as I am assuming I am not entering with an (restricted) initial amount of capital but investing the same amount in the portfolio every month. You assume an initial amount of capital which will be shrinked on the first day and has to overcompensate the prior day. Don't get me wrong. I agree with your points but I just don't see it being false showing the average return. If you are following your assumption taking the cumulative return would be right: kzbin.info/www/bejne/nIirgqqniZifhLs BTW: Why are you taking the square root?
@johnsmith-qc8ud
@johnsmith-qc8ud 3 жыл бұрын
@@Algovibes yeah, the video you referenced is exacly about what i pointed out. The square root (in this case, or n-th root for averaging n values) comes from a definition of geometric average, the right way of averaging returns. It has exactly the same result if you use logreturns: exp(mean(ln(0.75), ln(1.35))) ~= 1.006 = +0.6%. Yes, you are right that you can ignore this if you can compensate for a loss after each negative period. The bad thing here is that it's like a hidden factor - you need some unpredictable amount of money to compensate each time after a negative period. This might be unfeasible if you invest for many years and the sum you adding each month is small comparing to the absolute variance of your investment. Thus it's better to use "compounding average" (not sure how to name it) which is geomean of returns.
Fundamental Analysis of Stocks with Python
19:09
Algovibes
Рет қаралды 28 М.
How to build a trading strategy [Momentum] with Python?
22:54
Algovibes
Рет қаралды 28 М.
Человек паук уже не тот
00:32
Miracle
Рет қаралды 3,3 МЛН
Car Bubble vs Lamborghini
00:33
Stokes Twins
Рет қаралды 20 МЛН
Wait for it 😂
00:19
ILYA BORZOV
Рет қаралды 10 МЛН
A Profitable Trade in a NASDAQ Stock (Skyward Specialty Insurance)
21:44
Algorithmic Trading Strategy Using MACD & Python
30:38
Computer Science (compsci112358)
Рет қаралды 173 М.
Master ORDER FLOW TRADING in Less than ONE HOUR!
51:01
Fractal Flow - Pro Trading Strategies
Рет қаралды 116 М.
How do Graphics Cards Work?  Exploring GPU Architecture
28:30
Branch Education
Рет қаралды 1,3 МЛН
Convert TradingView Indicators into Strategies with AI (IT FINALLY WORKS)
21:49