aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/index.py3
-rw-r--r--python/yieldcurve.py14
2 files changed, 12 insertions, 5 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py
index 3d929cd0..8137f63f 100644
--- a/python/analytics/index.py
+++ b/python/analytics/index.py
@@ -236,6 +236,9 @@ class Index(object):
# self._yc = ql_to_jp(self._ql_yc)
ql_yc = YC(currency = self.currency)
self._yc = ql_to_jp(ql_yc)
+ # use the rolled forward curve if we price something in the future
+ if self._yc.base_date < d:
+ self._yc = self._yc.expected_forward_curve(d)
self._trade_date = d
self._step_in_date = self.trade_date + datetime.timedelta(days=1)
self._accrued = self._fee_leg.accrued(self._step_in_date)
diff --git a/python/yieldcurve.py b/python/yieldcurve.py
index fa7f153b..c49b6dd1 100644
--- a/python/yieldcurve.py
+++ b/python/yieldcurve.py
@@ -16,11 +16,13 @@ import numpy as np
from quantlib.quotes import SimpleQuote
from db import dbconn
from pyisda.curve import YieldCurve, BadDay
+import warnings
def getMarkitIRData(effective_date = datetime.date.today(),
currency = "USD"):
conn = dbconn("serenitasdb")
- sql_str = "SELECT * FROM {}_rates WHERE effective_date = %s".format(currency)
+ sql_str = "SELECT * FROM {}_rates WHERE effective_date <= %s " \
+ "ORDER BY effective_date DESC LIMIT 1".format(currency)
with conn.cursor() as c:
c.execute(sql_str, (effective_date,))
col_names = [col[0] for col in c.description]
@@ -57,10 +59,12 @@ def rate_helpers(currency="USD", MarkitData=None):
if not MarkitData:
MarkitData = getMarkitIRData(pydate_from_qldate(settings.evaluation_date), currency)
if MarkitData['effectiveasof'] != pydate_from_qldate(settings.evaluation_date):
- raise RuntimeError("Yield curve effective date: {0} doesn't " \
- "match the evaluation date: {1}".format(
- MarkitData['effectiveasof'],
- pydate_from_qldate(settings.evaluation_date)))
+ warnings.warn("Yield curve effective date: {0} doesn't " \
+ "match the evaluation date: {1}".format(
+ MarkitData['effectiveasof'],
+ pydate_from_qldate(settings.evaluation_date)),
+ RuntimeWarning)
+ settings.evaluation_date = Date.from_datetime(MarkitData['effectiveasof'])
calendar = WeekendsOnly()
if currency == "USD":
isda_ibor = IborIndex("IsdaIbor", Period(3, Months), 2, USDCurrency(), calendar,