全部版块 我的主页
论坛 金融投资论坛 六区 金融学(理论版) 金融工程(数量金融)与金融衍生品
3875 3
2017-03-28
已经建好LSM算普通美式期权的模型,试算了没有问题,但修改成亚美式就始终算不出正确答案,有的时候美式的价格比欧式的还低……百思不得其解……求助大神指点!
matlab代码如下:
脚本:
clc; clear;


%% Stock price features.

%%
Spot = 4000;               % Spot price.
r = 0.0488;                 % Risk free rate.
q = 0;

% Option features.
K =4000;                  % Strike price.
v = 0.3;                % Volatility.
T =1/3;                % Maturity in years.

% Simulation features.
NT = 20;                % Number of time increments.
dt = T/NT;               % Time increment.
NS = 1e4;                % Number of simulated paths.

% Trinomial tree features.
%n = 250;                 % Time steps for trinomial tree.
EuroAmer = 'A';          % Flavor indicator for trinomial tree.
PutCall = 'P';           % Select a put in the trinomial tree.

%% Simulate the stock price process under Black Scholes
FirstCol1 = log(Spot).*ones(NS,1);
z=randn(NS,NT-1);
E1 = (r-q-0.5*v^2)*dt + sqrt(dt)*v.*z;
All1 = [FirstCol1 E1];
S1 = cumsum(All1,2);
S=exp(S1);
clear FirstCol1 E1 All1


%% Longstaff-Schwartz price
% Design matrix for the LSM algorithm
XmatrixHandle = {@(y)ones(length(y),1), @(y)(y),@(y)(y.^2)};
% Run the LSM algorithm
[EuroPriceLSM AmerPriceLSM] = BlackScholesLSM_asian_new(S,K,r,q,T,NS,NT,dt,PutCall,XmatrixHandle);
% Early exercise premium
PremiumLSM = AmerPriceLSM - EuroPriceLSM;


函数:

function [EuroPrice AmerPrice] = BlackScholesLSM_asian_new(S,K,r,q,T,NS,NT,dt,PutCall,XmatrixHandle)

% Longstaff-Schwartz method for American options
% Fabrice Douglas Rouah, FRouah.com and Volopta.com

% INPUTS
%  S = Matrix of simulated stock price, size NSxNT (rows are paths)
%  K = Strike
%  r = Risk free rate
%  q = Dividend yield
%  T = Maturity
%  NS = Number of stock price paths
%  NT = Number of time steps per path
%  dt = Time increment (T/NT)
%  PutCall = 'P' or 'C'

% Number of columns in the X matrix
NX = length(XmatrixHandle);

% Initialize the Cash Flows
CF = zeros(NS,NT);

%Create average price
S_avg=zeros(NS,NT);
S_sum=zeros(NS,NT);
parfor i=1:NT
    S_sum(:,i)=sym(sum(S(:,1:i),2));
    S_avg(:,i)=sym(S_sum(:,i)./i);
end

% Set the last cash flows to the intrinsic value
if strcmp(PutCall,'P')
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-3-28 14:34:55
额怎么发出来不完整……
函数:
function [EuroPrice AmerPrice] = BlackScholesLSM_asian_new(S,K,r,q,T,NS,NT,dt,PutCall,XmatrixHandle)

% Longstaff-Schwartz method for American options
% Fabrice Douglas Rouah, FRouah.com and Volopta.com

% INPUTS
%  S = Matrix of simulated stock price, size NSxNT (rows are paths)
%  K = Strike
%  r = Risk free rate
%  q = Dividend yield
%  T = Maturity
%  NS = Number of stock price paths
%  NT = Number of time steps per path
%  dt = Time increment (T/NT)
%  PutCall = 'P' or 'C'

% Number of columns in the X matrix
NX = length(XmatrixHandle);

% Initialize the Cash Flows
CF = zeros(NS,NT);

%Create average price
S_avg=zeros(NS,NT);
S_sum=zeros(NS,NT);
parfor i=1:NT
    S_sum(:,i)=sym(sum(S(:,1:i),2));
    S_avg(:,i)=sym(S_sum(:,i)./i);
end

% Set the last cash flows to the intrinsic value
if strcmp(PutCall,'P')
        CF(:,NT) = max(K - S_avg(:,NT), 0);
elseif strcmp(PutCall,'C')
        CF(:,NT) = max(S_avg(:,NT) - K, 0);
end

% European option value
EuroPrice = exp(-r*T)*mean(CF(:,NT));

% Work backwards through the stock prices until time j=2.
% We could work through to time j=1 but the regression will not be
% of full rank at time 1, so this is cleaner.
for j=NT-1:-1:2
        if strcmp(PutCall,'P')
                I = find(S_avg(:,j) < K);           % Indices for Puts
        else
                I = find(S_avg(:,j) > K);           % Indices for Calls
        end
        X = S(I,j);                         % X-vector = time j stock prices.
    EX=S_avg(I,j);   
        Y = CF(I,j+1)*exp(-r*dt);           % Y-vector = time j+1 discounted CF.
    Z = zeros(length(X),NX);            % Design matrix for regression to predict cash flows
    for k=1:NX
        Z(:, k) = feval(XmatrixHandle{k}, X);
    end
        beta = Z\Y;                               % Regression parameters.
        P = Z*beta;                         % Regression predicted CF.
        if strcmp(PutCall,'P')
                J = max(K - EX, 0) > P;          % Early exercise for puts.
        else
                J = max(EX - K, 0) > P;          % Early exercise for calls.
    end
        E = I(J);                           % Stock price indices where immediate exercise is optimal.
        C = setdiff((1:NS),E)';             % Stock price indices where continuation is optimal.
        if strcmp(PutCall,'P')
                CF(E,j) = max(K - EX(J), 0);     % Replace with early exercise for puts
        else
                CF(E,j) = max(EX(J) - K, 0);
        end
        CF(C,j) = exp(-r*dt)*CF(C,j+1);     % Continued CF are discounted back one period.
end

% American option value
AmerPrice = exp(-r*dt)*mean(CF(:,2));
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-5-7 12:41:05
我觉得,你这个问题是用于regress用的basis function不够有效(或不够多),我看了一下,BlackScholesLSM_asian_new 中 basis function似乎只考虑了每个可行权时点的即时的股价,未考虑累计到该可行权时点的股价平均值。不用股价平均值作为basis function就可能使行权决策离“最优行权决策"很远,导致美式期权(因为行权时机不合适)的计算出现小于欧式期权的情况。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-9-4 17:54:17
您好,请问这个代码是美式的还是亚美式的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群