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

Return EOM when calculating roll convention from stub if prefer EOM is true #1590

Merged
merged 3 commits into from Oct 30, 2017

Conversation

Projects
None yet
2 participants
@brianweller89
Contributor

brianweller89 commented Oct 27, 2017

This fixes an edge case for February. For EOM trades, If start and end date are in February and one (but not both) was in a a leap year then the roll convention was calculated as 29 rather than EOM.

Also added new tests for existing use cases.

Use actual start month and end month rather than proleptic months to …
…determine EOM rolls.

This fixes an edge case for February. For EOM trades, If start and end date are in February and one (but not both) was in a a leap year then the roll convention was calculated as 29 rather than EOM.

In terms of existing behaviour, only other change is to the below use case:
* If start and end date are in same month but not the same year
* With different day of month
* End date day of month is the last day of the month

This case previously returned EOM roll day but now returns start day of month as the roll day. A trade with this combination of regular period start/end date should only be valid if it is a single period swap, in which case roll day would not be relevant.
@@ -259,7 +257,7 @@ public RollConvention toRollConvention(
// dates are at the end of the month, and in different months
if (this == NONE) {
if (start.getDayOfMonth() != end.getDayOfMonth() &&
start.getLong(PROLEPTIC_MONTH) != end.getLong(PROLEPTIC_MONTH) &&
start.getMonth() != end.getMonth() &&

This comment has been minimized.

@jodastephen

jodastephen Oct 27, 2017

Member

This seems like an even odder test than before. A schedule from July to July will handled differently to one from July to August.

Maybe keep the existing code, but inside the block check preferEndOfMonth and return EOM if true?

This comment has been minimized.

@brianweller89

brianweller89 Oct 27, 2017

Contributor

Per the existing comment it looks like the original intention here was to handle the case where the months are different, so varying behaviour when months are different vs the same doesn't seem unexpected?

An effect of the above suggestion would be that an EOM trade with start on 28 February and end 30th April would change to return EOM roll convention rather than 30. This sounds fine in the context of "preferEndOfMonth" being true but does feel like a slightly more intrusive change in behaviour than currently proposed.

brianweller89 added some commits Oct 27, 2017

@jodastephen jodastephen merged commit 7ce49eb into master Oct 30, 2017

15 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
security/snyk No new issues
Details
security/snyk - modules/basics/pom.xml No new issues
Details
security/snyk - modules/calc/pom.xml No new issues
Details
security/snyk - modules/collect/pom.xml No new issues
Details
security/snyk - modules/data/pom.xml No new issues
Details
security/snyk - modules/loader/pom.xml No new issues
Details
security/snyk - modules/market/pom.xml No new issues
Details
security/snyk - modules/math/pom.xml No new issues
Details
security/snyk - modules/measure/pom.xml No new issues
Details
security/snyk - modules/pom.xml No new issues
Details
security/snyk - modules/pricer/pom.xml No new issues
Details
security/snyk - modules/product/pom.xml No new issues
Details
security/snyk - modules/report/pom.xml No new issues
Details

@jodastephen jodastephen deleted the topic/Feb_EOM_fix branch Oct 30, 2017

brianweller89 added a commit that referenced this pull request Oct 31, 2017

Use actual start month and end month rather than proleptic months to …
…determine EOM rolls. (#1590)

* Use actual start month and end month rather than proleptic months to determine EOM rolls.

This fixes an edge case for February. For EOM trades, If start and end date are in February and one (but not both) was in a a leap year then the roll convention was calculated as 29 rather than EOM.

In terms of existing behaviour, only other change is to the below use case:
* If start and end date are in same month but not the same year
* With different day of month
* End date day of month is the last day of the month

This case previously returned EOM roll day but now returns start day of month as the roll day. A trade with this combination of regular period start/end date should only be valid if it is a single period swap, in which case roll day would not be relevant.

* PR comment

* Additional test cases

@brianweller89 brianweller89 changed the title from Use actual start month and end month rather than proleptic months to determine EOM rolls. to Return EOM when calculating roll convention from stub if prefer EOM is true Oct 31, 2017

@jodastephen jodastephen added this to the v1.6 milestone Nov 6, 2017

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