File tree Expand file tree Collapse file tree 5 files changed +8298
-2
lines changed Expand file tree Collapse file tree 5 files changed +8298
-2
lines changed Original file line number Diff line number Diff line change 11# TODO Turn this into a jupyter notebook
22
33from pyacm import NominalACM
4-
54import matplotlib .pyplot as plt
65import matplotlib .dates as mdates
76import pandas as pd
8- import numpy as np
7+
98
109# Read and plot data
1110yield_curve = pd .read_csv (
Original file line number Diff line number Diff line change 1+ """
2+ Generate point-in-time estimates
3+ """
4+ from tqdm import tqdm
5+ import pandas as pd
6+ from pyacm import NominalACM
7+
8+
9+ min_obs = 252
10+
11+ # Read the data
12+ yield_curve = pd .read_csv (
13+ "sample_data/di monthly maturities.csv" ,
14+ index_col = 0 ,
15+ )
16+ yield_curve = yield_curve .iloc [:, :121 ] # maturities up to 10y
17+ yield_curve = yield_curve .dropna ()
18+ yield_curve .index = pd .to_datetime (yield_curve .index )
19+ yield_curve = yield_curve [yield_curve .index >= "2007-03-01" ] # TODO deal with this missing data
20+
21+ tp = pd .DataFrame (columns = yield_curve .columns )
22+ er = pd .DataFrame (columns = yield_curve .columns )
23+
24+ for d in tqdm (yield_curve .index ):
25+
26+ aux_curve = yield_curve .loc [:d ]
27+ if aux_curve .shape [0 ] < min_obs :
28+ continue
29+
30+ acm = NominalACM (
31+ curve = aux_curve ,
32+ n_factors = 5 ,
33+ )
34+
35+ tp .loc [d ] = acm .tp .loc [d ]
36+ er .loc [d ] = acm .er_hist_d .loc [d ]
37+
38+ tp .to_csv ("sample_data/pit_tp.csv" )
39+ er .to_csv ("sample_data/pit_er.csv" )
You can’t perform that action at this time.
0 commit comments