Skip to content

Commit 45215d6

Browse files
SylviaZhaoooHumphreyYangmmckyjstac
authored
[commod_price] Update editorial suggestions (#443)
* [commod_price] Update editorial suggestions * [commod_price] Update the internal link * [commod_price] Update the plotting code * [commod_price] Update code * Update commod_price.md * fix a small typo in doc ref * Update lectures/commod_price.md Co-authored-by: Matt McKay <[email protected]> * Update lectures/monte_carlo.md Co-authored-by: Matt McKay <[email protected]> * Update the link of Monte Carlo * Update commod_price.md * misc --------- Co-authored-by: Humphrey Yang <[email protected]> Co-authored-by: Matt McKay <[email protected]> Co-authored-by: John Stachurski <[email protected]>
1 parent 4c08c22 commit 45215d6

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

lectures/commod_price.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ We will solve an equation where the price function is the unknown.
3232

3333
This is harder than solving an equation for an unknown number, or vector.
3434

35-
The lecture will discuss one way to solve a "functional equation" for an unknown
36-
function
35+
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).
3736

3837
For this lecture we need the `yfinance` library.
3938

@@ -70,7 +69,7 @@ s = yf.download('CT=F', '2016-1-1', '2023-4-1')['Adj Close']
7069
fig, ax = plt.subplots()
7170
7271
ax.plot(s, marker='o', alpha=0.5, ms=1)
73-
ax.set_ylabel('price', fontsize=12)
72+
ax.set_ylabel('cotton price in USD', fontsize=12)
7473
ax.set_xlabel('date', fontsize=12)
7574
7675
plt.show()
@@ -134,13 +133,12 @@ $p_t$.
134133

135134
The harvest of the commodity at time $t$ is $Z_t$.
136135

137-
We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is IID with common
138-
density function $\phi$.
136+
We assume that the sequence $\{ Z_t \}_{t \geq 1}$ is IID with common density function $\phi$, where $\phi$ is nonnegative.
139137

140138
Speculators can store the commodity between periods, with $I_t$ units
141139
purchased in the current period yielding $\alpha I_t$ units in the next.
142140

143-
Here $\alpha \in (0,1)$ is a depreciation rate for the commodity.
141+
Here the parameter $\alpha \in (0,1)$ is a depreciation rate for the commodity.
144142

145143
For simplicity, the risk free interest rate is taken to be
146144
zero, so expected profit on purchasing $I_t$ units is
@@ -175,6 +173,7 @@ $$
175173
\alpha \mathbb{E}_t \, p_{t+1} - p_t \leq 0
176174
$$ (eq:arbi)
177175
176+
This means that if the expected price is lower than the current price, there is no room for arbitrage.
178177
179178
Profit maximization gives the additional condition
180179
@@ -183,7 +182,7 @@ $$
183182
$$ (eq:pmco)
184183
185184
186-
We also require that the market clears in each period.
185+
We also require that the market clears, with supply equaling demand in each period.
187186
188187
We assume that consumers generate demand quantity $D(p)$ corresponding to
189188
price $p$.
@@ -193,12 +192,12 @@ Let $P := D^{-1}$ be the inverse demand function.
193192
194193
Regarding quantities,
195194
196-
* supply is the sum of carryover by speculators and the current harvest
195+
* supply is the sum of carryover by speculators and the current harvest, and
197196
* demand is the sum of purchases by consumers and purchases by speculators.
198197
199198
Mathematically,
200199
201-
* supply $ = X_t = \alpha I_{t-1} + Z_t$, which takes values in $S := \mathbb R_+$, while
200+
* supply is given by $X_t = \alpha I_{t-1} + Z_t$, which takes values in $S := \mathbb R_+$, while
202201
* demand $ = D(p_t) + I_t$
203202
204203
Thus, the market equilibrium condition is
@@ -220,6 +219,8 @@ How can we find an equilibrium?
220219
Our path of attack will be to seek a system of prices that depend only on the
221220
current state.
222221
222+
(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.)
223+
223224
In other words, we take a function $p$ on $S$ and set $p_t = p(X_t)$ for every $t$.
224225
225226
Prices and quantities then follow
@@ -235,8 +236,6 @@ conditions above.
235236
More precisely, we seek a $p$ such that [](eq:arbi) and [](eq:pmco) hold for
236237
the corresponding system [](eq:eosy).
237238
238-
To this end, suppose that there exists a function $p^*$ on $S$
239-
satisfying
240239
241240
$$
242241
p^*(x) = \max
@@ -285,7 +284,7 @@ But then $D(p^*(X_t)) = X_t$ and $I_t = I(X_t) = 0$.
285284
286285
As a consequence, both [](eq:arbi) and [](eq:pmco) hold.
287286
288-
We have found an equilibrium.
287+
We have found an equilibrium, which verifies the ansatz.
289288
290289
291290
### Computing the equilibrium
@@ -347,7 +346,7 @@ The code below implements this iterative process, starting from $p_0 = P$.
347346
The distribution $\phi$ is set to a shifted Beta distribution (although many
348347
other choices are possible).
349348
350-
The integral in [](eq:dopf3) is computed via Monte Carlo.
349+
The integral in [](eq:dopf3) is computed via {ref}`Monte Carlo <monte-carlo>`.
351350
352351
353352
```{code-cell} ipython3
@@ -395,7 +394,8 @@ while error > tol:
395394
396395
ax.plot(grid, price, 'k-', alpha=0.5, lw=2, label=r'$p^*$')
397396
ax.legend()
398-
ax.set_xlabel('$x$', fontsize=12)
397+
ax.set_xlabel('$x$')
398+
ax.set_ylabel("prices")
399399
400400
plt.show()
401401
```

lectures/monte_carlo.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ kernelspec:
1212
---
1313

1414

15-
15+
(monte-carlo)=
1616
# Monte Carlo and Option Pricing
1717

1818
## Overview
@@ -49,7 +49,6 @@ from numpy.random import randn
4949
```
5050

5151

52-
5352
## An introduction to Monte Carlo
5453

5554
In this section we describe how Monte Carlo can be used to compute

0 commit comments

Comments
 (0)