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 , where K=F(S,T) is the strike price.
Letting be the time to expiry, the formula for the price of the forward contract is
and the value of the equivalent option is
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:
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
- 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