1
$\begingroup$

I am completely new to Python, just trying to reference Quantlib Cookbook to construct eonia curve, here is my code. I didn't change much compared to the cookbook Eonia Curve BootStrapping chapter, but run into errors with syntax:

import QuantLib as ql
import math
import utils
today=ql.Date(9, ql.September, 2019)
ql.Settings.instance().evaluationDate = today

helpers = [ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate)),
           ql.Period(1, ql.Days), fixingDays, ql.TARGET(),
           ql.ModifiedFollowing, False, ql.Actual360())
           for rate, fixingDays in [(-0.00363,0)]

helpers += [ql.OISRateHelper(2, ql.Period(*tenor),
            ql.QuoteHandle(ql.SimpleQuote(rate)), ql.Eonia())
            for rate, tenor in
             [(-0.004415, (2, ql.Weeks)), (-0.00478, (1, ql.Months)),
              (-0.00496, (2, ql.Months)), (-0.005065, (3, ql.Months)),
              (-0.005235, (4, ql.Months)), (-0.00537, (5, ql.Months)),
              (-0.005465, (6, ql.Months)), (-0.005595, (7, ql.Months)),
              (-0.005871, (10, ql.Months)), (-0.0059495, (11,ql.Months)),
              (-0.005871, (1, ql.Years)), (-0.006349, (18, ql.Months))]]

Errors:

The error exist in the second helpers, below is what pycharm give me:

helpers += [\
         ^
SyntaxError: invalid syntax

Can anybody give me some hint where went wrong?

$\endgroup$
  • $\begingroup$ I think you are missing a ] in the helpers definition. $\endgroup$ – Jose Pedro Melo Sep 15 at 16:45
  • $\begingroup$ where should i put that ]? in the 2nd helpers, I think I closed "for rate, tenor" with ] at the end, and another ] at the end to close helpers $\endgroup$ – xzhan769 Sep 15 at 18:17
  • $\begingroup$ helpers = [ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate)), ql.Period(1, ql.Days), fixingDays, ql.TARGET(), ql.ModifiedFollowing, False, ql.Actual360()) for rate, fixingDays in [(-0.00363,0)]] <--- $\endgroup$ – Jose Pedro Melo Sep 15 at 18:19
  • $\begingroup$ Thank you I think that solve the problem! $\endgroup$ – xzhan769 Sep 15 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.