From c6302a6f754101e5699c417aae9189cbf756d572 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Thu, 9 May 2024 15:37:12 +1000 Subject: [PATCH 01/11] [commod_price] Update editorial suggestions --- lectures/commod_price.md | 13 ++++++------- lectures/monte_carlo.md | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index be5d5f33..426c42a5 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -32,8 +32,7 @@ We will solve an equation where the price function is the unknown. This is harder than solving an equation for an unknown number, or vector. -The lecture will discuss one way to solve a "functional equation" for an unknown -function +The lecture will discuss one way to solve a "functional equation" (the equation where the unknown object is a function). For this lecture we need the `yfinance` library. @@ -134,8 +133,7 @@ $p_t$. The harvest of the commodity at time $t$ is $Z_t$. -We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is IID with common -density function $\phi$. +We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is {ref}`IID ` with common density function $\phi$, where $\phi$ is nonnegative. Speculators can store the commodity between periods, with $I_t$ units purchased in the current period yielding $\alpha I_t$ units in the next. @@ -193,12 +191,12 @@ Let $P := D^{-1}$ be the inverse demand function. Regarding quantities, -* supply is the sum of carryover by speculators and the current harvest +* supply is the sum of carryover by speculators and the current harvest, and * demand is the sum of purchases by consumers and purchases by speculators. Mathematically, -* supply $ = X_t = \alpha I_{t-1} + Z_t$, which takes values in $S := \mathbb R_+$, while +* supply is given by $X_t = \alpha I_{t-1} + Z_t$, which takes values in $S := \mathbb R_+$, while * demand $ = D(p_t) + I_t$ Thus, the market equilibrium condition is @@ -347,7 +345,7 @@ The code below implements this iterative process, starting from $p_0 = P$. The distribution $\phi$ is set to a shifted Beta distribution (although many other choices are possible). -The integral in [](eq:dopf3) is computed via Monte Carlo. +The integral in [](eq:dopf3) is computed via {ref}`Monte Carlo `. ```{code-cell} ipython3 @@ -396,6 +394,7 @@ while error > tol: ax.plot(grid, price, 'k-', alpha=0.5, lw=2, label=r'$p^*$') ax.legend() ax.set_xlabel('$x$', fontsize=12) +ax.set_ylabel('$prices$', fontsize=12) plt.show() ``` diff --git a/lectures/monte_carlo.md b/lectures/monte_carlo.md index eecbd011..48c92d40 100644 --- a/lectures/monte_carlo.md +++ b/lectures/monte_carlo.md @@ -49,7 +49,7 @@ from numpy.random import randn ``` - +(Monte-Carlo)= ## An introduction to Monte Carlo In this section we describe how Monte Carlo can be used to compute From 78bfa7f60474a5b70c5454881bf00097f90dc122 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Fri, 10 May 2024 17:07:50 +1000 Subject: [PATCH 02/11] [commod_price] Update the internal link --- lectures/commod_price.md | 2 +- lectures/lln_clt.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 426c42a5..ee205bf8 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -133,7 +133,7 @@ $p_t$. The harvest of the commodity at time $t$ is $Z_t$. -We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is {ref}`IID ` with common density function $\phi$, where $\phi$ is nonnegative. +We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is {ref}`IID ` with common density function $\phi$, where $\phi$ is nonnegative. Speculators can store the commodity between periods, with $I_t$ units purchased in the current period yielding $\alpha I_t$ units in the next. diff --git a/lectures/lln_clt.md b/lectures/lln_clt.md index 7e7676ce..291690e0 100644 --- a/lectures/lln_clt.md +++ b/lectures/lln_clt.md @@ -167,6 +167,7 @@ $$ The next theorem is called Kolmogorov's strong law of large numbers. +(iid-theorem)= ````{prf:theorem} If $X_1, \ldots, X_n$ are IID and $\mathbb E |X|$ is finite, then From 8dad9e6fc7e3f6ff271aebecb38165f1edddc477 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Wed, 22 May 2024 15:10:24 +1000 Subject: [PATCH 03/11] [commod_price] Update the plotting code --- lectures/commod_price.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index ee205bf8..23350338 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -393,8 +393,8 @@ while error > tol: ax.plot(grid, price, 'k-', alpha=0.5, lw=2, label=r'$p^*$') ax.legend() -ax.set_xlabel('$x$', fontsize=12) -ax.set_ylabel('$prices$', fontsize=12) +ax.set_xlabel('$x$') +ax.set_ylabel('$prices$') plt.show() ``` From 5137111d23b46d95d6052ec10540c074cd0eb71d Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Wed, 22 May 2024 16:39:48 +1000 Subject: [PATCH 04/11] [commod_price] Update code --- lectures/commod_price.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 23350338..a8b66544 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -394,7 +394,7 @@ while error > tol: ax.plot(grid, price, 'k-', alpha=0.5, lw=2, label=r'$p^*$') ax.legend() ax.set_xlabel('$x$') -ax.set_ylabel('$prices$') +ax.set_ylabel("prices") plt.show() ``` From 559605aff59ccc1f64bbb10f88e1994fe08814b5 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Sun, 30 Jun 2024 17:06:01 +1000 Subject: [PATCH 05/11] Update commod_price.md --- lectures/commod_price.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index a8b66544..04deea78 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -345,7 +345,7 @@ The code below implements this iterative process, starting from $p_0 = P$. The distribution $\phi$ is set to a shifted Beta distribution (although many other choices are possible). -The integral in [](eq:dopf3) is computed via {ref}`Monte Carlo `. +The integral in [](eq:dopf3) is computed via {doc}`monte_carlo.md`. ```{code-cell} ipython3 From 4b823c4cbe8c41ba6a44392bfcb045fa89ed8acb Mon Sep 17 00:00:00 2001 From: Humphrey Yang Date: Sun, 30 Jun 2024 15:25:21 +0800 Subject: [PATCH 06/11] fix a small typo in doc ref --- lectures/commod_price.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 04deea78..91e21678 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -345,7 +345,7 @@ The code below implements this iterative process, starting from $p_0 = P$. The distribution $\phi$ is set to a shifted Beta distribution (although many other choices are possible). -The integral in [](eq:dopf3) is computed via {doc}`monte_carlo.md`. +The integral in [](eq:dopf3) is computed via {doc}`monte_carlo`. ```{code-cell} ipython3 From 2b2a55ac6951f32383eaf310eca9d9beab89ae3a Mon Sep 17 00:00:00 2001 From: JingkunZhao <155940781+SylviaZhaooo@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:54:53 +1000 Subject: [PATCH 07/11] Update lectures/commod_price.md Co-authored-by: Matt McKay --- lectures/commod_price.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 91e21678..ba8dfa25 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -32,7 +32,7 @@ We will solve an equation where the price function is the unknown. This is harder than solving an equation for an unknown number, or vector. -The lecture will discuss one way to solve a "functional equation" (the equation where the unknown object is a function). +The lecture will discuss one way to solve a *functional equation* (the equation where the unknown object is a function). For this lecture we need the `yfinance` library. From c51ec04148e296adef9ab12103df495c47df385c Mon Sep 17 00:00:00 2001 From: JingkunZhao <155940781+SylviaZhaooo@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:19:42 +1000 Subject: [PATCH 08/11] Update lectures/monte_carlo.md Co-authored-by: Matt McKay --- lectures/monte_carlo.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lectures/monte_carlo.md b/lectures/monte_carlo.md index 48c92d40..9df402ad 100644 --- a/lectures/monte_carlo.md +++ b/lectures/monte_carlo.md @@ -49,7 +49,6 @@ from numpy.random import randn ``` -(Monte-Carlo)= ## An introduction to Monte Carlo In this section we describe how Monte Carlo can be used to compute From 3847892f86dae6770539c1d6f8b3889c5ecfa121 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Mon, 1 Jul 2024 10:52:39 +1000 Subject: [PATCH 09/11] Update the link of Monte Carlo --- lectures/commod_price.md | 2 +- lectures/monte_carlo.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index ba8dfa25..80707fce 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -345,7 +345,7 @@ The code below implements this iterative process, starting from $p_0 = P$. The distribution $\phi$ is set to a shifted Beta distribution (although many other choices are possible). -The integral in [](eq:dopf3) is computed via {doc}`monte_carlo`. +The integral in [](eq:dopf3) is computed via {ref}`Monte Carlo `. ```{code-cell} ipython3 diff --git a/lectures/monte_carlo.md b/lectures/monte_carlo.md index 9df402ad..9f66c229 100644 --- a/lectures/monte_carlo.md +++ b/lectures/monte_carlo.md @@ -12,7 +12,7 @@ kernelspec: --- - +(monte-carlo)= # Monte Carlo and Option Pricing ## Overview From aa22a8bb14a95333121f53c398f3ea0b416383a2 Mon Sep 17 00:00:00 2001 From: JingkunZhao Date: Mon, 8 Jul 2024 12:22:22 +1000 Subject: [PATCH 10/11] Update commod_price.md --- lectures/commod_price.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 80707fce..63cc1090 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -69,7 +69,7 @@ s = yf.download('CT=F', '2016-1-1', '2023-4-1')['Adj Close'] fig, ax = plt.subplots() ax.plot(s, marker='o', alpha=0.5, ms=1) -ax.set_ylabel('price', fontsize=12) +ax.set_ylabel('cotton price in USD', fontsize=12) ax.set_xlabel('date', fontsize=12) plt.show() @@ -138,7 +138,7 @@ We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is {ref}`IID ` w Speculators can store the commodity between periods, with $I_t$ units purchased in the current period yielding $\alpha I_t$ units in the next. -Here $\alpha \in (0,1)$ is a depreciation rate for the commodity. +In general, $\alpha$ is a factor. Here $\alpha \in (0,1)$ is a depreciation rate for the commodity. For simplicity, the risk free interest rate is taken to be zero, so expected profit on purchasing $I_t$ units is @@ -173,6 +173,7 @@ $$ \alpha \mathbb{E}_t \, p_{t+1} - p_t \leq 0 $$ (eq:arbi) +This means that if the expected price is lower than the current price, there is no room for arbitrage. Profit maximization gives the additional condition @@ -181,7 +182,7 @@ $$ $$ (eq:pmco) -We also require that the market clears in each period. +We also require that the market clears, with supply equaling demand in each period. We assume that consumers generate demand quantity $D(p)$ corresponding to price $p$. @@ -233,7 +234,7 @@ conditions above. More precisely, we seek a $p$ such that [](eq:arbi) and [](eq:pmco) hold for the corresponding system [](eq:eosy). -To this end, suppose that there exists a function $p^*$ on $S$ +To this end, we apply the idea of [**ansatz**](https://en.wikipedia.org/wiki/Ansatz) here by supposing that there exists a function $p^*$ on $S$ satisfying $$ @@ -283,7 +284,7 @@ But then $D(p^*(X_t)) = X_t$ and $I_t = I(X_t) = 0$. As a consequence, both [](eq:arbi) and [](eq:pmco) hold. -We have found an equilibrium. +We have found an equilibrium, which verifies the ansatz. ### Computing the equilibrium From 053c529963cd334b3dec64c8ada49c2bc841ea48 Mon Sep 17 00:00:00 2001 From: John Stachurski Date: Mon, 8 Jul 2024 14:03:23 +1000 Subject: [PATCH 11/11] misc --- lectures/commod_price.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/commod_price.md b/lectures/commod_price.md index 63cc1090..efab8144 100644 --- a/lectures/commod_price.md +++ b/lectures/commod_price.md @@ -32,7 +32,7 @@ We will solve an equation where the price function is the unknown. This is harder than solving an equation for an unknown number, or vector. -The lecture will discuss one way to solve a *functional equation* (the equation where the unknown object is a function). +The lecture will discuss one way to solve a [functional equation](https://en.wikipedia.org/wiki/Functional_equation) (an equation where the unknown object is a function). For this lecture we need the `yfinance` library. @@ -133,12 +133,12 @@ $p_t$. The harvest of the commodity at time $t$ is $Z_t$. -We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is {ref}`IID ` with common density function $\phi$, where $\phi$ is nonnegative. +We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is IID with common density function $\phi$, where $\phi$ is nonnegative. Speculators can store the commodity between periods, with $I_t$ units purchased in the current period yielding $\alpha I_t$ units in the next. -In general, $\alpha$ is a factor. Here $\alpha \in (0,1)$ is a depreciation rate for the commodity. +Here the parameter $\alpha \in (0,1)$ is a depreciation rate for the commodity. For simplicity, the risk free interest rate is taken to be zero, so expected profit on purchasing $I_t$ units is @@ -219,6 +219,8 @@ How can we find an equilibrium? Our path of attack will be to seek a system of prices that depend only on the current state. +(Our solution method involves using an [ansatz](https://en.wikipedia.org/wiki/Ansatz), which is an educated guess --- in this case for the price function.) + In other words, we take a function $p$ on $S$ and set $p_t = p(X_t)$ for every $t$. Prices and quantities then follow @@ -234,8 +236,6 @@ conditions above. More precisely, we seek a $p$ such that [](eq:arbi) and [](eq:pmco) hold for the corresponding system [](eq:eosy). -To this end, we apply the idea of [**ansatz**](https://en.wikipedia.org/wiki/Ansatz) here by supposing that there exists a function $p^*$ on $S$ -satisfying $$ p^*(x) = \max