Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

➡️ 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...

23,000 görüntüleme • 28 gün önce •via TikTok

0 Yorum

Yorum bulunmuyor

Orijinal gönderinin yorumları burada görünecek

Benzer Videolar

➡️ 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.

QuantFinanceToGo

37,000 görüntüleme • 2 gün önce

➡️ Quantitative Finance from scratch part 12 closes season 1. Every part was one step in a single story about a bet with an edge, and every number below comes from that part's own run. Part 1, expected value: a $1 bet on red wins 18 times out of 37, so it loses 2.7 cents on average, and over a million bets the casino made $27,288. Part 2, the random walk: coin flips add up to something that looks like a stock chart, and the same edge becomes a drift of 2.7 cents per step. Part 3, the square root rule: after 100 random steps the typical distance is about 10, because randomness grows with the square root of time. Part 4, the bell curve: many small random steps build it, with 68 % of results within one standard deviation. Part 5, returns: percent moves multiply, so after -50 % you need +100 % to get back. Part 6, present value: at 5 % interest, $100 paid in ten years is worth $61.39 today. Part 7, volatility: two investments with the same average swing about 4 % and 32 % a year. Part 8, the Sharpe ratio (William F. Sharpe, 1966): extra return per unit of risk, 0.36 for the wild investment and 0.99 for the calm one. Part 9, volatility drag: +50 % and then -50 % leaves you 25 % down. Part 10, correlation: the less two assets move together, the less a 50/50 mix swings, from 19 % down to 10 %. Part 11, diversification: ten assets cut the risk from 20 % to 12.2 %, above a floor of 11 % that the shared market sets (Markowitz, "Portfolio Selection", Journal of Finance, 1952). The big picture: how big the edge is, how much it swings, and how much of that swing you can spread away. Season 2 brings portfolios, bets and evidence. This video is for education only, and nothing in it is financial advice. #quantfinance #finance #riskmanagement #portfolio #probability

QuantFinanceToGo

109,700 görüntüleme • 1 ay önce

Flip a coin. Heads, your account goes up 50 percent. Tails, it goes down 40 percent. Expected value is plus 5 percent a flip, so you take the bet a hundred times. Expected value says your $10,000 becomes $1.3 million. The most likely path leaves you with $52. An MIT professor explains the entire gap in one sentence, in a free undergraduate lecture, then moves on like it was nothing. His name is John Tsitsiklis. He teaches undergraduate probability at MIT. He also proved in 1994 that Q-learning converges, the result that says the algorithm under modern reinforcement learning does not merely happen to work, it has to. INFORMS gave him the von Neumann Theory Prize for that line of work in 2018. He runs the lecture on the students for an hour. First he takes the average apart. A random variable is not a number, it is a function. A bar graph of probabilities is a PMF. Expectation is the center of gravity of that bar graph, the single point where you slide a pen underneath and the thing balances. He is slow and patient about it. By minute 35 you trust the average completely. Then he stops and says he wants to give "one general word of caution." "The average of a function of a random variable, in general, is not the same as the function of the average... in general, you can not reason on the average." Everything before that sentence was the trap. Go back to the coin. Compounding is not addition. Up 50 then down 40 is not plus 10. It is 1.5 times 0.6, which is 0.9. You are down 10 percent. Do that 50 times each way and you have 0.9 to the fiftieth power. Fifty-two dollars. So where did the $1.3 million go? It is real. It is parked at the very top of the distribution. Run the hundred flips and only about one path in seven finishes above where you started. Only about one in a hundred ever reaches that $1.3 million. Those few runs are gigantic, and they carry the average for everybody else. You will not be in them. In February 2018 that trade had a ticker. XIV, short volatility, $1.9 billion in it. It had paid on the average day for seven years. On February 5 the VIX rose 115.6 percent, the biggest one-day jump ever recorded. XIV went from $115.55 to $4.22 overnight. Credit Suisse shut the note two weeks later. Nobody in it was wrong about the average. They were wrong about which path they were standing on. The usable version: your compound return is your average return minus roughly half your variance. A system averaging 20 percent a year at 40 percent vol does not compound at 20. It compounds at 12. That missing 8 is not fees or slippage. Tsitsiklis delivers the most expensive sentence in finance, finishes the variance section, and ends with "see you on Wednesday." The lecture is free. The average is free. Knowing which path you are standing on is the trade.

Veles

635,710 görüntüleme • 3 ay önce

