Skip to content
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

MakeVanillaSwap may infer the wrong fixed leg tenor for swaps with explicit termination dates #1367

Open
tomwhoiscontrary opened this issue May 6, 2022 · 0 comments

Comments

@tomwhoiscontrary
Copy link
Contributor

I haven't actually tested this, but i believe this from reading the code. I will try to write a test case later, but i wanted to report this before i forget!

I am assuming that MakeVanillaSwap is still supported and intended to be used; i have not noticed that it is deprecated etc.

To use MakeVanillaSwap to create a swap with an explicit termination date, we call withTerminationDate; this sets the swapTenor_ field to a null value:

    MakeVanillaSwap::withTerminationDate(const Date& terminationDate) {
        terminationDate_ = terminationDate;
        swapTenor_ = Period();
        return *this;
    }

When the swap is actually built, the fixed leg tenor is inferred based on conventions for the currency and swap tenor:

        Period fixedTenor;
        if (fixedTenor_ != Period())
            fixedTenor = fixedTenor_;
        else {
            if ((curr == EURCurrency()) ||
                (curr == USDCurrency()) ||
                (curr == CHFCurrency()) ||
                (curr == SEKCurrency()) ||
                (curr == GBPCurrency() && swapTenor_ <= 1 * Years))
                fixedTenor = Period(1, Years);
            else if ((curr == GBPCurrency() && swapTenor_ > 1 * Years) ||
                (curr == JPYCurrency()) ||
                (curr == AUDCurrency() && swapTenor_ >= 4 * Years))
                fixedTenor = Period(6, Months);
            else if ((curr == HKDCurrency() ||
                     (curr == AUDCurrency() && swapTenor_ < 4 * Years)))
                fixedTenor = Period(3, Months);
            else
                QL_FAIL("unknown fixed leg default tenor for " << curr);
        }

But in this case, for a swap with an explicit termination date, there is no valid swapTenor_, and what happens depends on how a null Period compares to non-null ones; i suspect that for sterling and Australian dollars, the tenor for short swaps will be picked, regardless of the actual tenor of the swap. This seems wrong to me.

I can see a couple of ways this could be changed.

Firstly, require an explicit fixed leg tenor if there is an explicit termination date. Thrown an assertion error otherwise.

Secondly, if there is an explicit termination date, work out an implicit swap tenor based on the effective and termination dates, and infer the fixed leg tenor from that.

Tangentially, i think it's a bit odd that this is all written in terms of leg tenor, rather than leg frequency, which is what is used in most other places i have seen, but it's not a big deal. I just wish there weren't so many different uses of "tenor" in this field!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants