From 9f11e914c1439a7ec19805d90117204dbb440981 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 00:57:12 +0000 Subject: [PATCH 1/3] Initial plan From 424a60bb0cb79b9485457a650a551d05a7525e54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 00:58:46 +0000 Subject: [PATCH 2/3] Fix YAML escape sequences in fig-cap attributes of mean-reversion-strategy-2 notebook Co-authored-by: steveya <7390489+steveya@users.noreply.github.com> --- posts/mean-reversion-strategy-2/index.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/posts/mean-reversion-strategy-2/index.ipynb b/posts/mean-reversion-strategy-2/index.ipynb index 9149b2a..b384edd 100644 --- a/posts/mean-reversion-strategy-2/index.ipynb +++ b/posts/mean-reversion-strategy-2/index.ipynb @@ -301,7 +301,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-terminal-pnl\n", - "#| fig-cap: \"Terminal PnL distributions widen with bias (left). The standard deviation of $Y_T$ matches the closed-form $\\sqrt{M^2 s_T^2 + s_T^4/2}$ (right).\"\n", + "#| fig-cap: 'Terminal PnL distributions widen with bias (left). The standard deviation of $Y_T$ matches the closed-form $\\sqrt{M^2 s_T^2 + s_T^4/2}$ (right).'\n", "# --- Simulation: terminal PnL distribution for different M ---\n", "theta, sigma, T, dt = 1.0, 0.10, 10, 1 / 252\n", "n_paths = 20_000\n", @@ -461,7 +461,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-sr-theta-bias\n", - "#| fig-cap: \"Asymptotic Sharpe ratio vs mean-reversion speed $\\theta$ for different biases. Lines are the closed-form formula; dots are Monte Carlo estimates.\"\n", + "#| fig-cap: 'Asymptotic Sharpe ratio vs mean-reversion speed $\\theta$ for different biases. Lines are the closed-form formula; dots are Monte Carlo estimates.'\n", "# --- Simulation: Asymptotic Sharpe Ratio vs theta for different M ---\n", "\n", "def sr_asymptotic(theta, sigma, M):\n", @@ -544,7 +544,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-sr-penalty-heatmap\n", - "#| fig-cap: \"SR penalty factor $(1 + 2\\theta M^2/\\sigma^2)^{-1/2}$ over the $(\\theta, |M|/\\sigma)$ plane. Green regions indicate low penalty; red regions indicate large penalty.\"\n", + "#| fig-cap: 'SR penalty factor $(1 + 2\\theta M^2/\\sigma^2)^{-1/2}$ over the $(\\theta, |M|/\\sigma)$ plane. Green regions indicate low penalty; red regions indicate large penalty.'\n", "# --- Heatmap: SR penalty factor as function of (theta, M/sigma) ---\n", "\n", "theta_grid = np.linspace(0.1, 5.0, 200)\n", @@ -592,7 +592,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-sr-horizon-bias\n", - "#| fig-cap: \"Finite-horizon Sharpe ratio $\\mathrm{SR}_t$ as a function of trading horizon for different biases $M$. All curves converge to their asymptotic limits (dots = MC).\"\n", + "#| fig-cap: 'Finite-horizon Sharpe ratio $\\mathrm{SR}_t$ as a function of trading horizon for different biases $M$. All curves converge to their asymptotic limits (dots = MC).'\n", "# --- Finite-horizon SR_t vs t for different M ---\n", "\n", "theta, sigma = 1.0, 0.10\n", From 4565bc365d279ee7aadb8f6bb2b26130066b773f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 01:23:39 +0000 Subject: [PATCH 3/3] Fix YAML escape sequences in fig-cap attributes of mean-reversion-strategy-3 and -4 notebooks Co-authored-by: steveya <7390489+steveya@users.noreply.github.com> --- posts/mean-reversion-strategy-3/index.ipynb | 8 ++++---- posts/mean-reversion-strategy-4/index.ipynb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/posts/mean-reversion-strategy-3/index.ipynb b/posts/mean-reversion-strategy-3/index.ipynb index 53fc3e7..979f628 100644 --- a/posts/mean-reversion-strategy-3/index.ipynb +++ b/posts/mean-reversion-strategy-3/index.ipynb @@ -174,7 +174,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-random-bias\n", - "#| fig-cap: \"Random independent bias. Expected PnL is invariant to bias uncertainty (left). SR degrades with $\\sigma_M$ following the same penalty formula as the constant-bias case (right).\"\n", + "#| fig-cap: 'Random independent bias. Expected PnL is invariant to bias uncertainty (left). SR degrades with $\\sigma_M$ following the same penalty formula as the constant-bias case (right).'\n", "# --- Simulation: SR with random independent bias ---\n", "theta, sigma, T, dt = 1.0, 0.10, 100, 1 / 252\n", "n_paths = 3_000\n", @@ -412,7 +412,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-ema-cov-pnl\n", - "#| fig-cap: \"Stationary covariance $\\Sigma_{XM}$ (left) and mean annualised PnL (right) vs EMA decay rate $\\lambda$. Faster EMA tracking increases correlation and reduces expected PnL.\"\n", + "#| fig-cap: 'Stationary covariance $\\Sigma_{XM}$ (left) and mean annualised PnL (right) vs EMA decay rate $\\lambda$. Faster EMA tracking increases correlation and reduces expected PnL.'\n", "# --- EMA: stationary covariance and mean PnL rate vs lambda ---\n", "theta, sigma = 1.0, 0.10\n", "T, dt, n_paths = 30, 1 / 252, 3_000\n", @@ -478,7 +478,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-sr-ema\n", - "#| fig-cap: \"Sharpe ratio vs $\\theta$ for different EMA decay rates. Lines are the closed-form $\\theta/\\sqrt{2(\\theta+\\lambda)}$; dots are Monte Carlo estimates.\"\n", + "#| fig-cap: 'Sharpe ratio vs $\\theta$ for different EMA decay rates. Lines are the closed-form $\\theta/\\sqrt{2(\\theta+\\lambda)}$; dots are Monte Carlo estimates.'\n", "# --- SR vs theta for different EMA speeds ---\n", "sigma = 0.10\n", "T, dt, n_paths = 100, 1 / 252, 1_000\n", @@ -554,7 +554,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-ema-penalty\n", - "#| fig-cap: \"Universal penalty curve $1/\\sqrt{1+\\lambda/\\theta}$ (left) and absolute SR heatmap over the $(\\theta, \\lambda)$ plane (right).\"\n", + "#| fig-cap: 'Universal penalty curve $1/\\sqrt{1+\\lambda/\\theta}$ (left) and absolute SR heatmap over the $(\\theta, \\lambda)$ plane (right).'\n", "# --- Penalty curve and 2-D SR heatmap ---\n", "fig, axes = plt.subplots(1, 2, figsize=(14, 5))\n", "\n", diff --git a/posts/mean-reversion-strategy-4/index.ipynb b/posts/mean-reversion-strategy-4/index.ipynb index bbe43be..ca3660c 100644 --- a/posts/mean-reversion-strategy-4/index.ipynb +++ b/posts/mean-reversion-strategy-4/index.ipynb @@ -186,7 +186,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-mle-bias\n", - "#| fig-cap: \"Finite-sample distributions of MLE estimates $\\\\hat\\\\theta$ (top) and $\\\\hat\\\\mu$ (bottom) for calibration windows of 2, 5, 10, and 20 years ($\\\\theta=1, \\\\sigma=1, \\\\mu=0$). The upward bias in $\\\\hat\\\\theta$ and the high variance of $\\\\hat\\\\mu$ diminish as the calibration window lengthens.\"\n", + "#| fig-cap: 'Finite-sample distributions of MLE estimates $\\\\hat\\\\theta$ (top) and $\\\\hat\\\\mu$ (bottom) for calibration windows of 2, 5, 10, and 20 years ($\\\\theta=1, \\\\sigma=1, \\\\mu=0$). The upward bias in $\\\\hat\\\\theta$ and the high variance of $\\\\hat\\\\mu$ diminish as the calibration window lengthens.'\n", "# --- Finite-sample bias in MLE estimates ---\n", "theta_true, sigma_true, mu_true = 1.0, 1.0, 0.0\n", "dt = 1 / 252\n", @@ -335,7 +335,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-sr-estimation\n", - "#| fig-cap: \"Estimation penalty on Sharpe ratio vs calibration length $\\\\theta T_{\\\\mathrm{est}}$. Left: penalty factor. Right: absolute SR. Monte Carlo dots closely track the theoretical curve $(1 + 2/\\\\theta T_{\\\\mathrm{est}})^{-1/2}$.\"\n", + "#| fig-cap: 'Estimation penalty on Sharpe ratio vs calibration length $\\\\theta T_{\\\\mathrm{est}}$. Left: penalty factor. Right: absolute SR. Monte Carlo dots closely track the theoretical curve $(1 + 2/\\\\theta T_{\\\\mathrm{est}})^{-1/2}$.'\n", "# --- SR vs estimation window: theory + MC ---\n", "theta_true, sigma_true, mu_true = 1.0, 1.0, 0.0\n", "dt = 1 / 252\n", @@ -493,7 +493,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-rolling-estimation\n", - "#| fig-cap: \"Rolling SMA penalty vs window length. Left: MC penalty factor for rolling SMA against the theoretical curve $(1+2/\\\\theta W)^{-1/2}$. Right: one-shot and rolling penalties overlaid on the same curve, confirming they share identical functional form.\"\n", + "#| fig-cap: 'Rolling SMA penalty vs window length. Left: MC penalty factor for rolling SMA against the theoretical curve $(1+2/\\\\theta W)^{-1/2}$. Right: one-shot and rolling penalties overlaid on the same curve, confirming they share identical functional form.'\n", "# --- Rolling estimation: SMA bias simulation ---\n", "theta_true, sigma_true = 1.0, 1.0\n", "dt = 1 / 252\n", @@ -620,7 +620,7 @@ "#| code-fold: true\n", "#| code-summary: \"Show simulation code\"\n", "#| label: fig-overconfidence\n", - "#| fig-cap: \"Distribution of predicted SR $\\\\sqrt{\\\\hat\\\\theta/2}$ vs true and realised SR for calibration lengths of 2, 5, 10, and 20 years. The median prediction systematically exceeds realised SR, with the gap narrowing as the calibration window lengthens.\"\n", + "#| fig-cap: 'Distribution of predicted SR $\\\\sqrt{\\\\hat\\\\theta/2}$ vs true and realised SR for calibration lengths of 2, 5, 10, and 20 years. The median prediction systematically exceeds realised SR, with the gap narrowing as the calibration window lengthens.'\n", "# --- Overconfidence: predicted vs realised SR ---\n", "theta_true, sigma_true = 1.0, 1.0\n", "dt = 1 / 252\n",