attack68 / rateslib

A fixed income library for pricing bonds and bond futures, and derivatives such as IRS, cross-currency and FX swaps. Contains tools for full Curveset construction with market standard optimisers and automatic differention (AD) and risk sensitivity calculations including delta and cross-gamma.
https://rateslib.readthedocs.io/en/latest/
Other
152 stars 27 forks source link

Adding AUD and NZD calendar and IRS spec into spec_loader? #350

Closed ChrisSun19921016 closed 1 month ago

ChrisSun19921016 commented 2 months ago

Is it possible to add AUD and NZD into the spec_loader? Thanks

Chris

attack68 commented 2 months ago

Do you happen to know their specs in this format:

defaults.spec["usd_irs"]
Out[1]: 
{'frequency': 'a',
 'stub': 'shortfront',
 'eom': False,
 'modifier': 'mf',
 'calendar': 'nyc',
 'payment_lag': 2,
 'currency': 'usd',
 'convention': 'act360',
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'rfr_payment_delay'}

If so I might be able to get them in for 1.4.0 release hopefully this week.

attack68 commented 2 months ago

I dont think there are AUD or NZD calendars. So probably need to define those first as well. Do you know how they work, or better yet can you share a CSV of fixing data against which the calendars can be measured so that in the past 5-10yrs the calendars produced exactly replicate the fixing dates.

Correction: I have added a Sydney calendar in the past but not a Wellington calendar.

ChrisSun19921016 commented 2 months ago

I guess we start with AUD first. For AUD there is the AONIA (OIS) curve, the BBSW 3M curve, and the BBSW 6M curve. (the most liquid ones anyway). The specs for the AUD OIS curve is: {'frequency': 'a', 'stub': 'shortfront', 'eom': True, 'modifier': 'mf', 'calendar': 'xxx', 'payment_lag': 2, 'currency': 'aud', 'convention': 'act365f', 'leg2_spread_compound_method': 'none_simple', 'leg2_fixing_method': 'rfr_payment_delay'} for the 3m curve: {'frequency': 'q', 'stub': 'shortfront', 'eom': True, 'modifier': 'mf', 'calendar': 'xxx', 'payment_lag': 2, 'currency': 'aud', 'convention': 'act365f', 'leg2_frequency': 'q', 'leg2_convention': 'act365f', 'leg2_spread_compound_method': 'none_simple', 'leg2_fixing_method': 'ibor', 'leg2_method_param': 2} and similarly for 6m: {'frequency': 's', 'stub': 'shortfront', 'eom': True, 'modifier': 'mf', 'calendar': 'xxx', 'payment_lag': 2, 'currency': 'aud', 'convention': 'act365f', 'leg2_frequency': 's', 'leg2_convention': 'act365f', 'leg2_spread_compound_method': 'none_simple', 'leg2_fixing_method': 'ibor', 'leg2_method_param': 2}

For calendar, I am afraid I dont have one at hand. I will share once I have it. You mentioned you have added Sydney calendar in the past, would that have worked?

Thanks for the swift reply!

attack68 commented 2 months ago

The Syndey calendar is correct. I have coded and tested that against RFR fixings. However, I have no data (or havent looked) for NZD. But of you can supply holiday rules and some fixing data to test NZD against its more likely to get done.

attack68 commented 2 months ago

Are you sure there is a payment lag on the IBOR? For other currencies usually this is 2 for RFR and 0 for IBOR related (because the cashflows is know well in advance).

ChrisSun19921016 commented 2 months ago

You are right, there shouldn't be. Thanks for pointing that out.

attack68 commented 1 month ago

New Zealand...

defaults.spec["nzd_irs3"] =
{'frequency': 's',
 'stub': 'shortfront',
 'eom': True,
 'modifier': 'mf',
 'calendar': 'wlg',
 'payment_lag': 0,
 'currency': 'nzd',
 'convention': 'act365f',
 'leg2_frequency': 'q'
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'ibor'
 'leg2_method_param': 0
}

defaults.spec["nzd_irs6"] =
{'frequency': 's',
 'stub': 'shortfront',
 'eom': True,
 'modifier': 'mf',
 'calendar': 'wlg',
 'payment_lag': 0,
 'currency': 'nzd',
 'convention': 'act365f',
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'ibor'
 'leg2_method_param': 0
}

@ChrisSun19921016 can you confirm these look reasonable for NZD 3s and 6s swaps. Note the method param (no lagged publication like US LIBOR or EURIBOR).

ChrisSun19921016 commented 1 month ago

Thanks for the update. The spec for NZD 3s looks fine. Not sure if we needed a 6s swap spec since it is not actively traded, nevertheless no harm to include them.

We would also need to add the xccy curve specs for AUD and NZD. I have specified in my local environment as below (please advise if you see anything wrong):

{'frequency': 'q',
 'stub': 'shortfront',
 'eom': False,
 'modifier': 'mf',
 'calendar': 'nyc,syd',
 'payment_lag': 2,
 'currency': 'aud',
 'convention': 'act365f',
 'leg2_currency': 'usd',
 'spread_compound_method': 'none_simple',
 'fixing_method': 'rfr_payment_delay',
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'rfr_payment_delay',
 'payment_lag_exchange': 0,
 'fixed': False,
 'leg2_fixed': False,
 'leg2_mtm': True}

and NZD:

{'frequency': 'q',
 'stub': 'shortfront',
 'eom': False,
 'modifier': 'mf',
 'calendar': 'nyc,wlg',
 'payment_lag': 2,
 'currency': 'nzd',
 'convention': 'act365f',
 'leg2_currency': 'usd',
 'spread_compound_method': 'none_simple',
 'fixing_method': 'rfr_payment_delay',
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'rfr_payment_delay',
 'payment_lag_exchange': 0,
 'fixed': False,
 'leg2_fixed': False,
 'leg2_mtm': True}
attack68 commented 1 month ago

Those spec are vs NZD and AUD RFR rates. Is there not a more common XCS for each of those that settles against the term IBOR style rate, i.e.:

defaults.spec["aud3usd_xcs"] = 
{
 # inherited parameters
 'frequency': 'q',
 'stub': 'shortfront',
 'eom': False,
 'modifier': 'mf',
 'calendar': 'nyc,syd',
 'payment_lag_exchange': 0,
 'payment_lag': 2,

 # leg1 specific
 'currency': 'aud',
 'convention': 'act365f',
 'spread_compound_method': 'none_simple',
 'fixing_method': 'ibor',
 'method_param': 2,  #  IS BBSW3M REALLY 2b.d. publication lag ????

 #leg 2 specific
 'leg2_currency': 'usd',
 'leg2_convention': 'act360',     ## <--- NOTE
 'leg2_spread_compound_method': 'none_simple',
 'leg2_fixing_method': 'rfr_payment_delay',
 'leg2_method_param': 0,

 # XCS control
 'fixed': False,
 'leg2_fixed': False,
 'leg2_mtm': True
}
ChrisSun19921016 commented 1 month ago

don't think BBSW3M is 2b.d. publication lag. Think the 'method_param' should have 0 as input for leg 1

attack68 commented 1 month ago

re open this if provided specs do not satisfy requirements.