www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/ComputethePricePortfolioInstrumentsExample.m
%% Compute the Price of a Portfolio of Instruments %% % The data for the interest-rate term structure is as follows: Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2011'; StartDates = ValuationDate; EndDates = {'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'; 'Jan-1-2015'}; Compounding = 1; %% % Create a |RateSpec|. RS = intenvset('ValuationDate', ValuationDate, 'StartDates',... StartDates, 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding) %% % Create an instrument portfolio with two range notes and a floating rate % note with the following data: Spread = 200; Settle = 'Jan-1-2011'; Maturity = 'Jan-1-2014'; % First Range Note RateSched(1).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'}; RateSched(1).Rates = [0.045 0.055; 0.0525 0.0675; 0.06 0.08]; % Second Range Note RateSched(2).Dates = {'Jan-1-2012'; 'Jan-1-2013' ; 'Jan-1-2014'}; RateSched(2).Rates = [0.048 0.059; 0.055 0.068 ; 0.07 0.09]; %% % Create |InstSet|, add a floting-rate note, and display the portfolio instruments. InstSet = instadd('RangeFloat', Spread, Settle, Maturity, RateSched); % Add a floating-rate note InstSet = instadd(InstSet, 'Float', Spread, Settle, Maturity); % Display the portfolio instrument instdisp(InstSet) %% % The data to build the tree is as follows: VolDates = ['1-Jan-2012'; '1-Jan-2013'; '1-Jan-2014';'1-Jan-2015']; VolCurve = 0.01; AlphaDates = '01-01-2015'; AlphaCurve = 0.1; HWVS = hwvolspec(RS.ValuationDate, VolDates, VolCurve,... AlphaDates, AlphaCurve); HWTS = hwtimespec(RS.ValuationDate, VolDates, Compounding); HWT = hwtree(HWVS, RS, HWTS) %% % Price the portfolio. Price = hwprice(HWT, InstSet)