Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need to calculate daily risk free rate from Fed data

2,881 views
Skip to first unread message

Andreas

unread,
Jan 12, 2009, 8:02:39 PM1/12/09
to
The St. Louis Federal Reserve makes a great set of data available for financial analysis at their FRED (Federal Reserve Economic Data) site at http://research.stlouisfed.org/fred2/.

I've downloaded treasury bill rates from 1984 to the present (they have lots of rates available at: http://research.stlouisfed.org/fred2/categories/116).

The data set gives me the yearly interest rate on 3-Month T-Bills for each day i.e:

1984-12-31, 0.008120
1985-01-01, 0.008120
1985-01-02, 0.008100
1985-01-03, 0.008070
1985-01-04, 0.008080
1985-01-07, 0.008060
1985-01-08, 0.008060
1985-01-09, 0.007950
..
2008-12-30, 0.000100
2008-12-31, 0.000110
2009-01-01, 0.000110
2009-01-02, 0.000080
2009-01-05, 0.000140
2009-01-06, 0.000140

I need to calculate the daily risk free rate for each interval in the data set based on the yearly rate give for each day.

I've gotten as far as this:

1 + yearlyRate == (1 + dailyRate)^360

Does this make sense?
If so, how do I implement this in Mathematica?
If not, how would I do it?

A couple of related questions:

Can one use FinancialData[] to access Treasury or Libor rate information or access a risk free rate directly?

Thx.

Bob Hanlon

unread,
Jan 12, 2009, 8:16:30 PM1/12/09
to

dailyRate[yearlyRate_?NumericQ, year_: Date[][[1]]] :=
Module[{dr, days},
days = DateDifference[{year, 1, 1}, {year + 1, 1, 1}];
dr /. FindRoot[1 + yearlyRate == (1 + dr)^days, {dr, yearlyRate/366}][[1]]]

year defaults to current year

dailyRate[0.008120]

0.000022157

For the same yearly rate, the daily rate during a leap year would be slightly lower since there is an additional day to arrive at the same yearly rate

dailyRate[0.008120, 2008]

0.0000220964


Bob Hanlon

---- Andreas <aa...@ix.netcom.com> wrote:

=============

Stern

unread,
Jan 12, 2009, 8:17:13 PM1/12/09
to
It is not entirely clear to me whether you are asking a finance question, a
math question, or a Mathematica question. I will try to address all three.
Your use of the 360 day convention is correct for Treasury bills, so you can
convert a single yearly rate by solving the equation you posted in your
original question. No need to use Mathematica for that; it's rudimentary.

dailyrate = (1+yearlyrate)^(1/360) - 1

in Mathematica terms, you might express this as a function, which would look
like this:

yearlyToDailyrate[yearlyrate_] := (1 + yearlyrate)^(1/360) - 1

If your risk free data is in the format
{{date1,yearlyRate1},{date2,yearlyRate2}....{dateN,yearlyRateN}}, as would
be natural, you can convert the entire list by using the Map command
together with the conversion above. Assuming your starting datalist has the
name yearlyRiskFreeSeries,

dailyRiskFreeSeries =Map[{#[[1]], yearlyToDailyrate
[#[[2]]]}&, yearlyRiskFreeSeries]


If you choose some risk free series other than the three month T-bill, check
the date convention. Many do not use the 360 day convention, and you should
adjust your math as needed.

Sorry, I have no advice on FinancialData[]; I pull my risk free rates from
Bloomberg, and generally use LIBOR rather than bills, though it changes
depending on the instrument I'm working with. [For anybody else out there
using Bloomberg, I have an application that can be called directly from
Mathematica to import any Bloomberg data series. It saves a lot of time.]

Michael Stern

Chris Pemberton

unread,
Jan 12, 2009, 8:17:23 PM1/12/09
to
This may point you in the right direction:

INPUT:
data =
Flatten[Take[Import["http://research.stlouisfed.org/fred2/data/DTB3.txt",
"Table"], -1]]
date = DateList[{First[data], {"Year", "-", "Month", "-", "Day"}}]
rate = Last[data]

OUTPUT:
{2009-01-07, 0.11} <- from the downloaded text file
{2009, 1, 7, 0, 0, 0} <- the date portion converted to Mathematica's
internal time format
0.11 <- the rate

Not sure if that is the rate you're looking for, but you should be able
to get whatever you need somewhere.
It would be faster if you download the text file and save it locally if
you're going to need multiple table values.

Chris

0 new messages