• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

How to perform Monte Carlo simulations to price a Forward contract under the Schwartz mean reverting model?

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
  • 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
however, I'm having some problems with this framework. This is what I tried so far

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:
  1. 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
  2. compute the next value of X using the formula (2)
  3. compute the next value of the spot price by taking the exponential of X
  4. compute the next price F of the forward contract using formula (1)
  5. compute the next price V of the option using \( V(S,t)=e^{-r(T-t)}F(S,t) \)
  6. compute the average V_Monte_Carlo of the option prices
  7. repeat steps 2-6 until all values are computed
However, as you can see from the image below, the curve of the option prices obtained with the MC simulation is smooth, while what I was expecting was a curve similar to the one of the exact solution. So I made some mistakes somewhere

p.s. if you prefer I can write the code here



  • testMC.zip
    1.4 KB · Views: 5