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

Add CSV format for trades #1540

Merged
merged 5 commits into from Aug 22, 2017
Merged

Add CSV format for trades #1540

merged 5 commits into from Aug 22, 2017

Conversation

@jodastephen
Copy link
Member

@jodastephen jodastephen commented Jul 31, 2017

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.

* @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) {

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

Unused refData arg

while (payReceive.isPresent()) {
legs.add(parseLeg(row, "Leg " + i + " "));
i++;
payReceive = row.findValue("Leg " + i + " " + DIRECTION_FIELD);

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

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);

This comment has been minimized.

@brianweller89

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.

This comment has been minimized.

@jodastephen

jodastephen Aug 22, 2017
Author Member

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);

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

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)));

This comment has been minimized.

@brianweller89

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.

This comment has been minimized.

@jodastephen

jodastephen Aug 22, 2017
Author Member

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));

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

Line count will not be incremented if exception is thrown.

case "FALSE":
case "F":
case "NO":
return false;

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

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) == '/') {

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

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);

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

dd/MM/yy not included in the exception message

This comment has been minimized.

@jodastephen

jodastephen Aug 18, 2017
Author Member

Exceptions are only including the recommended inputs, not everything we accept ;-)


//-------------------------------------------------------------------------
public void coverage() {
coverPrivateConstructor(FraTradeCsvLoader.class);

This comment has been minimized.

@brianweller89

brianweller89 Aug 14, 2017
Contributor

Why is FraTradeCsvLoader the only class tested here?

@jodastephen jodastephen force-pushed the topic/trade-csv branch from 8b670f8 to f030473 Aug 18, 2017
@jodastephen jodastephen force-pushed the topic/trade-csv branch from f030473 to f46c4c9 Aug 22, 2017
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);

This comment has been minimized.

@brianweller89

brianweller89 Aug 22, 2017
Contributor

Can we update the javadoc (TradeCsvLoader) to reflect the fact that this combination is now supported?

Change column name
Fix Javadoc
@jodastephen jodastephen force-pushed the topic/trade-csv branch from f440f89 to 63e91d4 Aug 22, 2017
@jodastephen jodastephen merged commit deee1bc into master Aug 22, 2017
15 checks passed
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 vulnerabilities
Details
security/snyk - modules/basics/pom.xml No new vulnerabilities
Details
security/snyk - modules/calc/pom.xml No new vulnerabilities
Details
security/snyk - modules/collect/pom.xml No new vulnerabilities
Details
security/snyk - modules/data/pom.xml No new vulnerabilities
Details
security/snyk - modules/loader/pom.xml No new vulnerabilities
Details
security/snyk - modules/market/pom.xml No new vulnerabilities
Details
security/snyk - modules/math/pom.xml No new vulnerabilities
Details
security/snyk - modules/measure/pom.xml No new vulnerabilities
Details
security/snyk - modules/pom.xml No new vulnerabilities
Details
security/snyk - modules/pricer/pom.xml No new vulnerabilities
Details
security/snyk - modules/product/pom.xml No new vulnerabilities
Details
security/snyk - modules/report/pom.xml No new vulnerabilities
Details
@jodastephen jodastephen deleted the topic/trade-csv branch Aug 22, 2017
@jodastephen jodastephen added this to the v1.4 milestone Sep 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants