www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/ComputeCashorNothingOptionPricesUsingtheBlackScholesOptiExample.m
%% Compute Cash-or-Nothing Option Prices 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 and exercise strike price of $90, a fixed payoff of $10 % that expires on October 1, 2008. Assume that on January 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 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; %% % Calculate the prices. Pcon = cashbybls(RateSpec, StockSpec, Settle,... Maturity, OptSpec, Strike, Payoff)