get_rates()#

Retrieving Interest Rates#

MoabDB

moabdb.get_rates(sample: str = '1y', start: str | None = None, end: str | None = None) DataFrame[source]#

Returns a pandas.DataFrame of historical interest rates.

Modifying the sample, start, and end parameters allows for the customization of the date range for the returned data. If the sample parameter is specified, the most recent data for that sample length is returned. If the start and end parameters are specified, the data for that specific date range is returned.

Parameters:
samplestr, optional

Sample period length. It can be used alone or with start | end.

startstr, optional

Sample start date. Requires one of end or sample.

endstr, optional

Sample end date. Requires one of start or sample.

Returns:
outpandas.DataFrame

DataFrame containing treasury data, indexed by datetime64. Each column represents a different term for the treasury yield.

Data includes the following variables:

DataFrame Column

Variable Description

Treasury_1m

Treasury yield for a 1-month maturity.

Treasury_2m

Treasury yield for a 2-month maturity.

Treasury_3m

Treasury yield for a 3-month maturity.

Treasury_4m

Treasury yield for a 4-month maturity.

Treasury_6m

Treasury yield for a 6-month maturity.

Treasury_1y

Treasury yield for a 1-year maturity.

Treasury_2y

Treasury yield for a 2-year maturity.

Treasury_3y | Treasury yield for a 3-year maturity.

Treasury_5y | Treasury yield for a 5-year maturity.

Treasury_7y

Treasury yield for a 7-year maturity.

Treasury_10y

Treasury yield for a 10-year maturity.

Treasury_20y

Treasury yield for a 20-year maturity.

Treasury_30y

Treasury yield for a 30-year maturity.

Realrate_5y

Real interest rate for a 5-year maturity.

Realrate_7y

Real interest rate for a 7-year maturity.

Realrate_10y

Real interest rate for a 10-year maturity.

Realrate_20y

Real interest rate for a 20-year maturity.

Realrate_30y

Real interest rate for a 30-year maturity.

Raises:
errors.MoabResponseError:

If there’s a problem interpreting the response

errors.MoabRequestError:

If the server has a problem interpreting the request, or if an invalid parameter is passed

errors.MoabInternalError:

If the server runs into an unrecoverable error internally

errors.MoabHttpError:

If there’s a problem transporting the payload or receiving a response

errors.MoabUnauthorizedError:

If the user is not authorized to request the datatype

errors.MoabNotFoundError:

If the data requested wasn’t found

errors.MoabUnknownError:

If the error code couldn’t be parsed

Login Example#

Import the library

>>> import moabdb as mdb

Login for intraday data requests

>>> mdb.get_rates()