"Basic Statistical Arbitrage: Understanding the Math Behind Pairs Trading" by Max Margenot

  Рет қаралды 236,280

Quantopian

Quantopian

Күн бұрын

This talk was given by Max Margenot at the Quantopian Meetup in Santa Clara on July 17th, 2017.
To learn more about Quantopian, visit: www.quantopian.com.
Video work was done by Matt Fisher, www.precipitate.media/.
Max’s background is in applied mathematics, statistics, and quantitative finance. He runs the online lecture series at Quantopian and is responsible for workshop curriculums and educational content. In addition to having experimented with algorithmic trading of cryptocurrencies and Bayesian estimation of covariance matrices, Max has published work in theoretical mathematics. He works with top universities including Columbia, U Chicago, and Cornell and holds a MS in Mathematical Finance from Boston University.
"Basic Statistical Arbitrage: Understanding the Math Behind Pairs Trading"
In algorithmic trading, information is king. You can tease out an edge to trade on even by using only the most basic properties of time series. In this lecture, we will cover the statistics that ground the trading logic when conducting pairs trades and discuss how to find pairs.
This talk is based on the following lectures from the Quantopian Lecture Series:
• Pairs Trading
• Integration, Cointegration, and Stationarity
All lectures can be found here:
www.quantopian.com/lectures
To learn more about Quantopian, visit www.quantopian.com.
Disclaimer
Quantopian provides this presentation to help people write trading algorithms - it is not intended to provide investment advice.
More specifically, the material is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory or other services by Quantopian.
In addition, the content neither constitutes investment advice nor offers any opinion with respect to the suitability of any security or any specific investment. Quantopian makes no guarantees as to accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Пікірлер: 109
@mattorrock4844
@mattorrock4844 5 жыл бұрын
Incredibly well said for a topic that can easily drown a laymen of statistics in its mathematical foundations. This will save many aspiring quants a lot of time in their algo developments , if they take the time to check their assumptions regarding stationarity. Oh what a world we now live in, where such information is offered free to the average investor. Thanks!
@k.butler8740
@k.butler8740 4 жыл бұрын
You need not only stationarity but also ergodicity for any sort of such forecasting. Max says that it's better to make many small denomination bets at a given set of odds (51% in this video) then one large denomination bet on the same set of odds. This is not true per se -- their outcomes have the same expected value because of the linearity of expectations. The reason why you want to make many small denom bets over the one large on the same odds is because of ergodicity: it is only the basket of pairs that you can make the ergodicity assumption about, not any single pair. What Max fails to note in this lecture is that it is the evolving basket of pairs or portfolio of pairs that themselves constitute a single emergent stationary and ergodic system.
@PurohitAnkit
@PurohitAnkit 2 жыл бұрын
Hi Max. Thank you for providing us with your lecture. It is really insightful 🙂
@pozloadescobar
@pozloadescobar 2 жыл бұрын
Good job Max. That was a great intro to pairs trading, particularly for folks with a few stats and time series classes. Max has a good sense of what stuff is OK to skip
@Gavinnnnnnnnnnnnnnn
@Gavinnnnnnnnnnnnnnn 4 жыл бұрын
that guy in the front is on the first peak of the dunning-kruger effect
@TheCheukhin
@TheCheukhin 4 жыл бұрын
yeh. how can he be hired?? Probably, he has a really good track record.
@Hahmzuh
@Hahmzuh 3 жыл бұрын
@Nora Wilson scam spammed across many places by fake account
@jeevajeeva2481
@jeevajeeva2481 3 жыл бұрын
@@Hahmzuh yes in every trading video they are commenting
@samuelhossain3267
@samuelhossain3267 3 жыл бұрын
aren't we all
@rahulchembakasseril5876
@rahulchembakasseril5876 3 жыл бұрын
Mount Stupid
@felipemiraflores2984
@felipemiraflores2984 2 ай бұрын
Amazing job Max, loved it!
@uwu1337
@uwu1337 3 жыл бұрын
At first I thought this was a bunch of useless maths, but when I got to the actual trading part I was pretty amazed how clever all of this actually applied in practice.
@kevinkim1778
@kevinkim1778 4 жыл бұрын
16:20. BRUH you need to understand random variables before you come here...
@ceekay5262
@ceekay5262 Жыл бұрын
Very informative. Thanks
@yousef-4334
@yousef-4334 4 жыл бұрын
I do not understand why he is admitting that he is making a mistake. because he is not making one. The pair trading requires the slope beta extracted from regression between the prices (NOT returns). The parameter beta used in CAPM, on the other hand, uses returns(NOT prices). Quantopian please correct me if I am wrong.
@amriksingh5003
@amriksingh5003 2 жыл бұрын
Hi what is that balance( Traju) symbol on trading view chart
@PotatoMan1491
@PotatoMan1491 3 жыл бұрын
I like your stuff, especially when I am not much of an expert in statistic
@babatundeakeredolu8187
@babatundeakeredolu8187 Жыл бұрын
Please can we have access to the notebook used for this lecture?
@Juanitoto
@Juanitoto 3 жыл бұрын
the dude in the front has cemented in his brain GBM GOVERNS stock prices instead of it being a model.
@chandershekhar1076
@chandershekhar1076 4 жыл бұрын
thank you
@navketan1965
@navketan1965 11 ай бұрын
Sir, In forex pairs SPREAD TRADING do you recommend use of CCI (say on 4H chart--cci 7,cci 14, cci30,cci50 values & add all these values on each pairs to spread & compare overpriced/underpriced leg).The pairs got to have correlations of at least 90%(say aud/usd &nzd/usd--aud/jpy &nzd/jpy--eur/jpy & gbp/jpy--gbp/aud & gbp/nzd etc.).Sell the overpriced & buy underpriced. This would give trader starting edge, staying power, size choice & risk control. You would be comparing deflection of prices summed up on multiple time frames(added up/robust) for asset A & B. Your wisdom is appreciated..
@paulnyagini
@paulnyagini Ай бұрын
😂😂😂😂😂 stop making me laugh.
@selmagray61
@selmagray61 4 жыл бұрын
Max is a bright kid and no longer at Quantopian. Jump to 40:28 where he self-effacingly admits that example is flawed..and that enhancing/correcting the lecture is on his todo list. Still worthwhile at seeing whats 'canned' at Q. Good luck.
@sjhughes0313
@sjhughes0313 3 жыл бұрын
Hm, but I think he corrects himself with another conceptual mistake. He says he should take the returns of each stock, then take the log of those returns, then find the linear combination, etc.. But I think he wants to be using log of the prices, in order to benefit from the log returns (log returns being different from log of the returns). So for him to properly get log returns, he'd be working with log of the prices, since log returns = log(1 + returns) = log(price 1) - log(price 2). Which mean he should be looking for some linear combination of log(price of stock 1) and log(price of stock 2). The way he describes it, he'd be looking for some linear combination of log(returns of stock 1) and log(returns of stock 2), which is incorrect. I think anyway..
@selmagray61
@selmagray61 3 жыл бұрын
@@sjhughes0313 Samuel, sorry just saw your reply. Above my pay grade with the math. Hope all is well.
@fattiger5953
@fattiger5953 3 жыл бұрын
@@sjhughes0313 I agree, cointegration on log returns doesn't really make sense.
@mvterra6
@mvterra6 2 жыл бұрын
Hi! Around 36:10 you say that you would buy 1 unit for each stock, wouldn't it be 1:1.5?
@EricOlszewski
@EricOlszewski 2 жыл бұрын
yes
@Mrslykid1992
@Mrslykid1992 5 жыл бұрын
Does Quantopian have any books that are recommend to learn quantitative finance field?
@rahuljuliofernandes222
@rahuljuliofernandes222 4 жыл бұрын
I'm starting writing my algos in 2019 does quantopian yet work?
@davidl.e5203
@davidl.e5203 2 жыл бұрын
They've closed in 2020. I believe their team now works for Robinhood
@lucasplacides2007
@lucasplacides2007 4 жыл бұрын
Does someone know the models he cites at 44:43? Can't really get the names based on his speech.
@michaelmorrison3614
@michaelmorrison3614 4 жыл бұрын
He mentions Ornstein-Uhlenbeck processes and Kalman Filters
@lucasplacides2007
@lucasplacides2007 4 жыл бұрын
@@michaelmorrison3614 thanks man! but what it's the other thing he mentions? common felters? common filters? hahah
@michaelmorrison3614
@michaelmorrison3614 4 жыл бұрын
@@lucasplacides2007 No problem, I edited my reply and added the other one, which is a Kalman Filter.
@Eigus-BikeCo
@Eigus-BikeCo 3 жыл бұрын
@@michaelmorrison3614 Thanks man, was wondering the same
@joshuadawson4952
@joshuadawson4952 5 жыл бұрын
I have been writing code in python for about 7 months. I am still struggling to write in the IDE, any suggestions on how to get better at this? Would working through the zipline documentation help with this? I cannot get Zipline to run in Jupyter bc of the RLock . Any suggestions on how to fix this. On a personal note you do an awesome job man.
@Quantopianvideos
@Quantopianvideos 5 жыл бұрын
Hi Joshua, Are you trying to use Zipline locally on your own computer? If so, it will be much easier to use Quantopian's online platform while learning the basics. Acquiring data, processing it into the right format, ingesting it, and getting useful output from your backtests is quite difficult. The best place to learn about the Quantopian platform is the tutorials. Specifically, the Getting Started and Pipeline Tutorials are designed to help people get started. They can be found at www.quantopian.com/tutorials.
@joshuadawson4952
@joshuadawson4952 5 жыл бұрын
@@Quantopianvideos Thank you for that suggestion and I will start doing that. I really wish there was more tutorials on the IDE itself, not being negative I freaking love quantopian!!! I wish I had found it sooner. Thank you for doing what you do over there
@Quantopianvideos
@Quantopianvideos 5 жыл бұрын
​@@joshuadawson4952 Thank you for the suggestion. We are working on providing a tutorial for the IDE and can let you know when it's ready. In the meantime, we do have an "Understanding the Algorithm API Tutorial" video that might give you a better understanding of how to use the various features that can be found on Quantopian: kzbin.info/www/bejne/nKvdlZutbNGgbqM.
@ck88777
@ck88777 3 жыл бұрын
dont code, stay away from trading, and get a normal job
@GF86123
@GF86123 11 ай бұрын
This guy is genius.
@user-qq8jm2dk7t
@user-qq8jm2dk7t 8 ай бұрын
it would be better if he share that Jupyter notes
@satyrn6047
@satyrn6047 3 жыл бұрын
like non-stationary, just picture the probability density over time as a surface.
@satyrn6047
@satyrn6047 3 жыл бұрын
like you can just use MAP estimation of parametric density function. then just split it up by spectrum.
@jeremyjohnson7537
@jeremyjohnson7537 7 ай бұрын
Can ou explain this in a better way?
@vansolo9794
@vansolo9794 4 жыл бұрын
That guy in the front row sticks his hand up after every question!
@jinxy7869
@jinxy7869 3 жыл бұрын
Because he knows stuff? Not everyone in the crowd is dumb as a potato.
@xh3992
@xh3992 4 жыл бұрын
please pick up basic stats concept before asking any questions
@jakobullmann7586
@jakobullmann7586 4 жыл бұрын
Omg... don’t bother about quant trading if you don’t know what a p value is!
@hanst7218
@hanst7218 3 жыл бұрын
Haha
@zam2050
@zam2050 9 ай бұрын
Whats a p value
@AV24274
@AV24274 3 ай бұрын
@@zam2050mines 7 inches
@paulnyagini
@paulnyagini Ай бұрын
There is a difference of knowing and understanding.
@hkaniugu
@hkaniugu Ай бұрын
Lol😂
@christophercatchings162
@christophercatchings162 3 жыл бұрын
Slides, Beautiful Slides.
@avinashdwivedi2015
@avinashdwivedi2015 3 жыл бұрын
Guy at the front have seen it all
@cusodha1
@cusodha1 4 жыл бұрын
I don't know why but I always found drinking something during the presentation a bit strange.
@FelipeRuedaH
@FelipeRuedaH 4 жыл бұрын
Throat can get really dry. But drinking coke?
@danielheckel2755
@danielheckel2755 4 жыл бұрын
Maybe he has a long position, just like Buffett.
@bmebri1
@bmebri1 Жыл бұрын
There's always a guy near the front of a presentation that questions your knowledge.
@carlosdesantiago1356
@carlosdesantiago1356 3 жыл бұрын
17:35 - 17:45 *drops mic* *sips coke*
@xelhaku
@xelhaku Жыл бұрын
Someone lowered the volume, that's a shame it makes this video non stationary
@nikolai228
@nikolai228 3 жыл бұрын
16:27 cringe
@watchizee7246
@watchizee7246 5 ай бұрын
He sounds exactly like Philip Gallagher.
@k.butler8740
@k.butler8740 4 жыл бұрын
While most of his flubs are not worth correcting as he understands a lot that he fails to communicate, but I think it's valuable to point out Max's misunderstanding of ergodicity. You need not only stationarity but also ergodicity for any sort of such forecasting. Max says that it's better to make many small denomination bets at a given set of odds (51% in this video) then one large denomination bet on the same set of odds. This is not true per se -- their outcomes have the same expected value because of the linearity of expectations. The reason why you want to make many small denom bets over the one large on the same odds is because of ergodicity: it is only the basket of pairs that you can make the ergodicity assumption about, not any single pair. What Max fails to note in this lecture is that it is the evolving basket of pairs or portfolio of pairs that themselves constitute a single emergent stationary and ergodic system. Otherwise you're making the textbook gamblers fallacy lol. Also, a stationary distribution is noise, not white noise. White noise is sampling of a normal distribution and the others we call colored noise, the most common of which is pink noise. We call normal noise white because its uniform in the frequency domain.
@whoislewys3546
@whoislewys3546 3 жыл бұрын
I'd just like to say I found this comment 6 months when I started learning algo trading, understood 10% of it, decided you deeply know your shit, and that if I could understand what you said here I have a chance of making it in the markets Took a several month long break, been studying hard again past couple of weeks, and now fully understand this comment So thanks for the butterfly wing flap homie
@testchannel4695
@testchannel4695 2 жыл бұрын
@@whoislewys3546 I will do the same, I'm just starting out, but I will get back in 6 months to see if it makes more sense. For now, the comment just sounds cool
@wardm4
@wardm4 2 жыл бұрын
@@testchannel4695 I wouldn't bother. The comment is mostly nonsense. Max isn't making the Gambler's fallacy. It's exactly the opposite. Ergodicity isn't needed here (and it has very little to do with expected value). It's just the law of large numbers. If you truly have 51% odds, then you can only see this by taking 1000's of bets. The fewer bets you make, the more variance will play a role in seeing your realized value being off from that 51%.
@adaelasm6467
@adaelasm6467 2 жыл бұрын
I don't think his 51% comment is about ergodicity at all. It's just basic risk management. Expected value is not the only thing that matters when deciding on capital allocation.
@PowerALTube
@PowerALTube 11 ай бұрын
@testchannel4695 yeah this comment is just utter dross masquerading as something more intelligent. Max's video is fine. Understanding that variance is additive for independent events is all that is required to decide that placing lots of small, independent bets is a good idea. No need to invoke all this ergodicity cringe...
@hanst7218
@hanst7218 3 жыл бұрын
39:05 Transaction costs will be huge.
@kylemusser7720
@kylemusser7720 5 жыл бұрын
11:34 its a t-stat not a p-value
@Donvito293
@Donvito293 4 жыл бұрын
www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.adfuller.html not true
@Ne3zyTV
@Ne3zyTV 5 жыл бұрын
I understood about 20% lol interesting still
@gornostai4ik_lol
@gornostai4ik_lol 5 жыл бұрын
really common for the first time. you will understand 100% of that after a few months watching that theme in non-stop :)
@ashleywatkins-clark1115
@ashleywatkins-clark1115 5 жыл бұрын
me, 2% & best thing I watched all year.
@Cloxxki
@Cloxxki 5 жыл бұрын
I'll all a bit theoretical and focusing on small bit to claw some profits from. Seems there are way easier ways to trade pairs and I've tested them to beabout as good as a leverage bet that you got right, long term. But without actual leveraged exposure, even without actual shorting. Just a partial re-distributing value after one asset has risen relative to the other. When you return to the mean, you are holding more units and thus more total portfolio value. It's hard to find volatile assets that cannot be easily exploited for this strategy. The hard part is to be into them only when they drop slower in value than you can milk them. With cryptos, the whole ride down to a fraction of peak values allowed to accumulate many X units. If they ever do run up ioin price somewhat, profits will be staggering. There are crazy efficient ways to exploit price fluctuations. I'm working on a strategy that get me off the job market.
@petrovsimon
@petrovsimon 4 жыл бұрын
"That was bait"... Zero laughs
@maddiehad
@maddiehad Жыл бұрын
lmao nothing is random. good talk btw.
@soykanilhan8349
@soykanilhan8349 Жыл бұрын
Can you add Turkish subtitles please
@TheFadime123
@TheFadime123 4 жыл бұрын
a lot of inaccuracies with what he is saying.
@jdavis85
@jdavis85 3 жыл бұрын
The guy in front is so disruptive. Aggressively asking questions when he doesn't know what a p value is??? You'd think he'd have some sense of shame after that.
@nikolai228
@nikolai228 3 жыл бұрын
so true
@jtm7776
@jtm7776 2 жыл бұрын
Dude was drinking the same coke the whole time
@selmagray61
@selmagray61 4 жыл бұрын
52:12 also seems very telling if you are trying to submit at minimum a pairs trades. If you don't use co-integration versus correlation or covariance in a time series...your assumptions are mute. Max makes a punishing point about the inferences drawn from correlation & covariance as oppose to co-integration. Only a propeller head can make a joke about Kalman filters "being a rich mans moving average", pretty humorous.
@k.butler8740
@k.butler8740 4 жыл бұрын
I, too, was a little offset by that at first, but you missed his point. All he's discussing regarding forecasting techniques is their utilization to synthesize stationary (and, via sublation, although this is beyond Max, ergodic) assets and then betting on the model having a smaller error term in the next few measurements then it is at a given measurement. In other words, we're betting on model error terms satisfying a limiting stationary distribution (which is kosher via CLT), that which we reductionistly call mean reversion, and therefore the model itself is only relevent inasmuch as it can synthesize a stationary and ergodic error distribution. You're much better off using some obscure and incorrect model as long as its error distribution converges to a stationary distribution as your pairs basket will be unique -- you can easily use a genetic algorithym to create a ton of examples and then back test them and loh and behold you'll get your own unique arb basis model. If you have the capital you take a bunch of these and use functional analysis/distribution theory to sublate your synthetic assets into a new even more forecastable asset.
@selmagray61
@selmagray61 3 жыл бұрын
@@k.butler8740 Kyle your a beast.
@k.butler8740
@k.butler8740 3 жыл бұрын
@@selmagray61 to a rollie pollie, so is the butterfly
@selmagray61
@selmagray61 3 жыл бұрын
@@k.butler8740 I take issue, am I the rollie pollie in this metaphor?
@k.butler8740
@k.butler8740 3 жыл бұрын
@@selmagray61 idk, but from most perspectives I'm not a beast ;)
@jacobsb374
@jacobsb374 3 жыл бұрын
I didn't understand shit. I wish i was brighter.
@herikaniugu
@herikaniugu 11 ай бұрын
Watch again and again, thats how we all do
@lancemartin1836
@lancemartin1836 2 жыл бұрын
Great video, but the guy in the front row is so insufferable
@juliaalonzo5998
@juliaalonzo5998 4 жыл бұрын
I think I'm missing something here. I feel like he's speaking japanese. I need to learn basic statistics. I feel that speaker is very smart, but he doesn't know his audience!!!!
@k.butler8740
@k.butler8740 4 жыл бұрын
he miss-states basics on many things so you can't take him literally -- lol yeah you do need the basics to be able to wade through his miss-statements and get the gist
@toaninh9120
@toaninh9120 8 ай бұрын
I'm sure this is pretty redundant rn but man Quantopian closing left a hole in my soul 🥲
@strawbryminiwheats
@strawbryminiwheats Жыл бұрын
thank you
Quant Strategy: Pairs Trading Algorithm (Mean Reversion)
15:00
Spencer Pao
Рет қаралды 58 М.
Mama vs Son vs Daddy 😭🤣
00:13
DADDYSON SHOW
Рет қаралды 50 МЛН
1,000 Diamonds! (Funny Minecraft Animation) #shorts #cartoon
00:31
toonz CRAFT
Рет қаралды 40 МЛН
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 49 МЛН
Jim Simons (full length interview) - Numberphile
1:00:43
Numberphile2
Рет қаралды 966 М.
Quants | The Alchemists of Wall Street | VPRO documentary
47:49
vpro documentary
Рет қаралды 2,5 МЛН
The mathematician who cracked Wall Street | Jim Simons
23:08
Solving distributed systems challenges in Rust
3:15:52
Jon Gjengset
Рет қаралды 222 М.
Wolfram Physics Project Launch
3:50:19
Wolfram
Рет қаралды 1,7 МЛН
2024 Citadel Quant Trading Interview with Analysis from Real Quants
23:23
Better Than Smart Phones☠️🤯 | #trollface
0:11
Not Sanu Moments
Рет қаралды 18 МЛН
Ускоряем ваш TV🚀
0:44
ARTEM_CHIBA
Рет қаралды 283 М.
Vision Pro наконец-то доработали! Но не Apple!
0:40
ÉЖИ АКСЁНОВ
Рет қаралды 453 М.
Проверил, как вам?
0:58
Коннор
Рет қаралды 363 М.