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

Feature/526, parse currency out of fpml #83

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class SmartDerivativeContractDescriptor {
private final String recervicePartyID;
private final Node underlying;
private final List<CalibrationDataItem.Spec> marketdataItemList;
private final String currency;

/**
* Descriptor for a smart derivative contract counterparty. Unified access to a party definition in an XML.
Expand Down Expand Up @@ -71,7 +72,7 @@ public String toString() {
}
}

public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, String uniqueTradeIdentifier, LocalDateTime tradeDate, List<Party> counterparties, Map<String, Double> marginAccountInitialByPartyID, Map<String, Double> penaltyFeeInitialByPartyID, String recervicePartyID, Node underlying, List<CalibrationDataItem.Spec> marketdataItems) {
public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, String uniqueTradeIdentifier, LocalDateTime tradeDate, List<Party> counterparties, Map<String, Double> marginAccountInitialByPartyID, Map<String, Double> penaltyFeeInitialByPartyID, String recervicePartyID, Node underlying, List<CalibrationDataItem.Spec> marketdataItems, String currency) {
this.dltTradeId = dltTradeId;
this.dltAddress = dltAddress;
this.uniqueTradeIdentifier = uniqueTradeIdentifier;
Expand All @@ -82,6 +83,7 @@ public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, S
this.recervicePartyID = recervicePartyID;
this.marketdataItemList = marketdataItems;
this.underlying = underlying;
this.currency = currency;

Validate.isTrue(counterparties.size() == 2, "Number of counterparties must be 2.");
Validate.isTrue(marginAccountInitialByPartyID.size() == 2, "Number of margin accounts values must be 2.");
Expand Down Expand Up @@ -142,4 +144,8 @@ public String getUnderlyingReceiverPartyID() {
}

public List<CalibrationDataItem.Spec> getMarketdataItemList() {return marketdataItemList;}

public String getCurrency() {
return currency;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public static SmartDerivativeContractDescriptor parse(String sdcxml) throws Pars
if (!underlying.getNodeName().equals("dataDocument")) {
underlying = underlying.getNextSibling();
}
Swap swap = (Swap) sdc.getUnderlyings().getUnderlying().getDataDocument().getTrade().get(0).getProduct().getValue();
String currency = swap.getSwapStream().get(0).getCalculationPeriodAmount().getCalculation().getNotionalSchedule().getNotionalStepSchedule().getCurrency().getValue().trim();

return new SmartDerivativeContractDescriptor(dltTradeId, dltAddress, uniqueTradeIdentifier, settlementDateInitial, parties, marginAccountInitialByPartyID, penaltyFeeInitialByPartyID, receiverPartyID, underlying, marketdataItems);
return new SmartDerivativeContractDescriptor(dltTradeId, dltAddress, uniqueTradeIdentifier, settlementDateInitial, parties, marginAccountInitialByPartyID, penaltyFeeInitialByPartyID, receiverPartyID, underlying, marketdataItems, currency);
}

public static <T> T unmarshalXml(String xml, Class<T> t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void testParser() throws IOException, SAXException, ParserConfigurationException
Assertions.assertEquals("UTI12345", sdc.getUniqueTradeIdentifier());
Assertions.assertEquals("ID-Test123", sdc.getDltTradeId());
Assertions.assertEquals("0x000000001", sdc.getDltAddress());
Assertions.assertEquals("EUR", sdc.getCurrency());

// Get parties
List<SmartDerivativeContractDescriptor.Party> parties = sdc.getCounterparties();
Expand Down