www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/ComputeCashorNothingOptionPricesandSensitivitiesUsingtheExample.m

    %% Compute Cash-or-Nothing Option Prices and Sensitivities Using the Black-Scholes Option Pricing Model  

% Copyright 2015 The MathWorks, Inc.


%% 
% Consider a European call and put cash-or-nothing options on a futures
% contract with an exercise price of $90, and a fixed payoff of $10 that
% expires on January 1, 2009. Assume that on October 1, 2008 the contract
% trades at $110, and has a volatility of 25% per annum and the risk-free
% rate is 4.5% per annum. Using this data, calculate the price and sensitivity
% of the call and put cash-or-nothing options on the futures contract. First,
% create the |RateSpec|: 
Settle = 'Jan-1-2008';
Maturity = 'Oct-1-2008';
Rates = 0.045;
Compounding = -1;  
Basis = 1;
RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle,...
'EndDates', Maturity, 'Rates', Rates, 'Compounding', Compounding, 'Basis', Basis)  

%% 
% Define the |StockSpec|. 
AssetPrice = 110;
Sigma = .25;
DivType = 'Continuous';
DivAmount = Rates;
StockSpec = stockspec(Sigma, AssetPrice, DivType, DivAmount)  

%% 
% Define the call and put options. 
OptSpec = {'call'; 'put'};
Strike = 90;
Payoff = 10;  

%% 
% Compute the gamma, theta, and price. 
OutSpec = { 'gamma';'theta';'price'};
[Gamma, Theta, Price] = cashsensbybls(RateSpec, StockSpec,...
Settle, Maturity, OptSpec, Strike, Payoff, 'OutSpec', OutSpec)