#meanreversion
➡️ Quantitative Finance from Scratch, part 45: Statistical Arbitrage. The arbitrage from the last part was a profit without any risk. Statistical arbitrage is the practical version: many small bets that can each lose, but win on average. One of the best known and simplest forms is pairs trading: two stocks in the same business that move together. The gap between them, the spread = P_A − β · P_B (P_A price of stock A, P_B price of stock B, β the hedge ratio), keeps coming back to its average. That is the edge: the trade treats this return almost like a law, so the further the spread moves away, the more it should come back, and that way back is the profit. The rule: z = (spread − average) / standard deviation. When z reaches +2 or −2, you sell the expensive stock, buy the cheap one, and close both when the gap is back at its average. Because one stock is long and the other short, a move of the whole market mostly cancels out. News about one company can still hit a single pair, so funds make many such trades at once, and the surprises average out. The big risks: the link between two stocks can break for good, for example after a merger, and when many funds hold the same trades, they can all lose at once. The code (statarb_reel.py, 16 lines of plain Python without packages) is general on purpose: the spread from two prices and the hedge ratio, the z score, and the signal that sells the expensive stock and buys the cheap one at two standard deviations and closes at the average. If you want to go deeper, the link to my website is in my bio. #quantfinance #statisticalarbitrage #pairstrading #meanreversion #python Education only, not financial advice.
QuantFinanceToGo37,000 次观看 • 2 天前
➡️ Quantitative Finance From Scratch, Part 23: Mean Reversion. Mean reversion means that a quantity which moves far from its long run average tends to drift back toward it. A single stock price behaves much like a random walk, but spreads, ratios and rates (the gap between two related stocks, interest rates, volatility) often show a pull back. The simplest model: every day the distance from the average shrinks by a fixed share, plus a random shock. The half life is the time it takes for half of that distance to disappear, so a short half life means a strong pull back. To test for the pull, you regress today's change on yesterday's distance from the average. A negative slope means a pull back. But even pure chance often looks like a pull here: in our test, 34% of pure random walks passed the usual limit of -2. So quants use a stricter limit for the t statistic of about -3 (the Dickey-Fuller limit, about -2.9). In this video we simulate one spread with a built-in half life of 10 days for four years. The regression finds a slope of -0.070, a t statistic of -6.05 and a half life of 9.5 days, far beyond that limit. The z score measures how many standard deviations the spread is from its average. Is it profitable? Only if the pull is real, strong enough to beat trading costs and still there in data you did not use for testing. A 2016 study of 97 published return signals found that their returns were on average 58% lower after publication. The average can shift, the pull can vanish, and a spread can keep widening before it comes back. Short samples can even make a pure random walk look mean reverting: in our test, three months of a pure random walk typically showed a half life of about 10 days. Education only, not financial advice. #quantitativefinance #trading #meanreversion #statisticalarbitrage #finance
QuantFinanceToGo23,000 次观看 • 28 天前
没有更多内容可加载

