0
$\begingroup$

I'm wondering how to precisely handle the quote convention of ON, TN, and S/N of FX quote. How to handle these convention in quantlib.

Here is my code, is that correct?

settlementDays = 2 #OIS convention
discount_term_structure = ql.RelinkableYieldTermStructureHandle()

oindex_on = ql.OvernightIndex('',0,ql.USDCurrency(),calendar,ois_dayCount,discount_term_structure)
oindex_tn = ql.OvernightIndex('',1,ql.USDCurrency(),calendar,ois_dayCount,discount_term_structure)
oindex_sn = ql.OvernightIndex('',2,ql.USDCurrency(),calendar,ois_dayCount,discount_term_structure)
oindex = ql.OvernightIndex('',settlementDays,ql.USDCurrency(),calendar,ois_dayCount,discount_term_structure)

oisHelpers = []
oisHelpers.append(ql.OISRateHelper(0,ql.Period(ois_data.loc[0,'Tenor']), ql.QuoteHandle(ois_data.loc[0,'Rate_handler']),oindex_on))
oisHelpers.append(ql.OISRateHelper(1,ql.Period(ois_data.loc[1,'Tenor']), ql.QuoteHandle(ois_data.loc[1,'Rate_handler']),oindex_tn))
oisHelpers.append(ql.OISRateHelper(2,ql.Period(ois_data.loc[2,'Tenor']), ql.QuoteHandle(ois_data.loc[2,'Rate_handler']),oindex_sn))

oisHelpers = oisHelpers + [ql.OISRateHelper(settlementDays,ql.Period(ois_data.loc[i,'Tenor']), ql.QuoteHandle(ois_data.loc[i,'Rate_handler'])\
                                            ,oindex) for i in range(3,len(ois_data))]```

Tenor   Rate    Rate_handler
0   1D  0.0160  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
1   1D  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
2   1D  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
3   1W  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
4   2W  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
5   3W  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
6   1M  0.0159  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
7   2M  0.0158  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
8   3M  0.0157  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
9   6M  0.0151  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
10  9M  0.0145  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
11  1Y  0.0138  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
12  2Y  0.0122  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
13  3Y  0.0112  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
14  4Y  0.0114  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
15  5Y  0.0115  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
16  6Y  0.0116  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
17  7Y  0.0118  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
18  8Y  0.0121  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
19  9Y  0.0124  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
20  10Y 0.0127  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
21  12Y 0.0131  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
22  15Y 0.0137  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
23  20Y 0.0143  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
24  25Y 0.0145  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
25  30Y 0.0146  <QuantLib.QuantLib.SimpleQuote; proxy of <Swig...
$\endgroup$
1
  • $\begingroup$ I just change the tenor of ON, TN and S/N to 1D. Is that a proper way to do this? $\endgroup$ Jun 12, 2020 at 4:07

1 Answer 1

2
$\begingroup$

I don't think that is the best way to implement it.

From a curve construction perspective the index for ON, SN and TN is the same and is just used to get the rate conventions.

index = ql.OvernightIndex('USD_ON', 0, ql.USDCurrency(), ql.UnitedStates(), ql.Actual360())
helpers = ql.RateHelperVector()
helpers.append( ql.OISRateHelper(0, ql.Period('1D'), ql.QuoteHandle(ql.SimpleQuote(0.0010)), index) )
helpers.append( ql.OISRateHelper(1, ql.Period('1D'), ql.QuoteHandle(ql.SimpleQuote(0.0015)), index) )
helpers.append( ql.OISRateHelper(2, ql.Period('1D'), ql.QuoteHandle(ql.SimpleQuote(0.0020)), index) )

import pandas as pd

pd.DataFrame([{
    "earliestDate": h.earliestDate().ISO(),
    "pillarDate": h.pillarDate().ISO(),
    "maturityDate": h.maturityDate().ISO(),
    "quote": h.quote().value()
} for h in helpers])

enter image description here

crv = ql.PiecewiseLogLinearDiscount(ql.Date().todaysDate(), helpers, ql.ActualActual())
crv.nodes()

((Date(12,6,2020), 1.0),
(Date(15,6,2020), 0.9999916667361105),
(Date(16,6,2020), 0.9999875001215266),
(Date(17,6,2020), 0.9999819446662784))

$\endgroup$
4
  • $\begingroup$ Thanks! this make sense. $\endgroup$ Jun 12, 2020 at 9:01
  • $\begingroup$ BTY, how to handle this on DepositRateHelper? What's the best way to set parameter $\endgroup$ Jun 12, 2020 at 9:01
  • $\begingroup$ quantlib-python-docs.readthedocs.io/en/latest/thelpers.html $\endgroup$ Jun 12, 2020 at 9:04
  • $\begingroup$ Just remember o/n and t/n dont always exist - if you are doing some general work then this is a headache you need to be aware of. $\endgroup$
    – river_rat
    Jun 13, 2020 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.