Skip to content

Commit 8fcd997

Browse files
committed
Adding contributing guidelines and update README
1 parent a022f37 commit 8fcd997

File tree

5 files changed

+8298
-2
lines changed

5 files changed

+8298
-2
lines changed

example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# TODO Turn this into a jupyter notebook
22

33
from pyacm import NominalACM
4-
54
import matplotlib.pyplot as plt
65
import matplotlib.dates as mdates
76
import pandas as pd
8-
import numpy as np
7+
98

109
# Read and plot data
1110
yield_curve = pd.read_csv(

pit_estimates.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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")

0 commit comments

Comments
 (0)