Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

➡️ Quantitative Finance From Scratch, Part 21: Linear Regression in finance Linear regression finds the straight line that best describes how one quantity moves with another. In finance, that is often a stock's daily return against the market's daily return. Least squares: for every day, you measure how far...

59,100 Aufrufe • vor 1 Monat •via TikTok

0 Kommentare

Keine Kommentare verfügbar

Kommentare vom Original-Post werden hier angezeigt

Ähnliche Videos

➡️ Quant Finance from scratch part 15: the CAPM (Capital asset pricing model) There is a lot of discussion in science ongoing whether it is still a good estimate for expected returns or too simple with just 1 factor (market). Still its crucial to understand the concept itsself. Step 1, a simulated market with assumed numbers, not forecasts: a risk-free asset pays 3 % a year, and the market pays 5 % more on average, with swings of 15.9 % a year. Step 2, eight stocks with betas from 0 to 1.4. Each also has swings of its own, unrelated to the market. Step 3, two of them: one with beta 0.4 and big swings of its own (20 %), one with beta 1.2 and small ones (9 %). Both swing about 21 % a year in total, yet they earned 5.3 % and 9.3 % on average. Step 4, mixing: a mix of 100 stocks like the first still earns 5.1 % but swings only 6.7 %. As in Part 11, a stock's own swings average out in a mix, while the market's swing stays. Beta measures the assets sensitivity to the market movements. Step 5, the line: the eight average returns lie on a straight line against beta, 3.1 % + 5.1 % for every step of 1 in beta. That is the CAPM equation, which gives the expected return of any single stock from its beta: expected return = risk-free rate + beta x (market's expected return - risk-free rate). For beta 1.2 it gives 3 % + 1.2 x 5 % = 9 %, close to the 9.3 % measured. Sharpe shared the 1990 Nobel Memorial Prize in Economic Sciences with Harry Markowitz and Merton Miller, his part for the theory of how assets are priced, the CAPM. The committee notes that several researchers developed it independently in the mid 1960s and names his essay "Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk" (Journal of Finance, 1964) as his pioneering achievement. This video is for education only, and nothing in it is financial advice. #quantfinance #capm #beta #finance #python

QuantFinanceToGo

58,900 Aufrufe • vor 1 Monat

➡️ Part 27 of Quantitative Finance From Scratch: the Fama-French three factor model. The market beta alone (parts 14 and 15) explains stock returns only in part, so Fama and French added two more factors, size (part 26) and value (part 25). They introduced the model in 1993 in the Journal of Financial Economics ("Common risk factors in the returns on stocks and bonds"). A factor is the return of one portfolio minus another: small minus big (SMB) and high minus low (HML, cheap minus expensive). In the regression, a stock's return above the risk-free rate equals alpha, plus a beta times each factor's return, plus an error term for the stock's own swings. Alpha is what the three factors cannot explain. In our simulation (nine portfolios, three simulated factors, 50 years of monthly returns, assumed numbers, true alpha zero), the market alone leaves the small value portfolio with an alpha of 7.9 % a year and explains only 46 % of its ups and downs. With all three factors, its alpha drops to -0.9 % a year, close to the built-in zero, the model explains 90 %, and the regression finds betas of 1.00, 1.00 and 0.96. The structure is built into the model, so it shows how the method works and makes no claim about real markets. In real data, the three factors explain much of the differences in average returns, though not all: in their 1996 tests, the continuation of short-term returns (momentum) stayed unexplained, and Fama and French later added two more factors. Eugene Fama shared the 2013 Nobel Memorial Prize in Economic Sciences with Lars Peter Hansen and Robert Shiller "for their empirical analysis of asset prices". Education only, not financial advice. #quantfinance #famafrench #factorinvesting #python #finance

QuantFinanceToGo

19,500 Aufrufe • vor 27 Tagen

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

QuantFinanceToGo

23,400 Aufrufe • vor 1 Monat

➡️ Part 29 of Quantitative Finance From Scratch: the Carhart four-factor model. The CAPM explains a stock's return with its beta, its exposure to market risk. Eugene Fama and Kenneth French (1993) added size and value, and Mark Carhart (Journal of Finance, 1997) added momentum, the tendency of last year's winners to keep winning for a while. In his model every beta is an exposure: to the market, to size, to value and to momentum. In his study of mutual funds, these four factors and fund costs almost completely explained why some funds seemed to keep winning. Our test run (assumed numbers, a teaching example: 50 years of monthly returns, four independent factors with assumed premiums, five stocks that all have a market beta of 1 and a true alpha of zero): the stock with market exposure only earns 9.6 % a year above cash, the size stock 10.7 %, the value stock 13.3 %, the momentum stock 12.8 % and the stock with all three exposures 19.7 %. For that last stock the market alone explains 40 % of its swings, three factors 69 % and all four 94 %. Real single stocks swing far more on their own, so real fits are lower, and luck still left one simulated stock with an alpha of about -3 % a year. Since then researchers have proposed many more factors. John Cochrane (2011) spoke of a "zoo of new factors", and Harvey, Liu and Zhu (2016) counted hundreds of proposed factors and warned that many are likely false discoveries. Education only, not financial advice. #quantfinance #factorinvesting #carhart #finance #python

QuantFinanceToGo

23,600 Aufrufe • vor 24 Tagen

➡️ Quantitative Finance From Scratch, Part 24: Momentum. Momentum means that assets which rose the most over the past months tend to keep rising a little longer, and the biggest losers tend to keep falling. It is the opposite of mean reversion from part 23. Quants usually measure it as the return over the past 12 months, leaving out the most recent month, because very short moves tend to reverse. In research, a classic momentum portfolio ranks many stocks by this past return, buys the top group, sells the bottom group and repeats this every month. In practice there are two common versions: long only (you only hold the top ranked stocks, for example through a momentum fund) and long short (winners minus losers, so the ups and downs of the whole market largely cancel out). In this video we simulate 500 stocks for 30 years with a small built-in continuation: expected returns that drift slowly. The long short version earns 5.9% a year with a t statistic of 6.00 and a beta of -0.01 to the market. The long only version earns 13.7% a year, but with a beta of 0.99 it moves almost one for one with the market, which itself earned 10.5% a year in this simulated path. Momentum has been found in stocks, bonds, currencies and commodities, and in more than 200 years of stock data. It also has a dangerous side: after a market fall, a sharp rebound can lift the past losers fast, and momentum portfolios have had sudden, very large losses, for example in spring 2009. Some studies find it weaker and more volatile in recent decades, and trading costs eat a part of it, but it has not disappeared. All numbers come from one simulated run with assumed numbers (seed 24). No real market data, no strategy recommendation. Education only, not financial advice. #quantitativefinance #quant #momentum #factorinvesting #finance

QuantFinanceToGo

54,000 Aufrufe • vor 1 Monat

➡️ Quantitative Finance from Scratch, part 44: Arbitrage Pricing Theory (APT). Stephen Ross published it in 1976 as an alternative to the CAPM. The CAPM explains expected returns with one risk, the market. The APT allows several risks, called factors, for example surprises in economic growth, inflation or interest rates. Every stock gets its own beta for each factor, plus swings of its own that have nothing to do with any factor. A factor model describes how a return moves when a factor changes. The APT asks a different question: what return should an investor expect for carrying that risk? In a factor model each stock can have its own alpha. The APT says this alpha should be zero, because two stocks with the same exposures carry the same risk and should earn the same expected return. The formula: E[R_i] = r_f + β_i1 λ_1 + β_i2 λ_2 + ... + β_iK λ_K, with r_f the risk free rate, β the exposure of the stock to one factor and λ the premium the market pays per unit of that factor's risk. If two stocks have the same exposures and one is expected to earn more, you buy that one and sell the other. Every factor cancels out, and with many such pairs their own swings average away. Traders who exploit such gaps push prices back, so expected returns line up on the formula, at least approximately. The theory leaves open which factors to use; researchers pick them from data, like Chen, Roll and Ross (1986) with economic factors, and the Fama-French model follows the same logic. The code (apt_reel.py, 15 lines of plain Python without packages) is general on purpose: the expected return from the risk free rate, the betas and the premiums, the alpha as the part the betas leave unexplained, and the arbitrage rule for two stocks with the same betas. Honest notes: the plane, the stocks and the long-short pairs in the video come from a simulation (seed 44), not from market data. Assumed: 100 stocks, two factors, betas between 0 and 1.5, risk free rate 2 %, premiums 4 % and 2 % per year, one stock with an alpha of 3 %, monthly factor surprises with 4.5 % and 3 % volatility, own swings 6 % per month, 64 pairs over 120 months. In the simulation the hedged position has exactly zero factor exposure and zero net cost, and the leftover swings shrink roughly with the square root of the number of pairs. Real arbitrage has costs, limits and estimation error in the betas. Sources: Ross, S. A. (1976), The Arbitrage Theory of Capital Asset Pricing, Journal of Economic Theory 13(3), 341-360. Chen, N.-F., Roll, R. and Ross, S. A. (1986), Economic Forces and the Stock Market, Journal of Business 59(3), 383-403. #quantfinance #apt #arbitragepricingtheory #factormodels #capm Education only, not financial advice.

QuantFinanceToGo

51,000 Aufrufe • vor 6 Tagen

➡️ Quantitative Finance From Scratch, Part 22: Hypothesis Testing. You start with the null hypothesis: the strategy's true average return is zero, so there is no edge. Then you ask how often pure luck would produce a result at least as extreme as yours if that were true. The t statistic divides the average return by its standard error (the typical size of the random error in an average). The p value is the probability of a t statistic at least this far from zero when there is really no edge. At the 95% confidence level, a result counts as significant when the p value is below 5%, and that matches a 95% confidence interval that does not include zero. In this video we simulate a strategy with a small real edge built in (a true Sharpe ratio of 1, daily swings of 1%) for five years. It reaches a t statistic of 1.50 and a two-sided p value of 13.3%. The 95% interval for the average daily return goes from -0.013% to +0.096%, so it includes zero and the result is not significant at the 5% level, even though the edge is real. By chance, the run only showed a Sharpe ratio of 0.67 instead of 1, and five years of data were not enough this time. A useful rule: the t statistic is about the yearly Sharpe ratio times the square root of the number of years. With a Sharpe ratio of 1, you need about four years to reach a t statistic of 2. The biggest trap is testing many rules. Test 100 strategies with no edge at all, and about 5 will still pass at the 5% level by luck. In our run, 7 did. A p value is not the probability that your strategy works. The test assumes independent returns and a market that stays the same, and a real edge can still be too small to survive trading costs. All numbers come from one simulated run with assumed numbers (seed 22). No real market data, no strategy recommendation. Education only, not financial advice. #quantitativefinance #quant #hypothesistesting #trading #statistics

QuantFinanceToGo

101,200 Aufrufe • vor 1 Monat

➡️ Quantitative Finance from Scratch, part 41: Volatility Targeting. In quant finance, risk is usually measured as volatility, how strongly a price swings up and down. Volatility comes in clusters, so stormy days tend to follow stormy days, and that makes it possible to forecast it to some extent. GARCH from parts 39 and 40 is one way to do that; rolling averages and exponentially weighted averages are others. Volatility targeting takes that forecast and compares it with a risk target you choose yourself. If your target is 10 % a year and the forecast for the market is 20 %, the market is twice as wild as you want, so you hold 10 / 20 = 50 % of your money in the market, and your risk stays at 10 %. In general: exposure = target volatility / forecast volatility. When the forecast is above your target, you hold less than all of your money. When it is below, the rule asks for more than 100 %, which means borrowing, so the exposure usually gets a cap. One limit remains: every forecast looks back. A sudden crash after a calm stretch still hits a full position, and only afterwards does the forecast jump and the position shrink. The code (vt_reel.py, 15 lines of Python with numpy) is general on purpose: a GARCH forecast for tomorrow from today's move and today's forecast (omega 0.05, alpha 0.10, beta 0.85 in percent squared per day, as in part 39), the rule exposure = target / forecast with a cap, and a daily loop over the returns that sets the exposure before each day and updates the forecast after it. #quantfinance #volatility #riskmanagement #finance #portfoliomanagement Education only, not financial advice.

QuantFinanceToGo

10,300 Aufrufe • vor 10 Tagen

➡️ Quantitative Finance From Scratch, Part 20: Backtesting. A backtest tests a trading strategy on historical data, as if you had used it back then, to see whether it would have made money and how much risk it took along the way. Portfolio managers, analysts and quant researchers run backtests before real money goes into an idea. The key idea: split the past in two. You build the rule on the first part (in sample) and then test it on later data it has never seen (out of sample). The out of sample result is the fairer check. Why it matters: if you search the past hard enough, you will find patterns, even in pure noise. Trying rule after rule until one looks good is called data mining, and many of those patterns are just statistical chance. In this video we test 498 simple rules (hold after the price rose or fell over 2 to 250 days) on 10 simulated years of a market with no edge at all. The best rule in the first five years makes +11% in sample. On the next five years, data it has never seen, the same rule loses 28% and drops to rank 460 of 498. The ten best rules in sample lose 18.5% on average out of sample. Even a properly backtested result only describes the past. Markets change, and a pattern that worked for years can stop working. Classic mistakes: look-ahead bias (using information you could not have known at that time), survivorship bias (testing only companies that still exist today) and leaving out trading costs. All numbers come from one simulated run with assumed numbers (seed 20, daily returns with zero average and a 1% daily swing). No real market data, no strategy recommendation. Education only, not financial advice. #quantitativefinance #quant #backtesting #finance #trading

QuantFinanceToGo

35,300 Aufrufe • vor 1 Monat

➡️Quantitative Finance from Scratch, part 40: GJR GARCH. The goal is simple: forecast how big tomorrow's moves will be. Volatility comes in clusters, and plain GARCH uses that by building tomorrow's forecast from today's move squared and today's forecast. Squaring wipes out the sign, though, so a 4 % drop and a 4 % rise raise tomorrow's forecast by exactly the same amount. In real stock markets a drop raises volatility much more than a rise of the same size. One reason is leverage: when the price falls, the company's debt weighs more relative to its stock, so the stock itself becomes riskier. Glosten, Jagannathan and Runkle captured this in 1993 with one extra weight, gamma, that only switches on after a down day. The model is now known as GJR GARCH: tomorrow's variance = omega + (alpha + gamma x I) x today's move squared + beta x today's variance, where I is 1 after a down day and 0 otherwise. The code (gjr_reel.py, 16 lines of Python with numpy) uses typical values omega 0.02, alpha 0.02, gamma 0.12 and beta 0.90, in percent squared per day, so the normal level is a volatility of 1 % a day. After a 4 % rise: 0.02 + 0.02 x 16 + 0.90 x 1 = 1.24, a forecast of 1.11 %. After a 4 % drop: 0.02 + 0.14 x 16 + 0.90 x 1 = 3.16, a forecast of 1.78 %. The extra volatility is 0.11 against 0.78 percentage points, about seven times as much (6.8). Plain GARCH with the values from part 39 gives 1.58 % in both cases, so right after a sell off it underestimates the risk. Source: Glosten, L. R., Jagannathan, R. and Runkle, D. E. (1993), On the Relation between the Expected Value and the Volatility of the Nominal Excess Return on Stocks, Journal of Finance 48(5), 1779 to 1801. Honest notes: the parameter values are typical textbook sizes, not estimates from real data. All market data in the video is simulated. #quantfinance #finance #volatility #riskmanagement #timeseries Education only, not financial advice.

QuantFinanceToGo

12,200 Aufrufe • vor 11 Tagen

➡️ Quantitative Finance from Scratch, part 47: What does a market maker actually do? A market maker is a trading firm that always provides two prices for a stock: the ask (higher, what you pay when you buy) and the bid (lower, what you get when you sell). When you trade as a retail investor, the other side is usually a market maker. It stands in the middle, so someone is always there to trade with you. This is called providing liquidity. In return, it earns the spread (spread = ask − bid). Buy at 99.98 dollars, sell at 100.02 dollars, and it earns four cents per share. That sounds tiny, but it repeats all day across many stocks. The job comes with two big risks. Inventory: when many people sell at once, the market maker ends up holding a lot of stock, and if the price then falls, it loses money (P&L = cash + inventory × fair price). Informed traders: someone who hears news first sells to the market maker right before the price drops. A good market maker adjusts its two prices all day, moving them with its inventory and widening the gap when the risk grows. On many exchanges, official market makers promise to quote within a maximum spread and pay lower fees in return. The code (mm_reel.py, 16 lines of plain Python without packages) is general on purpose: two quotes around a mid price, what happens when a customer buys or sells, the profit and loss, and a quote shifted with the inventory. If you want to go deeper, check out the full course I built: quantfinancetogo.com #quantfinance #marketmaking #marketmaker #finance #python Education only, not financial advice.

QuantFinanceToGo

30,200 Aufrufe • vor 2 Tagen

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

73,300 Aufrufe • vor 12 Tagen

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

112,700 Aufrufe • vor 1 Monat

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

41,100 Aufrufe • vor 4 Tagen

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

102,600 Aufrufe • vor 15 Tagen