- Joined
- 9/22/20
- Messages
- 6
- Points
- 13
I have 200 monthly spot prices of a commodity (oil) and I have to model the prices using the Schwartz mean reverting SDE:
\[ dS = \alpha(\mu-\log S)Sdt + \sigma S dW \] where W is the standard Brownian motion, mu is the drift, sigma the volatility, alpha the strength of mean reversion (these parameters are estimated from data).
This commodity is the underlying asset of the Forward contract with price at delivery F(S,T), where S is the spot price at time 0 and T is the expiry time.
Such a contract is equivalent to having an option with \( \text{payoff}(S_T)=S_T-K \), where K=F(S,T) is the strike price.
Letting \( \tau=T-t \) be the time to expiry, the formula for the price of the forward contract is
\[ F(S,\tau)=\exp\Big(e^{-\alpha\tau}\log S +(\mu-\frac{\sigma^2}{2\alpha}-\frac{\mu-r}{\alpha})(1-e^{-\alpha\tau})+\frac{\sigma^2}{4\alpha}(1-e^{-2\alpha\tau}\Big) \qquad (1)\] and the value of the equivalent option is \( V(S,t)=e^{-r(T-t)}F(S,t) \).
Knowing this information, how to run (I'm using matlab but other languages are fine too) a Monte Carlo simulation to price this particular option? Usually, these are the steps to follow
I wrote the (matlab) code (download below) which computes what I think (can you confirm?) is the exact solution for option pricing (V_exact in the attached code) and then computes the approximating solution by means of Monte Carlo simulation (V_Monte_Carlo in the code). The MC simulation uses the first spot price (real data) and the estimated parameters to 'randomly' compute the next spot prices. To compute the spot prices, instead of using the equation for dS that I wrote above it's easier to use this one which is obtained from dS by letting X=log S:
\[ X_t = X_0 e^{-\alpha t} + \mu^*(1-e^{-\alpha t}) + \underbrace{\sigma e^{-\alpha t} \int_0^t e^{\alpha s} dW_s}_Z \qquad (2) \] where \( \mu^* = \mu-\dfrac{\sigma^2}{2\alpha} \) and \( Z \sim \sigma\sqrt{\dfrac{1-e^{-2\alpha t}}{2\alpha}} \cdot N(0,1) \).
These are the steps for the Monte Carlo simulation:
p.s. if you prefer I can write the code here
\[ dS = \alpha(\mu-\log S)Sdt + \sigma S dW \] where W is the standard Brownian motion, mu is the drift, sigma the volatility, alpha the strength of mean reversion (these parameters are estimated from data).
This commodity is the underlying asset of the Forward contract with price at delivery F(S,T), where S is the spot price at time 0 and T is the expiry time.
Such a contract is equivalent to having an option with \( \text{payoff}(S_T)=S_T-K \), where K=F(S,T) is the strike price.
Letting \( \tau=T-t \) be the time to expiry, the formula for the price of the forward contract is
\[ F(S,\tau)=\exp\Big(e^{-\alpha\tau}\log S +(\mu-\frac{\sigma^2}{2\alpha}-\frac{\mu-r}{\alpha})(1-e^{-\alpha\tau})+\frac{\sigma^2}{4\alpha}(1-e^{-2\alpha\tau}\Big) \qquad (1)\] and the value of the equivalent option is \( V(S,t)=e^{-r(T-t)}F(S,t) \).
Knowing this information, how to run (I'm using matlab but other languages are fine too) a Monte Carlo simulation to price this particular option? Usually, these are the steps to follow
- generate a large number of random price paths for the underlying asset
- for each path compute the payoff of the option
- compute the average of all payoffs
- discount the average to today
I wrote the (matlab) code (download below) which computes what I think (can you confirm?) is the exact solution for option pricing (V_exact in the attached code) and then computes the approximating solution by means of Monte Carlo simulation (V_Monte_Carlo in the code). The MC simulation uses the first spot price (real data) and the estimated parameters to 'randomly' compute the next spot prices. To compute the spot prices, instead of using the equation for dS that I wrote above it's easier to use this one which is obtained from dS by letting X=log S:
\[ X_t = X_0 e^{-\alpha t} + \mu^*(1-e^{-\alpha t}) + \underbrace{\sigma e^{-\alpha t} \int_0^t e^{\alpha s} dW_s}_Z \qquad (2) \] where \( \mu^* = \mu-\dfrac{\sigma^2}{2\alpha} \) and \( Z \sim \sigma\sqrt{\dfrac{1-e^{-2\alpha t}}{2\alpha}} \cdot N(0,1) \).
These are the steps for the Monte Carlo simulation:
- The first price F of the forward contract - and so of the option V too - is set to 0 since there is no cost to enter a forward contract. Compute the first value of X by taking the logarithm of the first spot price
- compute the next value of X using the formula (2)
- compute the next value of the spot price by taking the exponential of X
- compute the next price F of the forward contract using formula (1)
- compute the next price V of the option using \( V(S,t)=e^{-r(T-t)}F(S,t) \)
- compute the average V_Monte_Carlo of the option prices
- repeat steps 2-6 until all values are computed
p.s. if you prefer I can write the code here