Skip to content

Commod price edits #254

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 1 commit into from
Jun 28, 2023
Merged
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
76 changes: 49 additions & 27 deletions lectures/commod_price.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,58 @@ kernelspec:
name: python3
---

For this lecture we need the `yfinance` library.

```{code-cell} ipython3
:tags: [hide-output]
!pip install yfinance
```


# Commodity Prices

For more than half of all countries around the globe, [commodities](https://en.wikipedia.org/wiki/Commodity) account for [the majority of total exports](https://unctad.org/publication/commodities-and-development-report-2019).
## Outline

For more than half of all countries around the globe, [commodities](https://en.wikipedia.org/wiki/Commodity) account for [the majority of total exports](https://unctad.org/publication/commodities-and-development-report-2019).

Examples of commodities include copper, diamonds, iron ore, lithium, cotton
and coffee beans.

In this lecture we give an introduction to the theory of commodity prices.

The figure below shows the price of cotton in USD since the start of 2016.
The lecture is quite advanced relative to other lectures in this series.

We need to compute an equilibrium, and that equilibrium is described by a
price function.

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

For this lecture we need the `yfinance` library.

```{code-cell} ipython3
:tags: [hide-input, hide-output]
:tags: [hide-output]
!pip install yfinance
```

We will use the following imports


```{code-cell} ipython3
import numpy as np
import yfinance as yf
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
from scipy.optimize import minimize_scalar, brentq
from scipy.stats import beta
```

## Data

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']
```

Expand All @@ -51,11 +78,18 @@ plt.show()

The figure shows surprisingly large movements in the price of cotton.

In general, prices depend on the choices and actions of suppliers, consumers and
speculators.
What causes these movements?

In general, prices depend on the choices and actions of

1. suppliers,
2. consumers, and
3. speculators.

Our focus will be on the interaction between these parties, viewed through the
lens of the standard competitive storage model
Our focus will be on the interaction between these parties.

We will connect them together in a dynamic model of supply and demand, called
the *competitive storage model*.

This model was developed by
{cite}`samuelson1971stochastic`,
Expand All @@ -65,8 +99,8 @@ This model was developed by



## Outline

## The competitive storage model

In the competitive storage model, commodities are assets that

Expand All @@ -91,16 +125,6 @@ The equilibrium price is determined competitively.
It is a function of the current state (which determines
current harvests and predicts future harvests).

We begin with the following imports


```{code-cell} ipython3
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
from scipy.optimize import minimize_scalar, brentq
from scipy.stats import beta
```


## The model
Expand All @@ -113,8 +137,6 @@ 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$.

The harvests take values in $S$, a subset of the nonnegative numbers.

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

Expand Down Expand Up @@ -176,7 +198,7 @@ Regarding quantities,

Mathematically,

* supply $ = X_t = \alpha I_{t-1} + Z_t$
* supply $ = 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 @@ -193,7 +215,7 @@ The initial condition $X_0 \in S$ is treated as given.

### An equilibrium function

Now to find an equilibrium?
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.
Expand Down