summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/utils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pyisda/utils.py b/pyisda/utils.py
index 38196f0..3a25be5 100644
--- a/pyisda/utils.py
+++ b/pyisda/utils.py
@@ -19,7 +19,7 @@ def getMarkitIRData(date = datetime.date.today() - datetime.timedelta(days = 1),
currency="USD"):
filename = "InterestRates_{0}_{1:%Y%m%d}".format(currency, date)
r = requests.get('http://www.markit.com/news/{0}.zip'.format(filename))
- if "x-zip" in r.headers['content-type']:
+ if "zip" in r.headers['content-type']:
with zipfile.ZipFile(BytesIO(r.content)) as z:
fh = z.open(filename + '.xml')
tree = ET.parse(fh)
@@ -30,7 +30,8 @@ def getMarkitIRData(date = datetime.date.today() - datetime.timedelta(days = 1),
effectiveasof = tree.find('./effectiveasof').text
MarkitData = {'deposits': list(deposits),
'swaps': list(swaps),
- 'effectiveasof': datetime.datetime.strptime(effectiveasof, "%Y-%m-%d").date()}
+ 'effectiveasof': datetime.datetime.strptime(effectiveasof[:10],
+ "%Y-%m-%d").date()}
return MarkitData
else:
return getMarkitIRData(date-datetime.timedelta(days=1))
@@ -53,7 +54,8 @@ def rate_helpers(currency="USD", MarkitData=None):
isda_ibor = IborIndex("IsdaIbor", Period(6, Months), 2, EURCurrency(), calendar,
ModifiedFollowing, False, Actual360())
fix_freq = Annual
- deps = [DepositRateHelper(q, Period(t), 2, calendar, ModifiedFollowing, False, Actual360())
+ deps = [DepositRateHelper(q, Period(t), 2, calendar, ModifiedFollowing,
+ False, Actual360())
for t, q in MarkitData['deposits']]
# this matches with bloomberg, but according to Markit, maturity should be unadjusted
swaps = [SwapRateHelper.from_tenor(q, Period(t), calendar, fix_freq, ModifiedFollowing,
@@ -70,6 +72,7 @@ def YC(currency="USD", helpers = None, MarkitData=None):
def build_yc(trade_date, ql_curve = False):
markit_data = getMarkitIRData(trade_date-datetime.timedelta(days=1))
+
if ql_curve:
settings = Settings()
settings.evaluation_date = Date.from_datetime(trade_date)