Skip to content

[commod_price] Update editorial suggestions #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions lectures/commod_price.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](https://en.wikipedia.org/wiki/Functional_equation) (an equation where the unknown object is a function).

For this lecture we need the `yfinance` library.

Expand Down Expand Up @@ -70,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()
Expand Down Expand Up @@ -134,13 +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 IID with common
density function $\phi$.
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.

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
Expand Down Expand Up @@ -175,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

Expand All @@ -183,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$.
Expand All @@ -193,12 +192,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
Expand All @@ -220,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
Expand All @@ -235,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, suppose that there exists a function $p^*$ on $S$
satisfying

$$
p^*(x) = \max
Expand Down Expand Up @@ -285,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
Expand Down Expand Up @@ -347,7 +346,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 <monte-carlo>`.


```{code-cell} ipython3
Expand Down Expand Up @@ -395,7 +394,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_xlabel('$x$')
ax.set_ylabel("prices")

plt.show()
```
Expand Down
3 changes: 1 addition & 2 deletions lectures/monte_carlo.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kernelspec:
---



(monte-carlo)=
# Monte Carlo and Option Pricing

## Overview
Expand Down Expand Up @@ -49,7 +49,6 @@ from numpy.random import randn
```



## An introduction to Monte Carlo

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