➡️ Quantitative Finance from Scratch, part 39: GARCH. Markets show a clear pattern: calm weeks follow calm weeks, and high volatility days arrive in groups. This is called volatility clustering. Robert Engle introduced the idea in 1982 with the ARCH model (Econometrica), Tim Bollerslev extended it to GARCH in 1986 (Journal of Econometrics), and Engle received the 2003 Nobel Prize in economics for methods of analyzing time series with time-varying volatility. GARCH(1,1) builds tomorrow's variance, the square of volatility, from three parts: a small constant omega that pulls the forecast back toward a normal level, today's move squared times a weight alpha, so a big surprise raises tomorrow's forecast right away, and today's variance times a weight beta, the memory that keeps a high forecast high for a while. The code (garch_reel.py, 16 lines of Python with numpy) uses typical values omega 0.05, alpha 0.10 and beta 0.85, in percent squared per day. The normal level is a volatility of 1 % a day. After a drop of 4 % on a calm day, tomorrow's variance is 0.05 + 0.10 x 16 + 0.85 x 1 = 2.50, so the forecast volatility jumps to 1.58 %. The extra variance then halves every 13.5 trading days: the forecast for day 5 is 1.49 %, for day 10 1.39 % and for day 30 1.16 %. In 1,000,000 simulated days of the same model, a move above 2.5 % happens on 1.75 % of all days, but on 10.97 % of the days right after such a move, about 6.3 times as often. Risk managers use GARCH forecasts to update value at risk, and some funds scale their positions down when the forecast volatility rises. If you want the full picture, there is a longer GARCH video on the YouTube channel. Honest notes: all data in the video is simulated with the GARCH model itself, so the clustering is built in by design; in real markets volatility usually reacts more strongly to falls than to rises, which this simple symmetric model leaves out. The 3D landscape of columns (20 simulated stocks sharing one GARCH volatility) is an illustration with compressed heights, not to scale. The value at risk line uses 1.65 times the forecast volatility, a normal approximation for one day at 95 %. #quantfinance #garch #volatility #riskmanagement #finance Education only, not financial advice.

QuantFinanceToGo

71,900 görüntüleme • 9 gün önce

➡️ Quantitative Finance from Scratch, part 35: how market makers make money. The first source is the spread. Like an exchange booth, a market maker buys a little below the fair price at the bid and sells a little above it at the ask, so every trade earns half the gap whatever the stock does next. After selling a call, it buys delta shares, so small moves no longer matter. The second source comes from the other Greeks: theta is the income, because the call it owes loses value every day, and gamma is the cost, because after every big move it must buy shares high and sell them low to keep the hedge. If the stock moves exactly as much as the implied volatility in the price, income and cost cancel. If it stays calmer, the market maker earns, and if it moves more, it loses. Vega is the risk to this income, because a jump in implied volatility makes the call it owes more expensive. If a customer sells it the call instead, everything flips. The code (marketmaker.py, 16 lines) sells our call from part 33 at the ask (fair $10.45, ask $10.55, bid $10.35) and hedges it every day on 2,000 simulated years with an implied volatility of 20 %. With a real volatility of 16 % it earns $1.59 per call on average and every path ends in profit; at 20 % it earns $0.10, about the spread; at 24 % it loses $1.41 and only 0.3 % of paths end in profit. Honest notes: a simplified model with one option, daily hedging, Black Scholes prices, constant volatility, no trading costs, no dividends and no other customers. Real market makers manage many options at once and also face fees, inventory limits and jumps. #quantfinance #options #marketmaking #greeks #finance

QuantFinanceToGo

93,300 görüntüleme • 13 gün önce

➡️ Machine Learning from Scratch, part 31: the transformer. A transformer turns every token into a list of numbers, adds its position, and then lets every token look at the others. That step is called attention: each token has a query (what am I looking for), a key (what do I contain) and a value (what I pass on). The better a query matches a key, the more of that value flows in. Real transformers repeat this in many layers with several attention heads each. The design comes from the 2017 Google paper "Attention Is All You Need" by Ashish Vaswani and colleagues, first used for translation. A large language model is a transformer trained to predict the next token, again and again, on a huge amount of text. Our own run, nothing downloaded. attention.py is one self-attention layer in 16 lines of numpy. Every word gets a query, a key and a value of 8 numbers, starting random, trained from scratch with hand-written backpropagation on 192 made-up sentences like "the dog ate the carrot because it was hungry". The task: find out which pet "it" means. On 64 new test sentences "it" puts 99.95 percent of its attention on the right word on average (the lowest single sentence gets 99.9 percent; the program prints this as 100%). Before training it was 10 percent, spread evenly. The cat sentence from the video is one of the test sentences. Honest notes: our task is easy on purpose. Every sentence has exactly one pet, so "it" only has to learn to look for pets, and it learns that within the first pass. Real sentences with two candidates need more context, which is what many layers are for. Our small version has no positions, no scaling, no mask, one head, and only "it" asks a question. Every word of the test sentences also appears in training; the combinations are new. The 3D space in the video shows the real keys of our model, projected to three axes (two of them stretched so you can see them). The stacked layers are a sketch. #machinelearning #ai #transformer #python #llm

MachineLearningToGo

79,400 görüntüleme • 1 ay önce