From 029ddcba6a526b765353a7a9a4d201c39d628582 Mon Sep 17 00:00:00 2001 From: Julius Lauterbach Date: Mon, 18 Nov 2024 15:09:59 +0100 Subject: [PATCH 1/2] SDC-660, added initialSettlementDate to SDC Descriptor --- .../product/SmartDerivativeContractDescriptor.java | 8 +++++++- .../finmath/smartcontract/product/xml/SDCXMLParser.java | 5 +++-- .../smartcontract/product/xml/SDCXMLParserTest.java | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/finmath/smartcontract/product/SmartDerivativeContractDescriptor.java b/src/main/java/net/finmath/smartcontract/product/SmartDerivativeContractDescriptor.java index 1f4e3c38..efad7c0e 100644 --- a/src/main/java/net/finmath/smartcontract/product/SmartDerivativeContractDescriptor.java +++ b/src/main/java/net/finmath/smartcontract/product/SmartDerivativeContractDescriptor.java @@ -29,6 +29,7 @@ public class SmartDerivativeContractDescriptor { private final String currency; private final String marketDataProvider; private final String tradeType; + private final String initialSettlementDate; /** * Descriptor for a smart derivative contract counterparty. Unified access to a party definition in an XML. @@ -75,7 +76,7 @@ public String toString() { } //TODO convert constructor into builder pattern or something comparable - public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, String uniqueTradeIdentifier, LocalDateTime tradeDate, List counterparties, Map marginAccountInitialByPartyID, Map penaltyFeeInitialByPartyID, String recervicePartyID, Node underlying, List marketdataItems, String currency, String marketDataProvider, String tradeType) { + public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, String uniqueTradeIdentifier, LocalDateTime tradeDate, List counterparties, Map marginAccountInitialByPartyID, Map penaltyFeeInitialByPartyID, String recervicePartyID, Node underlying, List marketdataItems, String currency, String marketDataProvider, String tradeType, String initialSettlementDate) { this.dltTradeId = dltTradeId; this.dltAddress = dltAddress; this.uniqueTradeIdentifier = uniqueTradeIdentifier; @@ -89,6 +90,7 @@ public SmartDerivativeContractDescriptor(String dltTradeId, String dltAddress, S this.currency = currency; this.marketDataProvider = marketDataProvider; this.tradeType = tradeType; + this.initialSettlementDate = initialSettlementDate; Validate.isTrue(counterparties.size() == 2, "Number of counterparties must be 2."); Validate.isTrue(marginAccountInitialByPartyID.size() == 2, "Number of margin accounts values must be 2."); @@ -161,4 +163,8 @@ public String getMarketDataProvider() { public String getTradeType() { return tradeType; } + + public String getInitialSettlementDate() { + return initialSettlementDate; + } } diff --git a/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java b/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java index 515e764b..96826155 100644 --- a/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java +++ b/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java @@ -97,9 +97,10 @@ public static SmartDerivativeContractDescriptor parse(String sdcxml) throws Pars String marketDataProvider = sdc.getSettlement().getMarketdata().getProvider().trim(); - String tradeType = sdc.getTradeType(); + String tradeType = sdc.getTradeType().trim(); + String initialSettlementDate = sdc.getSettlement().getSettlementDateInitial().trim(); - return new SmartDerivativeContractDescriptor(dltTradeId, dltAddress, uniqueTradeIdentifier, settlementDateInitial, parties, marginAccountInitialByPartyID, penaltyFeeInitialByPartyID, receiverPartyID, underlying, marketdataItems, currency, marketDataProvider, tradeType); + return new SmartDerivativeContractDescriptor(dltTradeId, dltAddress, uniqueTradeIdentifier, settlementDateInitial, parties, marginAccountInitialByPartyID, penaltyFeeInitialByPartyID, receiverPartyID, underlying, marketdataItems, currency, marketDataProvider, tradeType, initialSettlementDate); } public static T unmarshalXml(String xml, Class t) { diff --git a/src/test/java/net/finmath/smartcontract/product/xml/SDCXMLParserTest.java b/src/test/java/net/finmath/smartcontract/product/xml/SDCXMLParserTest.java index 3893fbc9..150edf48 100644 --- a/src/test/java/net/finmath/smartcontract/product/xml/SDCXMLParserTest.java +++ b/src/test/java/net/finmath/smartcontract/product/xml/SDCXMLParserTest.java @@ -46,6 +46,7 @@ void testParser() throws IOException, SAXException, ParserConfigurationException Assertions.assertEquals("0x000000001", sdc.getDltAddress()); Assertions.assertEquals("EUR", sdc.getCurrency()); Assertions.assertEquals("internal", sdc.getMarketDataProvider()); + Assertions.assertEquals("2011-12-03T10:15:30", sdc.getInitialSettlementDate()); // Get parties List parties = sdc.getCounterparties(); @@ -154,6 +155,7 @@ void marshalSDCToXMLString() throws IOException, ParserConfigurationException, S Assertions.assertEquals("0x000000001", sdcDescriptor.getDltAddress()); Assertions.assertEquals("EUR", sdcDescriptor.getCurrency()); Assertions.assertEquals("internal", sdcDescriptor.getMarketDataProvider()); + Assertions.assertEquals("2011-12-03T10:15:30", sdcDescriptor.getInitialSettlementDate()); } } \ No newline at end of file From 28cd297755f53c1771d78988cf5d67cebd10e062 Mon Sep 17 00:00:00 2001 From: Julius Lauterbach Date: Mon, 18 Nov 2024 15:15:59 +0100 Subject: [PATCH 2/2] SDC-660, clean up --- .../net/finmath/smartcontract/product/xml/SDCXMLParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java b/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java index 96826155..d6baf3fd 100644 --- a/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java +++ b/src/main/java/net/finmath/smartcontract/product/xml/SDCXMLParser.java @@ -97,7 +97,7 @@ public static SmartDerivativeContractDescriptor parse(String sdcxml) throws Pars String marketDataProvider = sdc.getSettlement().getMarketdata().getProvider().trim(); - String tradeType = sdc.getTradeType().trim(); + String tradeType = sdc.getTradeType(); String initialSettlementDate = sdc.getSettlement().getSettlementDateInitial().trim(); return new SmartDerivativeContractDescriptor(dltTradeId, dltAddress, uniqueTradeIdentifier, settlementDateInitial, parties, marginAccountInitialByPartyID, penaltyFeeInitialByPartyID, receiverPartyID, underlying, marketdataItems, currency, marketDataProvider, tradeType, initialSettlementDate);