# DailyTreasuryYieldCurve

DailyTreasuryYieldCurve.jl is a Julia package for downloading and working with historical daily yield curve data from the US Treasury.

## Getting Daily Yield Curves

`DailyTreasuryYieldCurve.getyieldcurves`

— Function`getyieldcurves(;real::Bool=false,begdt::Date=Date(1990,1,2),enddt::Date=today())`

Download the whole published history of daily US Treasury yield curves from the official data feed.

Optionally, pass a filename if you have already downloaded the data, eg. `getyieldcurves(fn::AbstractString)`

.

By default, gets the nominal yield curve. Pass `realrates=true`

to get the real yield curve. The nominal series starts in 1990, while the real series starts in 2003.

Returns a `DataFrame`

.

Structure of returned data for *nominal* curve:

Column Name | Description |
---|---|

date | Date of yield curve |

m1 | 1 month constant maturity rate |

m2 | 2 month constant maturity rate |

m3 | 3 month constant maturity rate |

m6 | 6 month constant maturity rate |

y1 | 1 year constant maturity rate |

y2 | 2 year constant maturity rate |

y3 | 3 year constant maturity rate |

y5 | 5 year constant maturity rate |

y7 | 7 year constant maturity rate |

y10 | 10 year constant maturity rate |

y20 | 20 year constant maturity rate |

y30 | 30 year constant maturity rate |

Structure of returned data for *real* curve:

Column Name | Description |
---|---|

date | Date of yield curve |

y5 | 5 year constant maturity real rate |

y7 | 7 year constant maturity real rate |

y10 | 10 year constant maturity real rate |

y20 | 20 year constant maturity real rate |

y30 | 30 year constant maturity real rate |

Not all maturities were reported on every day.

## Interpolation

The package contains some convenience utilities for interpolating/extrapolating with the yield curve data.

`DailyTreasuryYieldCurve.RateInterpolator`

— Type`RateInterpolator`

A container for the series of daily yield curve interpolators.

Fields: `dates`

and `interpolators`

, both `Vector`

.

To interpolate, just call it with the value to interpolate (days to maturity) and the date of the curve.

`(ri::RateInterpolator)(d::Real,dt::Date)`

Currently supports only linear interpolation and extrapolation. See `createRateInterpolator`

for construction.

`DailyTreasuryYieldCurve.createRateInterpolator`

— Function`createRateInterpolator(df;realrates::Bool=false)`

Preferred method to construct a `RateInterpolator`

, just pass the `df`

that you get from `getyieldcurves`

.

If you request a date that does not exist in `RateInterpolator.dates`

, it will (blindly) carry forward the curve from the previous available date. It is your responsibility to double-check your inputs.

## Day Count Convention

The standard day count convention for valuing US Treasuries is Actual/Actual (ICMA) (as opposed to something like 30/360). However, it is unclear (to me) exactly how to match this to constant maturities. Therefore, I use the convention that months are 30 days (for maturities less than 1 year) and years are 365 days (for maturities 1 year or more).