treasury module

treasury - carry out various analyses on US Treasury Data

treasury.curves(date=None, allow_missing=False)

get treasury curves for today or a specific date

Parameters
  • date (str) – a datetime str in the format YYYY-MM-DD

  • allow_missing (bool) – boolean flag that allows NaN values when True

treasury.export(curves_data, file_extension='csv')

export curves data analysis to a desired output format

Parameters
  • curves_data (pandas.DataFrame) – dataframe containing treasury curve data

  • file_extension (str) – the file type to export. can be “csv” or “xlsx”

treasury.plot(raw_curve_data, num_years=10, start_year=None, end_year=None)

plot treasury curves over the past num_years. alternatively use start_year, end_year as a range. if start_year equals end_year, plot yearly data over the 12 months

Parameters
  • raw_curve_data (pandas.DataFrame) – treasury curve data with index Year

  • num_years (int) – number of years to plot, default is 10

  • start_year (int) – first year to begin plotting data

  • end_year (int) – last year to consider when plotting

treasury.yearly_curves(year, allow_missing=False)

get the yearly curve over months for different treasury durations

Parameters
  • year (int) – the year to analyze

  • allow_missing (bool) – boolean flag that allows NaN values when True