⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plotcrrtree.m

📁 These source code contains all the programs on pricing
💻 M
字号:
function PlotCRRTree(S0,K,r,T,sigma,N,flag)

% PlotCRRTree the values in the CRR tree give by P.
%   This function plots a tree that contains all the points in the Cox-Ross
%   Rubenstein tree given by by the input P. The nodes in the tree are
%   coloured according to the value of the derivative at that point in the
%   tree.
%
% Inputs:
%
%   S0      Initial asset price
%   K       Strike Price
%   r       Interest rate
%   T       Time to maturity of option
%   sigma   Volatility of underlying asset
%   N       Number of timesteps to take
%
%   flag - true (default) or false, governs whether we add text markers to
%   the tree to indicate the value of the options at each node of the tree

if nargin < 7, flag = true; end % Set up default value for flag

LB = []; UB = []; Values = [];
Controls = [];
ResultsText = [];

nCreate;
Price = [];
P = [];
S = [];
Time = [];
dt = [];
u = [];
d = [];
p = [];
a = [];
N = 8;

count = 1;

L = []; T = []; A = [];

nPlotTree;

% -------------------------------------------------------------------------
    function nPlotTree
        
        S0 = Values(1); K = Values(2); r = Values(3); T = Values(4); sigma = Values(5);
        [Price,P,S,Time,dt,u,d,p,a] = iCalcTree(S0,K,r,T,sigma,N);
        count = 1;
        L = zeros(N*(N+1)/2,1); 
        T = L; 
        A = zeros(N*(N-1)/2,1);% Place holders for the handles we create.

        for ii = 1:N
            for jj = 1:numel(P{ii})
                % create the node
                L(count) = line(ii/(N+1),(ii-2*(jj-1)-1)/(N+1),'color','k','marker','o');
                if flag % Create a text label if requested
                    status = 'on';
                else
                    status = 'off';
                end
                T(count) = text((ii+.1)/(N+1),(ii-2*(jj-1)-1.1)/(N+1),...
                    ['

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -