Default day count from index - #1553
Conversation
77c5885 to
4f0e9e8
Compare
brianweller89
left a comment
There was a problem hiding this comment.
Few minor points on the review.
Can we add a test for the defaulting logic?
| FloatingRateIndex index = parseIndex(row, legPrefix); | ||
| if (index != null) { | ||
| // floating leg | ||
| indices.add(index); |
There was a problem hiding this comment.
indices.add(index) can be outside the if loop rather than here; will still add null for the fixed rate
| // fixed leg | ||
| indices.add(null); | ||
| if (!findValue(row, legPrefix, DAY_COUNT_FIELD).isPresent()) { | ||
| missingDayCount = true; |
There was a problem hiding this comment.
Do we even need the missingDayCount check? Feels like this is an unnecessary layer of complexity in what is already quite complex code.
What's the harm of passing a non-null default into the parseLegs method? Will just be ignored if the fixed leg has defined value.
There was a problem hiding this comment.
Case is where there is a fixed leg and two floating legs with different day counts. Must only trigger the "check day unique" logic when day count is actually missing.
| throw new IllegalArgumentException( | ||
| "Swap leg must define day count on fixed legs when more than 2 floating legs"); | ||
| } | ||
| defaultFixedLegDayCount = dayCounts.iterator().next(); |
There was a problem hiding this comment.
I like the readibility of Iterables.getOnlyElement() in these situations
| FloatingRateIndex index, | ||
| DayCount defaultFixedLegDayCount, | ||
| BusinessDayAdjustment bda, | ||
| Frequency accrualFrequency, |
There was a problem hiding this comment.
accrual frequency not used anymore
| if (frn.getType() == FloatingRateType.IBOR) { | ||
| // re-parse Ibor using tenor, which ensures tenor picked up from indexStr if present | ||
| Frequency freq = Frequency.parse(getValue(row, leg, FREQUENCY_FIELD)); | ||
| Tenor iborTenor = freq.isTerm() ? frn.getDefaultTenor() : Tenor.of(freq.getPeriod()); |
There was a problem hiding this comment.
Not immediately related to this PR but our getDefaultTenor() logic is not fully correct here.
Default tenor for most major currencies is 6M, with only USD being 3M
There was a problem hiding this comment.
* This is useful for providing a basic default where errors need to be avoided.
* The value returned is not intended to be based on market conventions."
Use additional `FloatingRateIndex` logic to default day count
6269d87 to
955dfe5
Compare
Use additional
FloatingRateIndexlogic to default day count.Determines the index for each leg first, then calculates the default day count, then parses.