<jupyter_start><jupyter_text>Get Treasury data<jupyter_code>quote_date = datetime.date(year=2020, month=12, day=16)

df = data.treasury_direct_prices(quote_date)
df.head()<jupyter_output><empty_output><jupyter_text>Fit Nelson-Siegel<jupyter_code>treasuries = df[
    df["SECURITY_TYPE"].isin(
        ["MARKET BASED BILL", "MARKET BASED NOTE", "MARKET BASED BOND"]
    )
]
treasuries.head()
prices = treasuries["END_OF_DAY"]
cashflows, maturities = data.cashflows_matrix(treasuries, quote_date)
nelson_siegel = yieldcurves.NelsonSiegel.from_fit(prices, cashflows, maturities)
nelson_siegel
fig = plots.term_structure(
    nelson_siegel, prices, treasuries["MATURITY"], cashflows, maturities, quote_date
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12125340599455041, 'fraction_numerical': 0.010899182561307902, 'mean_word_length': 7.963414634146342, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '162792', 'license': 'Apache-2.0', 'n_tokens_mistral': 305, 'n_tokens_neox': 280, 'n_words': 42, 'path': 'src/notebooks/Treasury Demo.ipynb', 'repo_name': 'Bocha84/fixed-income', 'size': '734'}