Skip to content

Commit

Permalink
FIX: yf change to labels and using close price (#564)
Browse files Browse the repository at this point in the history
* FIX: yf change to labels and using close price

* migrate Adj Close to Close
  • Loading branch information
mmcky authored Jan 16, 2025
1 parent 6a8f932 commit ea4253a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lectures/commod_price.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lectures/heavy_tails.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
24 changes: 12 additions & 12 deletions lectures/prob_dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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()
Expand All @@ -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')
Expand Down Expand Up @@ -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()
```
Expand Down Expand Up @@ -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
```

Expand Down

0 comments on commit ea4253a

Please sign in to comment.