From 47e6513e37abc7f6cd71b8249261ea8e38891637 Mon Sep 17 00:00:00 2001 From: Caleb Burke Date: Thu, 18 Jun 2026 01:34:12 -0700 Subject: [PATCH] big prog on 001 --- README.md | 9 +- reading/001_Quantitative_Trading/README.md | 2 +- reading/001_Quantitative_Trading/notes.ipynb | 220 +++++++++++++++---- 3 files changed, 186 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 7ab2ab8..d032055 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,11 @@ Recommended path, generated by CLAUDE ### Phase 4 — Portfolio, Risk & Systems 1. Active Portfolio Management — Grinold & Kahn -2. Trading Systems and Methods — Kaufman (use as reference) -3. The Mathematics of Money Management — Vince -4. The Leverage Space Trading Model — Vince -5. Testing and Tuning Market Trading Systems +2. The Microstructure of Financial Markets — de Jong & Rindi +3. Trading Systems and Methods — Kaufman (use as reference) +4. The Mathematics of Money Management — Vince +5. The Leverage Space Trading Model — Vince +6. Testing and Tuning Market Trading Systems ### Phase 5 — Specialized / Optional diff --git a/reading/001_Quantitative_Trading/README.md b/reading/001_Quantitative_Trading/README.md index 1425e16..481108a 100644 --- a/reading/001_Quantitative_Trading/README.md +++ b/reading/001_Quantitative_Trading/README.md @@ -4,4 +4,4 @@ total pages=204 -**Currently reading:** chapter 1, page 40 +**Currently reading:** chapter 1, page 117 diff --git a/reading/001_Quantitative_Trading/notes.ipynb b/reading/001_Quantitative_Trading/notes.ipynb index bfbe162..de7f5f5 100644 --- a/reading/001_Quantitative_Trading/notes.ipynb +++ b/reading/001_Quantitative_Trading/notes.ipynb @@ -8,6 +8,22 @@ "# Notes" ] }, + { + "cell_type": "markdown", + "id": "b13688b9", + "metadata": {}, + "source": [ + "## Main Takeaways" + ] + }, + { + "cell_type": "markdown", + "id": "5df7046f", + "metadata": {}, + "source": [ + "## Daily routine" + ] + }, { "cell_type": "markdown", "id": "5a622bb3", @@ -23,57 +39,181 @@ "about two hours.\" - Quant trader morning routine" ] }, + { + "cell_type": "markdown", + "id": "f0855890", + "metadata": {}, + "source": [ + "## Definitions" + ] + }, { "cell_type": "markdown", "id": "7aab1f0d", "metadata": {}, "source": [ - "**Defn** directional trades - long or\n", - "short only" - ] - }, - { - "cell_type": "markdown", - "id": "152e6f82", - "metadata": {}, - "source": [ - "**Defn** dollar-neutral trades - hedged or pair trades\n" - ] - }, - { - "cell_type": "markdown", - "id": "3bf5cdfc", - "metadata": {}, - "source": [ - "**Defn** dollar neutral portfolio:\n", - "\n", - "The market value of the long positions\n", - "equals the market value of the short positions" - ] - }, - { - "cell_type": "markdown", - "id": "b7459bc6", - "metadata": {}, - "source": [ - "**Defn** market neutral portfolio:\n", - "\n", - "The beta of the portfolio with respect to a market index is close to zero, where beta measures the ratio between the expected returns of the portfolio and the expected returns of the market index" - ] - }, - { - "cell_type": "markdown", - "id": "48aa401e", - "metadata": {}, - "source": [ - "Where can we find good strategies?" + "- ***directional trades*** - long or short only\n", + "- ***dollar-neutral trades*** - hedged or pair trades\n", + "- ***dollar neutral portfolio*** - The market value of the long positions equals the market value of the short positions\n", + "- ***market neutral portfolio*** - The beta of the portfolio with respect to a market index is close to zero, where beta measures the ratio between the expected returns of the portfolio and the expected returns of the market index\n", + "- ***Leverage*** - Borrowing funds to buy an investment\n", + "- ***slippage*** - The difference between the price that triggers the trading signal and the average execution price of the entire order" ] }, { "cell_type": "markdown", "id": "8ec7516e", "metadata": {}, - "source": [] + "source": [ + "**Defn** Information Ratio (Sharpe ratio):\n", + "\n", + "$$\\text{Information Ratio} = \\frac{\\text{Average of Excess Returns}}{\\text{Standard Deviation of Excess Returns}}$$\n", + "\n", + "$$\\text{Excess Returns} = \\text{Portfolio Returns} - \\text{Benchmark Returns}$$" + ] + }, + { + "cell_type": "markdown", + "id": "865b04b1", + "metadata": {}, + "source": [ + "- ***equaity curve***: A line chart of your portfolio's value over time\n", + "- ***drawdown***: The decline from a peak to a subsequent trough, expressed as a percentage. It's a measure of loss from a prior high, not from your starting point.\n", + "- ***maximum drawdown***: The largest peak-to-trough decline over the entire history of a strategy. It answers: \"What's the worst loss someone could have experienced if they invested at the worst possible time?\" It's one of the most common risk metrics used to evaluate strategies.\n", + "- ***high watermark***: The highest portfolio value ever reached\n", + "- ***maximum drawdown duration***: The longest amount of time spent below the high watermark.\n", + "- ***basis points***: 1 basis point is 0.01%\n", + "- ***regime shift*** - Situation when the financial market structure or the macroeconomic environment undergoes a drastic change so much so that trading strategies that were profitable before may not be profitable now" + ] + }, + { + "cell_type": "markdown", + "id": "a845580c", + "metadata": {}, + "source": [ + "## Ruling out bad strategies" + ] + }, + { + "cell_type": "markdown", + "id": "303f8dc1", + "metadata": {}, + "source": [ + "\n", + "- If a strategy trades only a few times a year, chances are its\n", + "Sharpe ratio won’t be high. This does not prevent it from being\n", + "part of your multistrategy trading business, but it does disqualify\n", + "the strategy from being your main profit center.\n", + "- If a strategy has deep (e.g., more than 10 percent) or lengthy\n", + "(e.g., four or more months) drawdowns, it is unlikely that it will\n", + "have a high Sharpe ratio. I will explain the concept of drawdown\n", + "in the next section, but you can just visually inspect the equity\n", + "curve (which is also the cumulative profit-and-loss curve, assuming no redemption or cash infusion) to see if it is very bumpy\n", + "or not. Any peak-to-trough of that curve is a drawdown. (See\n", + "Figure 2.1 for an example.)\n", + "\n", + "As a rule of thumb, any strategy that has a Sharpe ratio of less\n", + "than 1 is not suitable as a stand-alone strategy\n", + "\n", + "For a given strategy, its important to ask the following:\n", + "\n", + "- Does it outperform a benchmark?\n", + "- Does it have a high enough Sharpe ratio?\n", + "- Does it have a small enough drawdown and short enough drawdown duration?\n", + "- Does the backtest suffer from survivorship bias?\n", + "- Does the strategy lose steam in recent years compared to its earlier years?\n", + "- Does the Strategy Suffer from Data-Snooping Bias?\n", + "- Does the strategy have its own “niche” that protects it from intense competition from large institutional money managers?" + ] + }, + { + "cell_type": "markdown", + "id": "ecc17253", + "metadata": {}, + "source": [ + "## Backtesting\n" + ] + }, + { + "cell_type": "markdown", + "id": "98567746", + "metadata": {}, + "source": [ + "- When gathering data for backtesting, ensure data is split and dividend adjusted.\n", + "- A backtest that relies on high and low data is less reliable than one that relies on the open and close\n", + "- Typically, an extreme return should be accompanied by a news announcement, or should occur on a day when the market index also experienced extreme returns. If not, then your data is suspect." + ] + }, + { + "cell_type": "markdown", + "id": "0dbd8630", + "metadata": {}, + "source": [ + "$$\\text{Annualized Sharpe Ratio} = \\sqrt{N_T} \\times \\text{Sharpe Ratio Based on }T$$" + ] + }, + { + "cell_type": "markdown", + "id": "319f28df", + "metadata": {}, + "source": [ + "Incorporate transaction costs into backtests. Transaction costs include:\n", + "\n", + "- Commission\n", + "- Liquidity cost\n", + "- Opportunity cost\n", + "- Market Impact\n", + "- Slippage" + ] + }, + { + "cell_type": "markdown", + "id": "1cbf1e0a", + "metadata": {}, + "source": [ + "Potential backtest performance issues:\n", + "\n", + "- Data: Split/dividend adjustments, noise in daily high/low, and\n", + "survivorship bias.\n", + "- Performance measurement: Annualized Sharpe ratio and maximum drawdown.\n", + "- Look-ahead bias: Using unobtainable future information for past\n", + "trading decisions.\n", + "- Data-snooping bias: Using too many parameters to fit historical\n", + "data, and avoiding it using large enough sample, out-of-sample\n", + "testing, and sensitivity analysis.\n", + "- Transaction cost: Impact of transaction costs on performance.\n", + "- Strategy refinement: Common ways to make small variations on\n", + "the strategy to optimize performance." + ] + }, + { + "cell_type": "markdown", + "id": "8047f4f0", + "metadata": {}, + "source": [ + "## Execution Systems: Why does actual performance diverge from expectations?" + ] + }, + { + "cell_type": "markdown", + "id": "30a1531a", + "metadata": {}, + "source": [ + "- Do you have bugs in your ATS software?\n", + "- Do the trades generated by your ATS match the ones generated\n", + "by your backtest program?\n", + "- Are the execution costs much higher than what you expected?\n", + "- Are you trading illiquid stocks that caused a lot of market impact?\n", + "- Strategy may have suffered from data-snooping bias or regime shift" + ] + }, + { + "cell_type": "markdown", + "id": "d5ea890d", + "metadata": {}, + "source": [ + "## Money and Risk Management" + ] } ], "metadata": {