Stock Price

Let $S_t$ represent the stock price at time $t.$ How to write a simple model for this quantity?

  • Return: $$ \frac{S_{t+\delta t}-S_t}{S_t} $$ where $S_{t+\delta t}-S_t=\delta S$

In the limit $\delta t\rightarrow 0$, we have $$ \lim_{\delta t\rightarrow 0}\frac{S_{t+\delta t}-S_t}{S_t} = \frac{dS}{S} $$

Modelling Return

Return: $$ \frac{dS}{S}=\mu dt+\sigma dW $$

  • $\mu dt$ is a measure of the deterministic expected rate of growth of the share price. In general, $\mu =\mu (S,t).$ In simple models $\mu $ is taken to be constant ($\mu =0.1 ~ \text{yr}^{-1} =10 ~ \%\text{yr}^{-1} $).
  • $\sigma dW$ describes the stochastic change in the share price, where $dW$ stands for $\delta W=W_{t+\delta t}-W_t$ as $\delta t\rightarrow 0$
  • $W_t$ is a Wiener process
  • $\sigma $ is the volatility ($\sigma =0.2 ~ \text{yr}^{-\frac12} = 20~\%\text{yr}^{-\frac12}$)

Using this notebook

The notebook contains "cells", and in each cell there is either information (like this) or code (they have "In [ ]" to the left). You can run the code in the notebook, as well as editing and rerunning it. The notebook will work best if you first run each cell in the order they appear. You can then click on a cell and run it again if you have changed anything.

Real Data

We can observe $S_t$ as recorded on the stock exchange. We can plot a time series of a real stock (the actual stock is unimportant) that I've already downloaded. We now write some code to import the plot into a variable M.

In [ ]:
from MathFinanceWorkshop import MFW_plot
M = MFW_plot()

Run the first two cells containging code. You can see the cells with code as they have "In [ ] " to the left. You should see a figure appear below the second command. This plots the timeseries of $S_t$ against. The graph is split into 20 time periods and each are a different colour, the reason will become apparent in the next cell.

In [ ]:
M.plotRealData()

Now run the third and final cell containing code. You should see a button "Run Interact" appear below, press it. A figure containing fours graphs will show.

The top left contains the same real data as above but now we have 20 lines on the graph all starting at $S_0=1$, as the data has been scaled against the initial value.

The top right contains the 20 simulations starting at $S_0=1$, using the stock model outlined above and the parameters selected for $\mu$ and $\sigma$.

The bottom left contains a histogram of the historical stock returns, $$ \frac{S_{t+\delta t}-S_t}{S_t} $$ and the bottom right is a histogram of returns for the simulated stock prices. If it is a good model and properly calibrated you should expect the graphs on the left to look like the graphs on the right.

Task

Try moving the sliders to different values of $\mu$ and $\sigma$, can you get the data on the right (our mathematical model) to look like the data on the left?

In [ ]:
M.f_plot_interactive()