From 6440f99cdb0be1d99d7c731581abe9287e01b04d Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 14 Jan 2025 10:47:26 +1100 Subject: [PATCH 1/2] FIX: yf change to labels and using close price --- lectures/prob_dist.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lectures/prob_dist.md b/lectures/prob_dist.md index 14c210c4..4760053a 100644 --- a/lectures/prob_dist.md +++ b/lectures/prob_dist.md @@ -4,7 +4,7 @@ jupytext: extension: .md format_name: myst format_version: 0.13 - jupytext_version: 1.16.1 + jupytext_version: 1.16.6 kernelspec: display_name: Python 3 (ipykernel) language: python @@ -434,7 +434,7 @@ for μ, σ in zip(μ_vals, σ_vals): u = scipy.stats.norm(μ, σ) ax.plot(x_grid, u.pdf(x_grid), alpha=0.5, lw=2, - label=f'$\mu={μ}, \sigma={σ}$') + label=rf'$\mu={μ}, \sigma={σ}$') ax.set_xlabel('x') ax.set_ylabel('PDF') plt.legend() @@ -449,7 +449,7 @@ for μ, σ in zip(μ_vals, σ_vals): u = scipy.stats.norm(μ, σ) ax.plot(x_grid, u.cdf(x_grid), alpha=0.5, lw=2, - label=f'$\mu={μ}, \sigma={σ}$') + label=rf'$\mu={μ}, \sigma={σ}$') ax.set_ylim(0, 1) ax.set_xlabel('x') ax.set_ylabel('CDF') @@ -510,7 +510,7 @@ for σ in σ_vals: u = scipy.stats.norm(μ, σ) ax.plot(x_grid, u.cdf(x_grid), alpha=0.5, lw=2, - label=f'$\mu={μ}, \sigma={σ}$') + label=rf'$\mu={μ}, \sigma={σ}$') ax.set_ylim(0, 1) ax.set_xlim(0, 3) ax.set_xlabel('x') @@ -554,7 +554,7 @@ for λ in λ_vals: u = scipy.stats.expon(scale=1/λ) ax.plot(x_grid, u.pdf(x_grid), alpha=0.5, lw=2, - label=f'$\lambda={λ}$') + label=rf'$\lambda={λ}$') ax.set_xlabel('x') ax.set_ylabel('PDF') plt.legend() @@ -567,7 +567,7 @@ for λ in λ_vals: u = scipy.stats.expon(scale=1/λ) ax.plot(x_grid, u.cdf(x_grid), alpha=0.5, lw=2, - label=f'$\lambda={λ}$') + label=rf'$\lambda={λ}$') ax.set_ylim(0, 1) ax.set_xlabel('x') ax.set_ylabel('CDF') @@ -615,7 +615,7 @@ for α, β in zip(α_vals, β_vals): u = scipy.stats.beta(α, β) ax.plot(x_grid, u.pdf(x_grid), alpha=0.5, lw=2, - label=fr'$\alpha={α}, \beta={β}$') + label=rf'$\alpha={α}, \beta={β}$') ax.set_xlabel('x') ax.set_ylabel('PDF') plt.legend() @@ -628,7 +628,7 @@ for α, β in zip(α_vals, β_vals): u = scipy.stats.beta(α, β) ax.plot(x_grid, u.cdf(x_grid), alpha=0.5, lw=2, - label=fr'$\alpha={α}, \beta={β}$') + label=rf'$\alpha={α}, \beta={β}$') ax.set_ylim(0, 1) ax.set_xlabel('x') ax.set_ylabel('CDF') @@ -675,7 +675,7 @@ for α, β in zip(α_vals, β_vals): u = scipy.stats.gamma(α, scale=1/β) ax.plot(x_grid, u.pdf(x_grid), alpha=0.5, lw=2, - label=fr'$\alpha={α}, \beta={β}$') + label=rf'$\alpha={α}, \beta={β}$') ax.set_xlabel('x') ax.set_ylabel('PDF') plt.legend() @@ -688,7 +688,7 @@ for α, β in zip(α_vals, β_vals): u = scipy.stats.gamma(α, scale=1/β) ax.plot(x_grid, u.cdf(x_grid), alpha=0.5, lw=2, - label=fr'$\alpha={α}, \beta={β}$') + label=rf'$\alpha={α}, \beta={β}$') ax.set_ylim(0, 1) ax.set_xlabel('x') ax.set_ylabel('CDF') @@ -799,7 +799,7 @@ So we will have one observation for each month. :tags: [hide-output] df = yf.download('AMZN', '2000-1-1', '2024-1-1', interval='1mo') -prices = df['Adj Close'] +prices = df['Close'] x_amazon = prices.pct_change()[1:] * 100 x_amazon.head() ``` @@ -876,7 +876,7 @@ For example, let's compare the monthly returns on Amazon shares with the monthly :tags: [hide-output] df = yf.download('COST', '2000-1-1', '2024-1-1', interval='1mo') -prices = df['Adj Close'] +prices = df['Close'] x_costco = prices.pct_change()[1:] * 100 ``` From 2d25233ec9cb92b70524bcf2b3f39df65abe79c9 Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 14 Jan 2025 11:31:30 +1100 Subject: [PATCH 2/2] migrate Adj Close to Close --- lectures/commod_price.md | 2 +- lectures/heavy_tails.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index efab8144..93654d18 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -60,7 +60,7 @@ The figure below shows the price of cotton in USD since the start of 2016. ```{code-cell} ipython3 :tags: [hide-input, hide-output] -s = yf.download('CT=F', '2016-1-1', '2023-4-1')['Adj Close'] +s = yf.download('CT=F', '2016-1-1', '2023-4-1')['Close'] ``` ```{code-cell} ipython3 diff --git a/lectures/heavy_tails.md b/lectures/heavy_tails.md index f5636fcc..854a7597 100644 --- a/lectures/heavy_tails.md +++ b/lectures/heavy_tails.md @@ -197,7 +197,7 @@ mystnb: caption: Daily Amazon returns name: dailyreturns-amzn --- -s = data['Adj Close'] +s = data['Close'] r = s.pct_change() fig, ax = plt.subplots() @@ -229,7 +229,7 @@ mystnb: caption: Daily Bitcoin returns name: dailyreturns-btc --- -s = data['Adj Close'] +s = data['Close'] r = s.pct_change() fig, ax = plt.subplots()