aboutsummaryrefslogtreecommitdiffstats
path: root/python/yieldcurve.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/yieldcurve.py')
-rw-r--r--python/yieldcurve.py14
1 files changed, 9 insertions, 5 deletions
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,