Monte Carlo在金融上的应用,一直想找个例子,百度给出的结果却都是老生常谈的算pi的例子,甚至李洋那本matlab量化也是如此。顺便批评一下这本书立意太低,matlab用法占了1/4,期权定价再重复一下赫尔书中的知识,最终竟然以均线交叉策略作例子结束。所以下面给出搜集的几个Monte Carlo在金融中的应用例子,以飨诸位。
文中的思路来源于Columbia 大学 Martin Haugh 的蒙塔卡罗模拟讲义,如有理解不到位的地方,请指正。
function[theta] = portfolio_evaluation(mua,mub,siga,sigb,n,T,rho,S0a,S0b,na,nb);
% This function estimates the probability that the portfolio value, W_T, falls
% by more than 10%. n is the number of simulated values of W_T that we use.
W0 = na*S0a + nb*S0b;
Sigma = [siga^2 siga*sigb*rho;
siga*sigb*rho sigb^2];
B = randn(2,n);
C = chol(Sigma);
V = C’ * B;
STa = S0a * exp((mua - (siga^2)/2)*T + sqrt(T)*V(1,:));
STb = S0b * exp((mub - (sigb^2)/2)*T + sqrt(T)*V(2,:));
WT = na*STa + nb*STb;
theta = mean(WT/W0) - 1;