Add CSV format for trades #1540
Conversation
* @param refData the reference data | ||
* @return the loaded trades, all errors are captured in the result | ||
*/ | ||
static SwapTrade parse(CsvRow row, TradeInfo info, ReferenceData refData) { |
brianweller89
Aug 14, 2017
Contributor
Unused refData arg
Unused refData arg
while (payReceive.isPresent()) { | ||
legs.add(parseLeg(row, "Leg " + i + " ")); | ||
i++; | ||
payReceive = row.findValue("Leg " + i + " " + DIRECTION_FIELD); |
brianweller89
Aug 14, 2017
Contributor
Could use private findValue() here for consistency
Could use private findValue() here for consistency
.map(s -> new Integer(s)); | ||
HolidayCalendarId cal = findValue(row, leg, daysCalField) | ||
.map(s -> HolidayCalendarId.of(s)) | ||
.orElse(HolidayCalendarIds.NO_HOLIDAYS); |
brianweller89
Aug 14, 2017
Contributor
Would this default behaviour of using "NO_HOLIDAYS" ever be appropriate? We are using this method for fixing and payment dates, which would always need to be good business days.
If the input contains a days adjustment but no accompanying calendar it might be better to throw an exception.
Would this default behaviour of using "NO_HOLIDAYS" ever be appropriate? We are using this method for fixing and payment dates, which would always need to be good business days.
If the input contains a days adjustment but no accompanying calendar it might be better to throw an exception.
jodastephen
Aug 22, 2017
Author
Member
This needs to be tackled separately
This needs to be tackled separately
String indexStr = indexOpt.get(); | ||
Optional<FloatingRateName> frnOpt = FloatingRateName.extendedEnum().find(indexStr); | ||
if (frnOpt.isPresent()) { | ||
FloatingRateName frn = FloatingRateName.of(indexStr); |
brianweller89
Aug 14, 2017
Contributor
Seems odd to not be using frnOpt.get() here?
Seems odd to not be using frnOpt.get() here?
private static RateCalculation parseFixedRateCalculation(CsvRow row, String leg, double fixedRate, Currency currency) { | ||
FixedRateCalculation.Builder builder = FixedRateCalculation.builder(); | ||
// basics | ||
builder.dayCount(DayCount.of(getValue(row, leg, DAY_COUNT_FIELD))); |
brianweller89
Aug 14, 2017
Contributor
Probably involves too much work for the relative benefit, but would be nice to default the fixed DCF. There is a standard for each currency.
Probably involves too much work for the relative benefit, but would be nice to default the fixed DCF. There is a standard for each currency.
jodastephen
Aug 22, 2017
Author
Member
This needs to be tackled separately
This needs to be tackled separately
line++; | ||
} catch (RuntimeException ex) { | ||
failures.add( | ||
FailureItem.of(FailureReason.PARSING, ex, "CSV file trade could not be parsed at line {}: " + ex.getMessage(), line)); |
brianweller89
Aug 14, 2017
Contributor
Line count will not be incremented if exception is thrown.
Line count will not be incremented if exception is thrown.
case "FALSE": | ||
case "F": | ||
case "NO": | ||
return false; |
brianweller89
Aug 14, 2017
Contributor
Might as well support "Y" and "N" options as well
Might as well support "Y" and "N" options as well
} | ||
// dd/MM/yy | ||
// dd/MM/yyyy | ||
if (str.length() >= 6 && str.charAt(2) == '/' && str.charAt(5) == '/') { |
brianweller89
Aug 14, 2017
Contributor
This should be 8 rather than 6
This should be 8 rather than 6
throw new IllegalArgumentException( | ||
"Unknown date format, must be formatted as " + | ||
"yyyy-MM-dd, yyyyMMdd, dd/MM/yyyy, yyyy/MM/dd, 'd-MMM-yyyy' or 'dMMMyyyy' but was: " + str, | ||
ex); |
brianweller89
Aug 14, 2017
Contributor
dd/MM/yy not included in the exception message
dd/MM/yy not included in the exception message
jodastephen
Aug 18, 2017
Author
Member
Exceptions are only including the recommended inputs, not everything we accept ;-)
Exceptions are only including the recommended inputs, not everything we accept ;-)
|
||
//------------------------------------------------------------------------- | ||
public void coverage() { | ||
coverPrivateConstructor(FraTradeCsvLoader.class); |
brianweller89
Aug 14, 2017
Contributor
Why is FraTradeCsvLoader the only class tested here?
Why is FraTradeCsvLoader the only class tested here?
Tenor tenor = tenorOpt.get(); | ||
LocalDate endDate = startDate.plus(tenor); | ||
SwapTrade trade = createSwap(info, conventionStr, startDate, endDate, buySell, notional, fixedRate, fxRateOpt); | ||
return adjustTrade(trade, rollCnvOpt, stubCnvOpt, firstRegStartDateOpt, lastRegEndDateOpt, dateCnv, dateCalOpt); |
brianweller89
Aug 22, 2017
Contributor
Can we update the javadoc (TradeCsvLoader) to reflect the fact that this combination is now supported?
Can we update the javadoc (TradeCsvLoader) to reflect the fact that this combination is now supported?
Change column name Fix Javadoc
FRA, Swap and Term Deposit.
All can be created from a convention or from individual fields.
Swaps do not support variable notional/rate/gearing/spread, but support almost all other features.