# Calculating the risk free interest rate, or the continuously compounded yield on a T-bill, at any given time

I'm working on a program using the Black-Scholes model to price options over time. I need to be able to derive the risk free interest rate, and found this while researching:

In theory, r is a short-term safe interest rate, and it is constant through time though the theory does goes through with r¯ (average r from t to T) in place or r. In practice, you take the continuously compounded yield on a T-bill of maturity closest to that of your option. Eurocurrency rates work too, especially for currency options. In theory, you should choose whether to use a LIBOR or LIBID rate depending upon whether the option dealer who delta hedges your trade is going to be borrowing money (at the LIBOR rate) or lending money (at the LIBID rate).

Source

Is this the best way to calculate r? How could I pull this data for any given maturity? I'll be calculating option prices for any given underlying and maturity, so ideally it'd be great if I could implement a programmatic solution.

I'm new to quantitative finance, so I'm not sure what's the best way to approach this. I know there are subscriptions to pull options/stock data live or delayed - would one of those be appropriate here? I'd need a way to automatically search and pull data for T-bills for any given maturity.

Or is there a better way to derive r? I've also read about using the Kenneth French library, but I'm not sure where to start with that.

• The Black-Scholes model assumes that the risk free rate you use as input is a continuously compounded rate for the maturity of the option. You could just consider the closest TBill rate, or interpolate the Tbills curve to the maturity you want, and convert the rate to continuous compounding. – David Duarte Mar 4 at 10:54