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

Added counterparty field to CSV trade loader. #1583

Merged
merged 3 commits into from Oct 24, 2017

Conversation

marc-henrard
Copy link
Contributor

Parse Counterparty field for loaded trades. The counterparty are loaded into the 'counterparty' field of the TradeInfo.
Close issue #1582

@@ -424,6 +433,11 @@ private TradeInfo parseTradeInfo(CsvRow row) {
TradeInfoBuilder infoBuilder = TradeInfo.builder();
String scheme = row.findField(ID_SCHEME_FIELD).orElse(DEFAULT_TRADE_SCHEME);
row.findValue(ID_FIELD).ifPresent(id -> infoBuilder.id(StandardId.of(scheme, id)));
String schemeCpty = row.findField(CTPY_SCHEME_FIELD).orElse(DEFAULT_CTPY_SCHEME);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be findValue() not findField(). This will then default empty schemes.

@@ -424,6 +433,11 @@ private TradeInfo parseTradeInfo(CsvRow row) {
TradeInfoBuilder infoBuilder = TradeInfo.builder();
String scheme = row.findField(ID_SCHEME_FIELD).orElse(DEFAULT_TRADE_SCHEME);
row.findValue(ID_FIELD).ifPresent(id -> infoBuilder.id(StandardId.of(scheme, id)));
String schemeCpty = row.findField(CTPY_SCHEME_FIELD).orElse(DEFAULT_CTPY_SCHEME);
Optional<String> cptyOption = row.findValue(CTPY_FIELD);
if (cptyOption.isPresent() && !cptyOption.get().equals(EMPTY)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check for EMPTY as findValue() does this.

@@ -0,0 +1,23 @@
Strata Trade Type,Id Scheme,Id,Counterparty Scheme,Counterparty,Trade Date,Trade Time,Trade Zone,Convention,Buy Sell,Period To Start,Tenor,Index,Interpolated index,Fixed Rate,FX Rate,Day Count,Currency,Notional,Start Date,End Date,Date Convention,Date Calendar,Stub Convention,Leg 1 Direction,Leg 1 Start Date,Leg 1 End Date,Leg 1 Stub Convention,Leg 1 Roll Convention,Leg 1 Frequency,Leg 1 Currency,Leg 1 Notional,Leg 1 Fixed Rate,Leg 1 Day Count,Leg 1 Date Convention,Leg 1 Date Calendar,Leg 2 Direction,Leg 2 Start Date,Leg 2 End Date,Leg 2 Frequency,Leg 2 Currency,Leg 2 Notional,Leg 2 Index,Security Id Scheme,Security Id,Quantity,Long Quantity,Price
Fra,OG,123401,CPTY,Bank A,01/06/2017,11:05,Europe/London,GBP-LIBOR-3M,Buy,P2M,,,,0.5,,,,1000000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be simpler to add the extra two columns to the existing trades.csv file and extend the existing tests, rather than cutting and pasting new ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check 3 cases: without counterparty column, with only the 'Counterparty' column and with both 'Counterparty' and 'Counterparty Scheme' columns. That means at least 3 files.

@marc-henrard marc-henrard merged commit 56d9fcc into master Oct 24, 2017
@marc-henrard marc-henrard deleted the topic/trade-loader-cpty branch October 24, 2017 16:08
@jodastephen jodastephen added this to the v1.5 milestone Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants