Code covered by the BSD License

# Monte Carlo example of the Multi-Factor coupled Commodity Forward curves Simulator

18 Jun 2013

Implementation of the Multi-Factor multi commodity forward curve simulator

LnTestofSims(mySims, LastFC, volFN, Factors)
function [ExpectedLNMean,ExpectedLNStd,AveLnPrices, StdLnPrices] = LnTestofSims(mySims, LastFC, volFN, Factors)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% If the previous forward curve is known, the expected value of the next
% step can be determined as the natural log of the forward price is
% normally distributed.
%
% $ln F(T,s) \approx N(ln % F(t,s)-\frac{1}{2}\sum_{i=1}^{n}\left(\int_t^{T}\sigma_{i}(u,t)^2du\right),\sum_{i=1}^{n}\left(\int_t^{T}\sigma_{i}(u,t)^2du\right)$
%
% See A Multi-Factor Model for Energy Derivates, Les Clewlow and Chris
% Strickland, 1999
%
% This function returns the following results for each tenor:
%
% ExpectedLNMean - expected mean value of the log simulations
% ExpecetedLNStd - expected standard deviation of the lof simualitons
% AveLnPrices - average natural log of simulated prices
% StdLnPrices - standard deviation of natural log of simulated prices
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Work out average and std of log of the simualtions
lnPrices =log(mySims);
AveLnPrices = mean(lnPrices);
StdLnPrices = std(lnPrices);

%Determine sum of square of volatility function
sumVolFNs=zeros(size(volFN,1),1);
ExpectedLNMean=zeros(1,size(volFN,1));
ExpectedLNStd=zeros(1,size(volFN,1));

for i=1:size(volFN,1)
sum = 0;
for j=1:Factors
sum = sum + volFN(i,j)*volFN(i,j);
end
sumVolFNs(i) = sum;
ExpectedLNMean(i) = log(LastFC(i))-0.5*sumVolFNs(i);
ExpectedLNStd(i) = sqrt(sumVolFNs(i));
end

end