diff options
Diffstat (limited to 'python/analytics')
| -rw-r--r-- | python/analytics/index.py | 12 | ||||
| -rw-r--r-- | python/analytics/option.py | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py index 03a4c482..262e41bd 100644 --- a/python/analytics/index.py +++ b/python/analytics/index.py @@ -292,18 +292,18 @@ class Index(object): @classmethod def from_name(cls, index=None, series=None, tenor=None, trade_date=datetime.date.today(), - notional=10_000_000, redcode=None): + notional=10_000_000, redcode=None, maturity=None): if all([index, series, tenor]): sql_str = "SELECT indexfactor, lastdate, maturity, coupon " \ "FROM index_desc WHERE index=%s AND series=%s AND tenor = %s " \ "ORDER BY lastdate ASC" params = (index.upper(), series, tenor) - elif redcode: + elif all([redcode, maturity]): sql_str = "SELECT index, series, indexfactor, lastdate, maturity, coupon " \ - "FROM index_desc WHERE redindexcode=%s" - params = (redcode,) + "FROM index_desc WHERE redindexcode=%s AND maturity=%s" + params = (redcode, maturity) else: - raise ValueError("Need to provide either index, series, and tenor or redcode") + raise ValueError("Not enough information to load the index.") try: df = pd.read_sql_query(sql_str, engine, parse_dates=['lastdate'], @@ -419,7 +419,7 @@ class ForwardIndex(object): def from_name(cls, index_type, series, tenor, forward_date, trade_date=datetime.date.today(), notional=10e6): index = Index.from_name(index_type, series, tenor, trade_date, notional) - return cls(index, forward_date, indextype == "HY") + return cls(index, forward_date) @property def forward_annuity(self): diff --git a/python/analytics/option.py b/python/analytics/option.py index 75d54a92..c12fc816 100644 --- a/python/analytics/option.py +++ b/python/analytics/option.py @@ -92,7 +92,7 @@ class BlackSwaption(ForwardIndex): rec = r.fetchone() if rec is None: return ValueError("trade_id doesn't exist") - index = Index.from_name(redcode=rec.security_id, trade_date=rec.trade_date) + index = Index.from_name(redcode=rec.security_id, maturity=rec.maturity, trade_date=rec.trade_date) index.spread = 62 instance = cls(index, rec.expiration_date, rec.strike, rec.swaption_type.lower()) instance.notional = rec.notional |
