% Script: Exercise2_5.m % description: this file calculates some of the % the numbers required by Exercise 2.5. disp(' The prevailing interest rate at start of investment:') r = 0.06 disp(' Our investment goal:') goal = 100000 disp(' The amount we have to invest at the current rate to meet our goal:') invest = goal/(1+r)^3 disp(' The available instruments and their prices:') bondA = [0 8 8 8 8 108] priceA = pvvar(bondA,r) couponA = bondA(2) bondB = [0 106] priceB = pvvar(bondB,r) couponB = 6 bondC = [0 7.5 7.5 107] priceC = pvvar(bondC,r) couponC = bondC(2) deltar = 0.03; disp(' Go all bond A:') pause finalcashA = zeros(2,1); numbondA = invest/pvvar(bondA,r) disp(' Suppose after one year the rate jumps 3%:') newr = r + deltar disp(' At end of 3 years the money weve made so far:') moneysofar = numbondA*couponA*((1+newr)*(1+newr) +(1+newr) + 1) disp(' Now sell the bonds at their market price') bondsaleprice = pvvar([0,bondA(5:6)],newr) finalcashA(1) = moneysofar + numbondA*bondsaleprice; disp(' Suppose after one year the rate drops 3%:') newr = r - deltar disp(' At end of 3 years we have:') moneysofar = numbondA*couponA*((1+newr)*(1+newr) +(1+newr) + 1) disp(' Now sell the bonds at their market price') bondsaleprice = pvvar([0,bondA(5:6)],newr) disp(' Here are the totals under either scenario: ') finalcashA(2) = moneysofar + numbondA*bondsaleprice disp(' Displacement from our goal of $100,000:') deltagoal = finalcashA - [100000;100000] disp(' Next, go all bond B:') pause finalcashB = zeros(2,1) disp(' Suppose after one year the rate jumps 3%:') newr = r + deltar disp(' At end of three years we have:') moneysofar=invest*(1+r)*(1+newr)^2 finalcashB(1)=moneysofar; disp(' Suppose after one year the rate drops 3%:') newr = r - deltar disp(' At end of 3 years we have:') moneysofar=invest*(1+r)*(1+newr)^2 finalcashB(2)=moneysofar; disp(' Displacement from our goal of $100,000:') deltagoal = finalcashB - [100000;100000] disp(' Go all bond C:') pause finalcashC = zeros(2,1); numbondC = invest/pvvar(bondC,r) disp(' Suppose after one year the rate jumps 3%:') newr = r + deltar disp(' At end of 3 years the money weve made so far:') moneysofar = numbondC*couponC*((1+newr)*(1+newr) +(1+newr) + 1) disp(' Now collect the face value and add it in:') finalcashC(1) = moneysofar + numbondC*100; disp(' Suppose after one year the rate drops 3%:') newr = r - deltar disp(' At end of 3 years we have:') moneysofar = numbondC*couponC*((1+newr)*(1+newr) +(1+newr) + 1) disp(' Here are the totals under either scenario: ') finalcashC(2) = moneysofar + numbondC*100 disp(' Displacement from our goal of $100,000:') deltagoal = finalcashC - [100000;100000] pause disp(' Given a weighting like the following example, we compute the resulting displacement from our goal as follows:') wts = [1/3;1/3;1/3] finalcash = [finalcashA,finalcashB,finalcashC]*wts disp(' Displacement from our goal of $100,000:') deltafinalcash = finalcash - [100000;100000]