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.DataFrameof historical interest rates.Modifying the
sample,start, andendparameters allows for the customization of the date range for the returned data. If thesampleparameter is specified, the most recent data for that sample length is returned. If thestartandendparameters 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
endorsample.- endstr, optional
Sample end date. Requires one of
startorsample.
- 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_1mTreasury yield for a 1-month maturity.
Treasury_2mTreasury yield for a 2-month maturity.
Treasury_3mTreasury yield for a 3-month maturity.
Treasury_4mTreasury yield for a 4-month maturity.
Treasury_6mTreasury yield for a 6-month maturity.
Treasury_1yTreasury yield for a 1-year maturity.
Treasury_2yTreasury 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_7yTreasury yield for a 7-year maturity.
Treasury_10yTreasury yield for a 10-year maturity.
Treasury_20yTreasury yield for a 20-year maturity.
Treasury_30yTreasury yield for a 30-year maturity.
Realrate_5yReal interest rate for a 5-year maturity.
Realrate_7yReal interest rate for a 7-year maturity.
Realrate_10yReal interest rate for a 10-year maturity.
Realrate_20yReal interest rate for a 20-year maturity.
Realrate_30yReal 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()