Advanced pair trading in Python: beta loading, optimal entry, and stop-losses

preview_player
Показать описание
How to implement the logic of pair trading, cointegration, and statistical arbitrage strategies in Python while accounting for trading fees, optimal entry, and stop-losses? And how to make your strategy truly market-neutral using beta loading or beta rotation? Today we are going to investigate that and build our own advanced trading algorithm in Python.

Don't forget to subscribe to NEDL and give this video a thumbs up for more videos in Python!

Рекомендации по теме
Комментарии
Автор

wow a real algo trading channel that isnt just about RSI and indicators

shaaf
Автор

As always, impressive content and superior execution Savva :) Love it!

kessler
Автор

Parabéns Savva, obrigado por compatilhar!👏👏👏

cassioandrade
Автор

As always thanks so much on posting such high quality content w/ detailed walkthrough!
Just a minor suggestion on your coding style that you shall consider decouple functions / utilities for easier troubleshooting and future re-factoring :)

ekolytih
Автор

Savva, thanks for all your efforts! Your channel makes some advanced econometrics and statistics concepts easier to understand.
A couple of bugs in the above video:
fee = 0.0001 isn't realistic enough. You used 0.001 in previous videos. And if you use that value here, the results won't be ok anymore.
20:10 you mistyped the "signal" variable identifer. That's why strictly typed languages which require to declare variables first still rule the world :)

johnsmith-qcud
Автор

Thanks for the video, I understood some of it. The way the strategy is explained, it sounds like we're setting a stop loss at 5%, but the potential profit when equilibrium is restored is only 2%, so it seems that this would be profitable only with an exceptionally high win rate. Is this assessment correct, or am I missing something?

neuvocastezero
Автор

question. I noticed you use prices in this methodology. Would using log returns be more relevant to maintaining the relationship? I just implemented this strategy in digital assets and my results were fairly poor for the pair I choose and I was wondering whether this could be the reason why.

bryan-
Автор

is it possible to combine this with a Kalman filter? if so can you show how? ive seen similar approaches online when its applied to z score of the rolling hedged spread

fatdog
Автор

вы супер, начну спонсировать со след зп !

slavashalel
Автор

Какие брокеры дают работать через библиотеку Python?

FabioGaldony
Автор

Great content Savva. Are you thinking about expanding the code as to take in to consideration more than 2 tickers? For example analyzing more tickers (10/20?) and choosing the ones with lowest KPSS?

nicolabarbaro
Автор

Love this, thank you so much, this is exactly what I was looking for :) Quick question, i was wondering if i could do a regression with multiple independent variables, for example how would I see how the yield curve moving as a whole, or growth and inflation as a whole vs. my dependent variables like Equities, Commodity and Currency asset classes and subcomponents and constiuents? Thank you so much. I'm a huge fan of your work.

tanberzaman
Автор

Hi Nedl. Can you explain a bit more when it comes to real trading of your case, How many lot is going to long/short for each stocks? Many thanks!

zumus
Автор

Dear Savva, thanks you for your videos. I have watched ur last pair trading video and currently this one I still don't understand how the (t) sample goes in the loop u are calling the (t) of the same day using the same day closing price to calculate models and trading on the same day closing price used in the model. Correct me if am wrong dear. Because I still don't understand how u make decision of the next trading day if is overvalued or undervalued

mallerktrading
Автор

Why do you put function definitions inside a loop?

maciekspinoff
Автор

NEDL I think there is an error in the code on beta loading when you're taking the return.

see below:

rets0 = - 1

If we agree that returns equal p1-p0/p0 = p1/p0-1 Then it seems that you're taking p0/p1 -1 instead of p1/p0 -1.

let t = 8, window = 7:

this code would yield the following:

- 1 = - 1

here you can clearly see if you're plotting this out in jupyter labs you're actually calculating the returns as p0/p1 - 1. Did you mean to do this?

bryan-