|
From: Luigi B. <lui...@gm...> - 2021-05-24 14:19:24
|
Francis,
thanks. Should the same changes be applied to the example in the
official repo?
Luigi
On Fri, May 14, 2021 at 5:51 PM Francis Duffy <fdf...@gm...>
wrote:
> Hi Ashwani,
>
> I had a quick look at this. The attached Python file uses the data and
> code that you have provided, with minor amendments described below, to get
> within $5 of the upfront vs. the ISDA CDS model output. The attached Excel
> sheet uses the ISDA model add-in available here
> <https://www.cdsmodel.com/cdsmodel/documentation.html#> to generate the
> ISDA CDS model upfront values that I am using for comparison. The code also
> checks the discount factors vs. the ISDA CDS model output.
>
> The minor amendments were:
>
> - 1Y IR instrument is a depo as opposed to a swap
> - The piecewise yield curve must be built with a reference date equal
> to spot date i.e. trade date (31 Mar 2021 + 2) = 2 Apr 2021. I had to copy
> that curve and insert a discount factor of 1.0 on 31 Mar 2021. Without
> this, the code generates an error yield term structure reference date
> (April 2nd, 2021 should be evaluation date (March 31st, 2021). This is
> coming from here
> <https://github.com/lballabio/QuantLib/blob/master/ql/pricingengines/credit/isdacdsengine.cpp#L84> and
> could probably be relaxed.
> - Post CDS Big Bang, protection is effective immediately on the trade
> date so you don't need trade date + 1 when creating the CDS instrument.
> This is an ISDA CDS model implementation detail, i.e. current period break
> up into Riskless days and Risky days, and is taken care of in the engine
> here
> <https://github.com/lballabio/QuantLib/blob/master/ql/pricingengines/credit/isdacdsengine.cpp#L100>
> .
>
> The output is as follows, where I have set the tolerance to $5:
> 2021-05-14 16:12:59 INFO Check Markit values
> 2021-05-14 16:12:59 INFO
> 0.168958,-1005800.972539,-1005801.000000,0.027461,True
> 2021-05-14 16:12:59 INFO
> 0.168945,-1685138.710635,-1685141.000000,2.289365,True
> 2021-05-14 16:12:59 INFO
> 0.168904,-2255634.376402,-2255639.000000,4.623598,True
> 2021-05-14 16:12:59 INFO
> 0.168860,-2729114.272363,-2729119.000000,4.727637,True
> 2021-05-14 16:12:59 INFO
> 0.168821,-3121225.248050,-3121230.000000,4.751950,True
> 2021-05-14 16:12:59 INFO distance: 16.420010
>
> I don't have access to Bloomberg to check what it generates for a trade
> date of 31 Mar 2021 (as an aside, the IR values that you provided appear to
> be from the 31 Mar 2021 ISDA IR file whereas for a trade date of 31 Mar
> 2021 I think it is convention to use the file for 30 Mar 2021 - you will
> see effectiveasof equal to 2021-03-31 in that file). The values that you
> have provided from Bloomberg look closer to the ISDA CDS converter values
> without accrued rebate but they are still quite a distance off those also.
>
> Thanks,
> Francis.
>
> On Fri, May 14, 2021 at 2:29 PM Luigi Ballabio <lui...@gm...>
> wrote:
>
>> Ashwani,
>> the Python example doesn't get results within tolerance either, so I
>> doubt there's an obvious answer here. We should probably check the code of
>> the engine.
>>
>> Luigi
>>
>>
>> On Thu, Apr 1, 2021 at 1:41 AM Ashwani Singh <ash...@gm...>
>> wrote:
>>
>>> Using isda-cds.py
>>> <https://github.com/lballabio/QuantLib-SWIG/blob/master/Python/examples/isda-engine.py>
>>> example to compare with Bloomberg ISDA Standard Upfront Model but the
>>> difference between QL fairUpfront and that from BBG is much larger than
>>> the precision set. Running just for 40% recovery and 1000 bps case while
>>> looping through 5 maturities (1Y-5Y).
>>>
>>> Results (as below):
>>>
>>> Hazard Upfront Market Value Distance Within tolerance
>>> 0 0.17 -1.00e+06 -1003010 554.96 False
>>> 1 0.17 -1.68e+06 -1682459 641.48 False
>>> 2 0.17 -2.25e+06 -2253350 426.70 False
>>> 3 0.17 -2.73e+06 -2727484 62.97 False
>>> 4 0.17 -3.12e+06 -3120142 458.70 False
>>> total distance: 2144.81
>>>
>>>
>>> Anyone who might have tried this, could you please point the obvious
>>> mistake I am committing here? Code attached.
>>>
>>> Thanks.
>>>
>>> _______________________________________________
>>> QuantLib-users mailing list
>>> Qua...@li...
>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>>
>> _______________________________________________
>> QuantLib-users mailing list
>> Qua...@li...
>> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>>
>
|