diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-07-19 17:58:37 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-07-19 17:58:37 -0400 |
| commit | 8b9ff1aff7dfc5771b47e90c25d3cfa19a45c94b (patch) | |
| tree | 32598a393e69039379c3528dbc9ba1c89870f13d | |
| parent | d54b3ea0a873bed208275f0e2b4e4f986687dce9 (diff) | |
| download | pyisda-8b9ff1aff7dfc5771b47e90c25d3cfa19a45c94b.tar.gz | |
fix markit download
| -rw-r--r-- | pyisda/utils.py | 9 |
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) |
