-
Notifications
You must be signed in to change notification settings - Fork 2k
Const Notional Cross Currency Swaps #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Const Notional Cross Currency Swaps #2248
Conversation
@pcaspers — I'm assuming you're still ok with moving things here from ORE, give me a shout if things changed. Thanks! |
// Pay leg notional exchange at start. | ||
Date initialPayDate = paySchedule_.dates().front(); | ||
ext::shared_ptr<CashFlow> initialPayCF(new SimpleCashFlow(-payNominal_, initialPayDate)); | ||
legs_[0].insert(legs_[0].begin(), initialPayCF); | ||
// Pay leg notional exchange at end. | ||
Date finalPayDate = paySchedule_.dates().back(); | ||
ext::shared_ptr<CashFlow> finalPayCF(new SimpleCashFlow(payNominal_, finalPayDate)); | ||
legs_[0].push_back(finalPayCF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that this models only the const-notional swap, right? If so, it should probably be in the name of the class. The same goes for the other classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mtm crossccy in ORE are named crossccy<type_of_crossccy>mtmresetswap
, while the const-notionals are named crossccy<type_of_crossccy>swap
. Would you prefer crossccy<type_of_crossccy>constnotionalswap
as naming convention for const-notional xccy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pcaspers, would changing the class name be a problem?
\warning The notional amounts, payment schedules, and other details of each leg must be | ||
set up in the provided Leg objects before constructing the swap. | ||
*/ | ||
CrossCcySwap(const std::vector<Leg>& legs, const std::vector<bool>& payer, const std::vector<Currency>& currencies); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want an arbitrary number of legs here and the complexity that follows? @pcaspers, did you ever have a use for this in the past?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of, but we might break our processing if we restrict the class to 2 legs now. What kind of increased complexity do you have in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just that you have to loop over the legs, no big deal. Ok to have a vector.
CrossCcySwapEngine::CrossCcySwapEngine(const Currency& ccy1, const Handle<YieldTermStructure>& currency1Discountcurve, | ||
const Currency& ccy2, const Handle<YieldTermStructure>& currency2Discountcurve, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any better name for instead of currency1/currency2? Domestic/foreign? Base/other? Main/other? @pcaspers, was there any reason you picked 1 and 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Domestic / Foreign is in line with the expected fx spot quote and better than 1 and 2 in my opnion.
registerWith(spotFX_); | ||
} | ||
|
||
void CrossCcySwapEngine::calculate() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work for both const-notional and mark-to-market, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, to be sure you can just check the following test
We are ok with that. My only ask would be to keep ORE aligned, i.e. remove the classes from ORE and make sure ORE still works with the ql version. |
@pcaspers - One thing, in the |
Yes please, CrossCcyBasisSwap is supposed to support overnight legs. I ddn't check this PR in detail, but as I said above, I would appreciate if all functionality is preserved and a corresponding PR is opened for ORE that allows to remove the migrated classes in ORE and rely on the then-ql classes. |
Agreed — but should we use bools like |
Another thing @pcaspers, I see that in ORE you are using a different How should I tackle this problem? @lballabio seeking you guidance as well |
Hmm, if that's the case it's probably better to make another PR first that sorts out the overnight leg and pricers. @pcaspers, do you happen to have a summary of the differences? |
Ah yes, ORE and QuantLib diverged for the on coupons a while ago. I'd think they have roughly the same functional scope. QuantLib is more elegant. ORE might have some extensions like a freely definable rate computation period. Also, ORE adds cap / floors on overnight coupons. It would be great if someone could work on aligning QuantLib and ORE in this regard. It's on our roadmap for a while, but we never came around to actually do this. And yes, we probably better do this before migrating dependent classes like the xccy swap. |
All right, make sense to work on the copouns differences before introducing these new classes. I'll try to work on it, since I've already spotted some of the differences. I'll ping you guys (@lballabio, @pcaspers) if I need any help with that. |
Partially solving #2201 by adding const notional xccy swaps classes from ORE and readapting them to the current QuantLib version. MTM xccy swap will be added in another PR.
Classes added:
CrossCcySwap
: base class for a cross currency swapCrossCcyFixFloatSwap
: cross currency swap with a fixed leg and a floating legCrossCcyBasisSwap
: cross currency swap with two floating legsCrossCcySwapEngine
: the cross currency swap engine