Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Converting an IRDataCurve or IRFunctionCurve Object

Introduction

The IRDataCurve and IRFunctionCurve objects for interest-rate curves support conversion to:

  • A RateSpec structure. The RateSpec generated from an IRDataCurve or IRFunctionCurve object, using the toRateSpec method, is identical to the RateSpec structure created with intenvset using Financial Instruments Toolbox™ software.

  • A vector of dates and data from an IRDataCurve object acceptable to prbyzero, bkcall, bkput, tfutbyprice, and tfutbyyield or any function that requires a term structure of interest rates.

Using the toRateSpec Method

To convert an IRDataCurve or IRFunctionCurve object to a RateSpec structure, you must first create an interest-rate curve object. Then, use the toRateSpec method for an IRDataCurve object or thetoRateSpec method for an IRFunctionCurve object.

Example

Create a data vector from the following data: http://www.ustreas.gov/offices/domestic-finance/debt-management/
interest-rate/yield.shtml
:

Data = [1.85 1.84 1.91 2.09 2.47 2.71 3.12 3.43 3.85 4.57 4.58]/100;
Dates = daysadd(today,[30 90 180 360 2*360 3*360 5*360 7*360 10*360 20*360 30*360],2);
scatter(Dates,Data)
datetick

Create an IRDataCurve interest-rate curve object:

rr = IRDataCurve('Zero',today,Dates,Data);

Convert to a RateSpec:

toRateSpec(rr, today+30:30:today+365)
ans = 
           FinObj: 'RateSpec'
      Compounding: 2
             Disc: [12x1 double]
            Rates: [12x1 double]
         EndTimes: [12x1 double]
       StartTimes: [12x1 double]
         EndDates: [12x1 double]
       StartDates: 733569
    ValuationDate: 733569
            Basis: 0
     EndMonthRule: 1

Using Vector of Dates and Data Methods

You can use the getZeroRates method for an IRDataCurve object with a Dates property to create a vector of dates and data acceptable for prbyzero in Financial Toolbox™ software and bkcall, bkput, tfutbyprice, and tfutbyyield in Financial Instruments Toolbox software.

Example

This is an example of using the IRDataCurve method getZeroRates with prbyzero:

Data = [2.09 2.47 2.71 3.12 3.43 3.85 4.57 4.58]/100;
Dates = daysadd(today,[360 2*360 3*360 5*360 7*360 10*360 20*360 30*360],1);
irdc = IRDataCurve('Zero',today,Dates,Data,'InterpMethod','pchip');
Maturity = daysadd(today,8*360,1);
CouponRate = .055;
ZeroDates = daysadd(today,180:180:8*360,1);
ZeroRates = getZeroRates(irdc, ZeroDates);
BondPrice = prbyzero([Maturity CouponRate], today, ZeroRates, ZeroDates)
BondPrice =
  113.9250

See Also

| | |

Related Examples

More About

Was this topic helpful?