aboutsummaryrefslogtreecommitdiffstats
path: root/python/yieldcurve.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/yieldcurve.py')
-rw-r--r--python/yieldcurve.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/python/yieldcurve.py b/python/yieldcurve.py
index c8d6ed01..044a5165 100644
--- a/python/yieldcurve.py
+++ b/python/yieldcurve.py
@@ -18,7 +18,6 @@ import matplotlib.pyplot as plt
from quantlib.quotes import SimpleQuote
from db import dbconn
from pyisda.curve import YieldCurve
-import array
def getMarkitIRData(effective_date = datetime.date.today(),
currency = "USD"):
@@ -26,7 +25,7 @@ def getMarkitIRData(effective_date = datetime.date.today(),
sql_str = "SELECT * FROM {}_rates WHERE effective_date = %s".format(currency)
with conn.cursor() as c:
c.execute(sql_str, (effective_date,))
- col_names = [c[0] for c in c.description]
+ col_names = [col[0] for col in c.description]
r = c.fetchone()
MarkitData = {'effectiveasof': r[0],
'deposits': [(t, r[i]) for i, t in \
@@ -100,8 +99,8 @@ def get_dates(date, currency="USD"):
def roll_yc(yc, forward_date):
"""returns the expected forward yield cuve on a forward_date"""
dates = get_dates(forward_date)
- dfs = array.array('d', [yc.discount_factor(d, forward_date) for d in dates])
- return YieldCurve.from_discount_factors(forward_date, dates, array.array('d', dfs), 'ACT/365F')
+ dfs = np.array([yc.discount_factor(d, forward_date) for d in dates])
+ return YieldCurve.from_discount_factors(forward_date, dates, dfs, 'ACT/365F')
def YC(helpers = None, currency="USD", MarkitData=None):
if helpers is None:
@@ -112,7 +111,7 @@ def YC(helpers = None, currency="USD", MarkitData=None):
def ql_to_jp(ql_yc):
"""convert a QuantLib yield curve to a JP's one"""
if ql_yc._trait == BootstrapTrait.Discount:
- dfs = array.array('d', ql_yc.data[1:])
+ dfs = np.array(ql_yc.data[1:])
dates = [pydate_from_qldate(d) for d in ql_yc.dates[1:]]
trade_date = pydate_from_qldate(ql_yc.dates[0])
return YieldCurve.from_discount_factors(trade_date, dates, dfs, 'ACT/365F')