Financial products Markup Language (FpML®)
FpML® (Financial products Markup Language) is the industry-standard protocol for complex financial products. It is based on XML (eXtensible Markup Language), the standard meta-language for describing data shared between applications.
NuGet Package ID | LiquidTechnologies.XmlObjects.FpML4-0 |
---|---|
Description | An object model for the FpML® 4.0 standard providing strongly typed classes that can be serialized/deserializsed to XML. |
Documentation | Liquid XML Objects API |
Schema Documentation | https://schemas.liquid-technologies.com/FpML/4.0/ |
Official Schema Site | http://www.fpml.org/ |
License | EULA |
Supported Platforms |
|
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var dataDocumentCt = new Tns.DataDocumentCt(); var trades = new Tns.TradeCt(); { var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "partyA"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.swapswire.com/spec/2001/trade-id-1-0"; tradeIds.Value = "37261"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } var partyTradeIdentifiers1 = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers1.PartyReference.Href = "partyB"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.swapswire.com/spec/2001/trade-id-1-0"; tradeIds.Value = "37261"; partyTradeIdentifiers1.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers1); } trades.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2002, 7, 11, 0, 0, 0, 0, 0, 0, false); { var product = new Tns.CreditDefaultSwapElm(); product.GeneralTerms.EffectiveDate.UnadjustedDate.Value = new LxDateTime(LxDateTimeType.Date, 2002, 7, 11, 0, 0, 0, 0, 0, 0, false); { var dateAdjustments = new Tns.BusinessDayAdjustmentsCt(); dateAdjustments.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NONE; product.GeneralTerms.EffectiveDate.DateAdjustments = dateAdjustments; } { var adjustableDate = new Tns.AdjustableDate2Ct(); adjustableDate.UnadjustedDate.Value = new LxDateTime(LxDateTimeType.Date, 2006, 7, 11, 0, 0, 0, 0, 0, 0, false); { var dateAdjustments1 = new Tns.BusinessDayAdjustmentsCt(); dateAdjustments1.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.MODFOLLOWING; { var businessCenters = new Tns.BusinessCentersCt(); var businessCenters1 = new Tns.BusinessCenterCt(); { businessCenters1.Value = "GBLO"; businessCenters.BusinessCenters.Add(businessCenters1); } var businessCenters2 = new Tns.BusinessCenterCt(); { businessCenters2.Value = "USNY"; businessCenters.BusinessCenters.Add(businessCenters2); } dateAdjustments1.BusinessCenters = businessCenters; } adjustableDate.DateAdjustments = dateAdjustments1; } product.GeneralTerms.ScheduledTerminationDate.AdjustableDate = adjustableDate; } product.GeneralTerms.SellerPartyReference.Href = "partyA"; product.GeneralTerms.BuyerPartyReference.Href = "partyB"; { var dateAdjustments1 = new Tns.BusinessDayAdjustmentsCt(); dateAdjustments1.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.MODFOLLOWING; { var businessCenters = new Tns.BusinessCentersCt(); var businessCenters1 = new Tns.BusinessCenterCt(); { businessCenters1.Value = "GBLO"; businessCenters.BusinessCenters.Add(businessCenters1); } var businessCenters2 = new Tns.BusinessCenterCt(); { businessCenters2.Value = "USNY"; businessCenters.BusinessCenters.Add(businessCenters2); } dateAdjustments1.BusinessCenters = businessCenters; } product.GeneralTerms.DateAdjustments = dateAdjustments1; } product.GeneralTerms.ReferenceInformation.ReferenceEntity.Id = "referenceEntity"; { var entityName = new Tns.EntityNameCt(); entityName.Value = "Republic of Bulgaria"; product.GeneralTerms.ReferenceInformation.ReferenceEntity.EntityName = entityName; } var entityIds = new Tns.EntityIdCt(); { entityIds.EntityIdScheme = "http://www.fpml.org/spec/2003/entity-id-RED-1-0"; entityIds.Value = "1D216P"; product.GeneralTerms.ReferenceInformation.ReferenceEntity.EntityIds.Add(entityIds); } var referenceObligations = new Tns.ReferenceObligationCt(); { { var bond = new Tns.BondElm(); bond.CouponRate = BigDecimal.Parse("0.075"); bond.Maturity = new LxDateTime(LxDateTimeType.Date, 2013, 1, 15, 0, 0, 0, 0, 0, 0, false); var instrumentIds = new Tns.InstrumentIdCt(); { instrumentIds.InstrumentIdScheme = "http://www.fpml.org/spec/2002/instrument-id-ISIN-1-0"; instrumentIds.Value = "XS0145624432"; bond.InstrumentIds.Add(instrumentIds); } referenceObligations.Bond = bond; } { var primaryObligorReference = new Tns.LegalEntityReferenceCt(); primaryObligorReference.Href = "referenceEntity"; referenceObligations.PrimaryObligorReference = primaryObligorReference; } product.GeneralTerms.ReferenceInformation.ReferenceObligations.Add(referenceObligations); } product.GeneralTerms.ReferenceInformation.ReferencePrice = BigDecimal.Parse("1"); { var periodicPayment = new Tns.PeriodicPaymentCt(); periodicPayment.PaymentFrequency.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); periodicPayment.PaymentFrequency.Period = Tns.PeriodEnumEnum.M; periodicPayment.FirstPaymentDate = new LxDateTime(LxDateTimeType.Date, 2002, 10, 11, 0, 0, 0, 0, 0, 0, false); periodicPayment.RollConvention = Tns.RollConventionEnumEnum.N11; { var fixedAmountCalculation = new Tns.FixedAmountCalculationCt(); { var calculationAmount = new Tns.MoneyCt(); calculationAmount.Currency.Value = "USD"; calculationAmount.Amount = BigDecimal.Parse("5000000"); fixedAmountCalculation.CalculationAmount = calculationAmount; } fixedAmountCalculation.FixedRate = BigDecimal.Parse("0.0027"); fixedAmountCalculation.DayCountFraction = Tns.DayCountFractionEnumEnum.ACT_360; periodicPayment.FixedAmountCalculation = fixedAmountCalculation; } product.FeeLeg.PeriodicPayment = periodicPayment; } product.ProtectionTerms.CalculationAmount.Currency.Value = "USD"; product.ProtectionTerms.CalculationAmount.Amount = BigDecimal.Parse("5000000"); { var creditEvents = new Tns.CreditEventsCt(); { var failureToPay = new Tns.FailureToPayCt(); { var paymentRequirement = new Tns.MoneyCt(); paymentRequirement.Currency.Value = "USD"; paymentRequirement.Amount = BigDecimal.Parse("1000000"); failureToPay.PaymentRequirement = paymentRequirement; } creditEvents.FailureToPay = failureToPay; } { var obligationAcceleration = new Tns.EmptyCt(); creditEvents.ObligationAcceleration = obligationAcceleration; } { var repudiationMoratorium = new Tns.EmptyCt(); creditEvents.RepudiationMoratorium = repudiationMoratorium; } { var restructuring = new Tns.RestructuringCt(); { var restructuringType = new Tns.RestructuringTypeCt(); restructuringType.Value = "R"; restructuring.RestructuringType = restructuringType; } creditEvents.Restructuring = restructuring; } { var defaultRequirement = new Tns.MoneyCt(); defaultRequirement.Currency.Value = "USD"; defaultRequirement.Amount = BigDecimal.Parse("10000000"); creditEvents.DefaultRequirement = defaultRequirement; } { var creditEventNotice = new Tns.CreditEventNoticeCt(); creditEventNotice.NotifyingParty.BuyerPartyReference.Href = "partyB"; { var sellerPartyReference = new Tns.PartyReferenceCt(); sellerPartyReference.Href = "partyA"; creditEventNotice.NotifyingParty.SellerPartyReference = sellerPartyReference; } { var publiclyAvailableInformation = new Tns.PubliclyAvailableInformationCt(); { var standardPublicSources = new Tns.EmptyCt(); publiclyAvailableInformation.StandardPublicSources = standardPublicSources; } publiclyAvailableInformation.SpecifiedNumber = System.Numerics.BigInteger.Parse("2"); creditEventNotice.PubliclyAvailableInformation = publiclyAvailableInformation; } creditEvents.CreditEventNotice = creditEventNotice; } product.ProtectionTerms.CreditEvents = creditEvents; } { var obligations = new Tns.ObligationsCt(); obligations.Category = Tns.ObligationCategoryEnumEnum.Bond; { var notSubordinated = new Tns.EmptyCt(); obligations.NotSubordinated = notSubordinated; } { var notDomesticCurrency = new Tns.NotDomesticCurrencyCt(); obligations.NotDomesticCurrency = notDomesticCurrency; } { var notDomesticLaw = new Tns.EmptyCt(); obligations.NotDomesticLaw = notDomesticLaw; } { var notDomesticIssuance = new Tns.EmptyCt(); obligations.NotDomesticIssuance = notDomesticIssuance; } product.ProtectionTerms.Obligations = obligations; } { var physicalSettlementTerms = new Tns.PhysicalSettlementTermsCt(); { var physicalSettlementPeriod = new Tns.PhysicalSettlementPeriodCt(); { var businessDaysNotSpecified = new Tns.EmptyCt(); physicalSettlementPeriod.BusinessDaysNotSpecified = businessDaysNotSpecified; } physicalSettlementTerms.PhysicalSettlementPeriod = physicalSettlementPeriod; } physicalSettlementTerms.DeliverableObligations.AccruedInterest = false; physicalSettlementTerms.DeliverableObligations.Category = Tns.ObligationCategoryEnumEnum.Bond; { var notSubordinated = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.NotSubordinated = notSubordinated; } { var specifiedCurrency = new Tns.SpecifiedCurrencyCt(); physicalSettlementTerms.DeliverableObligations.SpecifiedCurrency = specifiedCurrency; } { var notDomesticLaw = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.NotDomesticLaw = notDomesticLaw; } { var notContingent = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.NotContingent = notContingent; } { var notDomesticIssuance = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.NotDomesticIssuance = notDomesticIssuance; } { var transferable = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.Transferable = transferable; } { var notBearer = new Tns.EmptyCt(); physicalSettlementTerms.DeliverableObligations.NotBearer = notBearer; } physicalSettlementTerms.Escrow = true; { var settlementCurrency = new Tns.CurrencyCt(); settlementCurrency.Value = "USD"; physicalSettlementTerms.SettlementCurrency = settlementCurrency; } product.PhysicalSettlementTerms = physicalSettlementTerms; } trades.Product = product; } { var calculationAgent = new Tns.CalculationAgentCt(); var calculationAgentPartyReferences = new Tns.PartyReferenceCt(); { calculationAgentPartyReferences.Href = "partyA"; calculationAgent.CalculationAgentPartyReferences.Add(calculationAgentPartyReferences); } trades.CalculationAgent = calculationAgent; } { var calculationAgentBusinessCenter = new Tns.BusinessCenterCt(); calculationAgentBusinessCenter.Value = "GBLO"; trades.CalculationAgentBusinessCenter = calculationAgentBusinessCenter; } { var documentation = new Tns.DocumentationCt(); { var masterAgreement = new Tns.MasterAgreementCt(); masterAgreement.MasterAgreementType.Value = "ISDA1992"; documentation.MasterAgreement = masterAgreement; } var contractualDefinitions = new Tns.ContractualDefinitionsCt(); { contractualDefinitions.Value = "ISDA1999Credit"; documentation.ContractualDefinitions.Add(contractualDefinitions); } var contractualSupplements = new Tns.ContractualSupplementCt(); { contractualSupplements.Value = "ISDA1999CreditConvertibleExchangeableAccretingObligations"; documentation.ContractualSupplements.Add(contractualSupplements); } trades.Documentation = documentation; } dataDocumentCt.Trades.Add(trades); } var parties = new Tns.PartyCt(); { parties.Id = "partyA"; parties.PartyId.Value = "XYZBICXXX"; parties.PartyName = "XYZ Bank"; dataDocumentCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "partyB"; parties1.PartyId.Value = "ABCBICXXX"; parties1.PartyName = "ABC Bank"; dataDocumentCt.Parties.Add(parties1); } dataDocumentCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.DataDocumentCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, dataDocumentCt); return writer.ToString(); } #endregion } } }
<?xml version="1.0" encoding="utf-8"?> <FpML version="4-0" xmlns="http://www.fpml.org/2003/FpML-4-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/2003/FpML-4-0 ../fpml-main-4-0.xsd" xsi:type="DataDocument"> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href="partyA" /> <tradeId tradeIdScheme="http://www.swapswire.com/spec/2001/trade-id-1-0">37261</tradeId> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href="partyB" /> <tradeId tradeIdScheme="http://www.swapswire.com/spec/2001/trade-id-1-0">37261</tradeId> </partyTradeIdentifier> <tradeDate>2002-07-11</tradeDate> </tradeHeader> <creditDefaultSwap> <generalTerms> <effectiveDate> <unadjustedDate>2002-07-11</unadjustedDate> <dateAdjustments> <businessDayConvention>NONE</businessDayConvention> </dateAdjustments> </effectiveDate> <scheduledTerminationDate> <adjustableDate> <unadjustedDate>2006-07-11</unadjustedDate> <dateAdjustments> <businessDayConvention>MODFOLLOWING</businessDayConvention> <businessCenters> <businessCenter>GBLO</businessCenter> <businessCenter>USNY</businessCenter> </businessCenters> </dateAdjustments> </adjustableDate> </scheduledTerminationDate> <sellerPartyReference href="partyA" /> <buyerPartyReference href="partyB" /> <dateAdjustments> <businessDayConvention>MODFOLLOWING</businessDayConvention> <businessCenters> <businessCenter>GBLO</businessCenter> <businessCenter>USNY</businessCenter> </businessCenters> </dateAdjustments> <referenceInformation> <referenceEntity id="referenceEntity"> <entityName>Republic of Bulgaria</entityName> <entityId entityIdScheme="http://www.fpml.org/spec/2003/entity-id-RED-1-0">1D216P</entityId> </referenceEntity> <referenceObligation> <bond> <instrumentId instrumentIdScheme="http://www.fpml.org/spec/2002/instrument-id-ISIN-1-0">XS0145624432</instrumentId> <couponRate>0.075</couponRate> <maturity>2013-01-15</maturity> </bond> <primaryObligorReference href="referenceEntity" /> </referenceObligation> <referencePrice>1.0</referencePrice> </referenceInformation> </generalTerms> <feeLeg> <periodicPayment> <paymentFrequency> <periodMultiplier>3</periodMultiplier> <period>M</period> </paymentFrequency> <firstPaymentDate>2002-10-11</firstPaymentDate> <rollConvention>11</rollConvention> <fixedAmountCalculation> <calculationAmount> <currency>USD</currency> <amount>5000000.0</amount> </calculationAmount> <fixedRate>0.0027</fixedRate> <dayCountFraction>ACT/360</dayCountFraction> </fixedAmountCalculation> </periodicPayment> </feeLeg> <protectionTerms> <calculationAmount> <currency>USD</currency> <amount>5000000.0</amount> </calculationAmount> <creditEvents> <failureToPay> <paymentRequirement> <currency>USD</currency> <amount>1000000.0</amount> </paymentRequirement> </failureToPay> <obligationAcceleration /> <repudiationMoratorium /> <restructuring> <restructuringType>R</restructuringType> </restructuring> <defaultRequirement> <currency>USD</currency> <amount>10000000.0</amount> </defaultRequirement> <creditEventNotice> <notifyingParty> <buyerPartyReference href="partyB" /> <sellerPartyReference href="partyA" /> </notifyingParty> <publiclyAvailableInformation> <standardPublicSources /> <specifiedNumber>2</specifiedNumber> </publiclyAvailableInformation> </creditEventNotice> </creditEvents> <obligations> <category>Bond</category> <notSubordinated /> <notDomesticCurrency /> <notDomesticLaw /> <notDomesticIssuance /> </obligations> </protectionTerms> <physicalSettlementTerms> <settlementCurrency>USD</settlementCurrency> <physicalSettlementPeriod> <businessDaysNotSpecified /> </physicalSettlementPeriod> <deliverableObligations> <accruedInterest>false</accruedInterest> <category>Bond</category> <notSubordinated /> <specifiedCurrency /> <notDomesticLaw /> <notContingent /> <notDomesticIssuance /> <transferable /> <notBearer /> </deliverableObligations> <escrow>true</escrow> </physicalSettlementTerms> </creditDefaultSwap> <calculationAgent> <calculationAgentPartyReference href="partyA" /> </calculationAgent> <calculationAgentBusinessCenter>GBLO</calculationAgentBusinessCenter> <documentation> <masterAgreement> <masterAgreementType>ISDA1992</masterAgreementType> </masterAgreement> <contractualDefinitions>ISDA1999Credit</contractualDefinitions> <contractualSupplement>ISDA1999CreditConvertibleExchangeableAccretingObligations</contractualSupplement> </documentation> </trade> <party id="partyA"> <partyId>XYZBICXXX</partyId> <partyName>XYZ Bank</partyName> </party> <party id="partyB"> <partyId>ABCBICXXX</partyId> <partyName>ABC Bank</partyName> </party> </FpML>
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var dataDocumentCt = new Tns.DataDocumentCt(); var trades = new Tns.TradeCt(); { var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "partyA"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.partyA.com/eqd-trade-id"; tradeIds.Value = "1234"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } trades.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2000, 6, 28, 0, 0, 0, 0, 0, 0, false); { var product = new Tns.EquityOptionElm(); product.BuyerPartyReference.Href = "partyB"; product.SellerPartyReference.Href = "partyA"; product.OptionType = Tns.OptionTypeEnumEnum.Call; { var singleUnderlyer = new Tns.SingleUnderlyerCt(); { var underlyingAsset = new Tns.IndexElm(); var relatedExchangeIds = new Tns.ExchangeIdCt(); { relatedExchangeIds.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; relatedExchangeIds.Value = "OSE"; underlyingAsset.RelatedExchangeIds.Add(relatedExchangeIds); } var instrumentIds = new Tns.InstrumentIdCt(); { instrumentIds.InstrumentIdScheme = "http://www.fpml.org/schemes/4.0/instrumentId"; instrumentIds.Value = ".N225"; underlyingAsset.InstrumentIds.Add(instrumentIds); } underlyingAsset.Description = "NIKKEI 225 INDEX"; { var exchangeId = new Tns.ExchangeIdCt(); exchangeId.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; exchangeId.Value = "TSE"; underlyingAsset.ExchangeId = exchangeId; } singleUnderlyer.UnderlyingAsset = underlyingAsset; } singleUnderlyer.OpenUnits = BigDecimal.Parse("1"); product.Underlyer.SingleUnderlyer = singleUnderlyer; } { var strike = new Tns.EquityStrikeCt(); strike.StrikePrice = BigDecimal.Parse("17475.9"); product.Strike = strike; } product.NumberOfOptions = BigDecimal.Parse("79.099093"); product.OptionEntitlement = BigDecimal.Parse("1"); { var equityEuropeanExercise = new Tns.EquityEuropeanExerciseCt(); { var adjustableDate = new Tns.AdjustableDateCt(); adjustableDate.UnadjustedDate.Value = new LxDateTime(LxDateTimeType.Date, 2002, 7, 1, 0, 0, 0, 0, 0, 0, false); adjustableDate.DateAdjustments.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NONE; equityEuropeanExercise.ExpirationDate.AdjustableDate = adjustableDate; } equityEuropeanExercise.EquityExpirationTimeType = Tns.TimeTypeEnumEnum.Close; product.EquityExercise.EquityEuropeanExercise = equityEuropeanExercise; } product.EquityExercise.AutomaticExerciseApplicable = true; product.EquityExercise.EquityValuation.ValuationTimeType = Tns.TimeTypeEnumEnum.Close; product.EquityExercise.SettlementCurrency.Value = "EUR"; product.EquityExercise.SettlementType = Tns.SettlementTypeEnumEnum.Cash; product.EquityExercise.FailureToDeliverApplicable = true; { var fxFeature = new Tns.FXFeatureCt(); fxFeature.FxFeatureType.Value = "Composite"; product.FxFeature = fxFeature; } { var equityOptionFeatures = new Tns.EquityOptionFeaturesCt(); { var asian = new Tns.AsianCt(); asian.AveragingInOut = Tns.AveragingInOutEnumEnum.In_; { var averagingPeriodIn = new Tns.EquityAveragingPeriodCt(); { var averagingDateTimes = new Tns.DateTimeListCt(); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2000, 8, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2000, 9, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2000, 10, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2000, 11, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2000, 12, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2001, 1, 4, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2001, 2, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingDateTimes.DateTimes.Add(new LxDateTime(LxDateTimeType.DateTime, 2001, 3, 1, 8, 57, 0, 0, 0, 0, 0, 0)); averagingPeriodIn.AveragingDateTimes = averagingDateTimes; } averagingPeriodIn.MarketDisruption.Value = "ModifiedPostponement"; asian.AveragingPeriodIn = averagingPeriodIn; } equityOptionFeatures.Asian = asian; } product.EquityOptionFeatures = equityOptionFeatures; } product.EquityPremium.PayerPartyReference.Href = "partyB"; product.EquityPremium.ReceiverPartyReference.Href = "partyA"; { var paymentAmount = new Tns.MoneyCt(); paymentAmount.Currency.Value = "EUR"; paymentAmount.Amount = BigDecimal.Parse("107821.57"); product.EquityPremium.PaymentAmount = paymentAmount; } { var paymentDate = new Tns.AdjustableDateCt(); paymentDate.UnadjustedDate.Value = new LxDateTime(LxDateTimeType.Date, 2000, 7, 3, 0, 0, 0, 0, 0, 0, false); paymentDate.DateAdjustments.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NONE; product.EquityPremium.PaymentDate = paymentDate; } product.EquityPremium.PricePerOption = BigDecimal.Parse("1363.1202"); product.MethodOfAdjustment = Tns.MethodOfAdjustmentEnumEnum.CalculationAgent; { var productType = new Tns.ProductTypeCt(); productType.Value = "europeanCallIndex"; product.ProductType = productType; } trades.Product = product; } { var calculationAgent = new Tns.CalculationAgentCt(); var calculationAgentPartyReferences = new Tns.PartyReferenceCt(); { calculationAgentPartyReferences.Href = "partyA"; calculationAgent.CalculationAgentPartyReferences.Add(calculationAgentPartyReferences); } trades.CalculationAgent = calculationAgent; } { var documentation = new Tns.DocumentationCt(); { var masterAgreement = new Tns.MasterAgreementCt(); masterAgreement.MasterAgreementType.Value = "ISDA2002"; documentation.MasterAgreement = masterAgreement; } var contractualDefinitions = new Tns.ContractualDefinitionsCt(); { contractualDefinitions.Value = "ISDA2000"; documentation.ContractualDefinitions.Add(contractualDefinitions); } var contractualDefinitions1 = new Tns.ContractualDefinitionsCt(); { contractualDefinitions1.Value = "ISDA1996Equity"; documentation.ContractualDefinitions.Add(contractualDefinitions1); } trades.Documentation = documentation; } { var governingLaw = new Tns.GoverningLawCt(); governingLaw.Value = "GBEN"; trades.GoverningLaw = governingLaw; } dataDocumentCt.Trades.Add(trades); } var parties = new Tns.PartyCt(); { parties.Id = "partyA"; parties.PartyId.Value = "Party A"; dataDocumentCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "partyB"; parties1.PartyId.Value = "Party B"; dataDocumentCt.Parties.Add(parties1); } dataDocumentCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.DataDocumentCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, dataDocumentCt); return writer.ToString(); } #endregion } } }
<?xml version="1.0" encoding="utf-8"?> <!-- == Copyright (c) 2002-2003. All rights reserved. == Financial Products Markup Language is subject to the FpML public license. == A copy of this license is available at http://www.fpml.org/documents/license --> <FpML version="4-0" xmlns="http://www.fpml.org/2003/FpML-4-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/2003/FpML-4-0 ../fpml-main-4-0.xsd http://www.w3.org/2000/09/xmldsig# xmldsig-core-schema.xsd" xsi:type="DataDocument"> <!-- Version 0.12, 24 Jan 2002 --> <!-- fpml-4-0-eqd-gs-european-call-index.xml --> <!-- Version 0.13, 28 Jan 2002 --> <!-- 1. revised following updates to eqd DTD on 24 Jan 2002 --> <!-- 2. update using FpML 2.0 LCWD samples as a template --> <!-- Version 0.14, 29 Jan 2002 --> <!-- 1. Confirm data population prior to distribution --> <!-- MSDW confirm --> <!-- AP Version 0.30 30 October 2002 --> <!-- AP Version 0.31 01 November 2002 --> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href="partyA" /> <tradeId tradeIdScheme="http://www.partyA.com/eqd-trade-id">1234</tradeId> </partyTradeIdentifier> <tradeDate>2000-06-28</tradeDate> </tradeHeader> <equityOption> <productType>europeanCallIndex</productType> <buyerPartyReference href="partyB" /> <sellerPartyReference href="partyA" /> <optionType>Call</optionType> <!-- AP 18 Nov 02 move to underlyer <underlying> <description>NIKKEI 225 INDEX</description> <instrumentId instrumentIdScheme="">.N225</instrumentId> <exchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/ExchangeID">Tokyo Stock Exchange</exchangeId> <relatedExchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/ExchangeID">Osaka Securities Exchange</relatedExchangeId> </underlying> --> <underlyer> <singleUnderlyer> <index> <instrumentId instrumentIdScheme="http://www.fpml.org/schemes/4.0/instrumentId">.N225</instrumentId> <description>NIKKEI 225 INDEX</description> <exchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">TSE</exchangeId> <relatedExchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">OSE</relatedExchangeId> </index> <openUnits>1</openUnits> </singleUnderlyer> </underlyer> <strike> <strikePrice>17475.90</strikePrice> </strike> <numberOfOptions>79.099093</numberOfOptions> <optionEntitlement>1.00</optionEntitlement> <equityExercise> <equityEuropeanExercise> <expirationDate> <adjustableDate> <unadjustedDate>2002-07-01</unadjustedDate> <dateAdjustments> <businessDayConvention>NONE</businessDayConvention> </dateAdjustments> </adjustableDate> </expirationDate> <equityExpirationTimeType>Close</equityExpirationTimeType> </equityEuropeanExercise> <automaticExerciseApplicable>true</automaticExerciseApplicable> <equityValuation> <valuationTimeType>Close</valuationTimeType> </equityValuation> <settlementCurrency>EUR</settlementCurrency> <!-- settlementPriceSource made optional in the case of Asians. JS. 17/5/02 SCB+++ --> <!-- Verify scheme name JS 17/5/02 --> <settlementType>Cash</settlementType> <failureToDeliverApplicable>true</failureToDeliverApplicable> </equityExercise> <fxFeature> <fxFeatureType>Composite</fxFeatureType> </fxFeature> <equityOptionFeatures> <asian> <!-- Scheme name needs verification JS 17/5/02 SCB+++ --> <averagingInOut>In</averagingInOut> <averagingPeriodIn> <averagingDateTimes> <dateTime>2000-08-01T08:57:00-00:00</dateTime> <dateTime>2000-09-01T08:57:00-00:00</dateTime> <dateTime>2000-10-01T08:57:00-00:00</dateTime> <dateTime>2000-11-01T08:57:00-00:00</dateTime> <dateTime>2000-12-01T08:57:00-00:00</dateTime> <dateTime>2001-01-04T08:57:00-00:00</dateTime> <dateTime>2001-02-01T08:57:00-00:00</dateTime> <dateTime>2001-03-01T08:57:00-00:00</dateTime> </averagingDateTimes> <marketDisruption>ModifiedPostponement</marketDisruption> </averagingPeriodIn> </asian> </equityOptionFeatures> <equityPremium> <payerPartyReference href="partyB" /> <receiverPartyReference href="partyA" /> <paymentAmount> <currency>EUR</currency> <amount>107821.57</amount> </paymentAmount> <paymentDate> <unadjustedDate>2000-07-03</unadjustedDate> <dateAdjustments> <businessDayConvention>NONE</businessDayConvention> </dateAdjustments> </paymentDate> <pricePerOption>1363.1202</pricePerOption> </equityPremium> <methodOfAdjustment>CalculationAgent</methodOfAdjustment> </equityOption> <calculationAgent> <calculationAgentPartyReference href="partyA" /> </calculationAgent> <documentation> <masterAgreement> <masterAgreementType>ISDA2002</masterAgreementType> </masterAgreement> <contractualDefinitions>ISDA2000</contractualDefinitions> <contractualDefinitions>ISDA1996Equity</contractualDefinitions> </documentation> <governingLaw>GBEN</governingLaw> </trade> <party id="partyA"> <partyId>Party A</partyId> </party> <party id="partyB"> <partyId>Party B</partyId> </party> </FpML>
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var dataDocumentCt = new Tns.DataDocumentCt(); var trades = new Tns.TradeCt(); { var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "partyA"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.partyA.com/eqd-trade-id"; tradeIds.Value = "1234"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } trades.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2000, 6, 28, 0, 0, 0, 0, 0, 0, false); { var calculationAgent = new Tns.CalculationAgentCt(); var calculationAgentPartyReferences = new Tns.PartyReferenceCt(); { calculationAgentPartyReferences.Href = "partyA"; calculationAgent.CalculationAgentPartyReferences.Add(calculationAgentPartyReferences); } trades.CalculationAgent = calculationAgent; } { var documentation = new Tns.DocumentationCt(); { var masterAgreement = new Tns.MasterAgreementCt(); masterAgreement.MasterAgreementType.Value = "ISDA2002"; documentation.MasterAgreement = masterAgreement; } var contractualDefinitions = new Tns.ContractualDefinitionsCt(); { contractualDefinitions.Value = "ISDA2000"; documentation.ContractualDefinitions.Add(contractualDefinitions); } var contractualDefinitions1 = new Tns.ContractualDefinitionsCt(); { contractualDefinitions1.Value = "ISDA1996Equity"; documentation.ContractualDefinitions.Add(contractualDefinitions1); } trades.Documentation = documentation; } { var governingLaw = new Tns.GoverningLawCt(); governingLaw.Value = "GBEN"; trades.GoverningLaw = governingLaw; } dataDocumentCt.Trades.Add(trades); } var parties = new Tns.PartyCt(); { parties.Id = "partyA"; parties.PartyId.Value = "Party A"; dataDocumentCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "partyB"; parties1.PartyId.Value = "Party B"; dataDocumentCt.Parties.Add(parties1); } dataDocumentCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.DataDocumentCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, dataDocumentCt); return writer.ToString(); } #endregion } } }
<?xml version="1.0"?> <FpML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="DataDocument" version="4-0" xmlns="http://www.fpml.org/2003/FpML-4-0"> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href="partyA" /> <tradeId tradeIdScheme="http://www.partyA.com/eqd-trade-id">1234</tradeId> </partyTradeIdentifier> <tradeDate>2000-06-28</tradeDate> </tradeHeader> <calculationAgent> <calculationAgentPartyReference href="partyA" /> </calculationAgent> <documentation> <masterAgreement> <masterAgreementType>ISDA2002</masterAgreementType> </masterAgreement> <contractualDefinitions>ISDA2000</contractualDefinitions> <contractualDefinitions>ISDA1996Equity</contractualDefinitions> </documentation> <governingLaw>GBEN</governingLaw> </trade> <party id="partyA"> <partyId>Party A</partyId> </party> <party id="partyB"> <partyId>Party B</partyId> </party> </FpML>
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var dataDocumentCt = new Tns.DataDocumentCt(); var trades = new Tns.TradeCt(); { var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "PartyA"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.partyA.com/eqs-trade-id"; tradeIds.Value = "1734"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } var partyTradeIdentifiers1 = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers1.PartyReference.Href = "PartyB"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.partyB.com/eqs-trade-id"; tradeIds.Value = "5648"; partyTradeIdentifiers1.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers1); } trades.TradeHeader.TradeDate.Id = "TradeDate"; trades.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2002, 7, 19, 0, 0, 0, 0, 0, 0, false); { var product = new Tns.EquitySwapElm(); var equityLegs = new Tns.EquityLegCt(); { equityLegs.PayerPartyReference.Href = "PartyA"; equityLegs.ReceiverPartyReference.Href = "PartyB"; equityLegs.EffectiveDate.Id = "EffectiveDate"; { var relativeDate = new Tns.RelativeDateOffsetCt(); relativeDate.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; relativeDate.DateRelativeTo.Href = "TradeDate"; relativeDate.DayType = Tns.DayTypeEnumEnum.ExchangeBusiness; relativeDate.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); relativeDate.Period = Tns.PeriodEnumEnum.D; equityLegs.EffectiveDate.RelativeDate = relativeDate; } equityLegs.TerminationDate.Id = "TerminationDate"; { var relativeDate1 = new Tns.RelativeDateOffsetCt(); relativeDate1.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; relativeDate1.DateRelativeTo.Href = "FinalEquityPaymentDate"; relativeDate1.PeriodMultiplier = System.Numerics.BigInteger.Parse("0"); relativeDate1.Period = Tns.PeriodEnumEnum.D; equityLegs.TerminationDate.RelativeDate = relativeDate1; } { var basket = new Tns.BasketCt(); basket.OpenUnits = BigDecimal.Parse("1"); var basketConstituents = new Tns.BasketConstituentCt(); { { var underlyingAsset = new Tns.IndexElm(); var relatedExchangeIds = new Tns.ExchangeIdCt(); { relatedExchangeIds.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; relatedExchangeIds.Value = "MATIF"; underlyingAsset.RelatedExchangeIds.Add(relatedExchangeIds); } var relatedExchangeIds1 = new Tns.ExchangeIdCt(); { relatedExchangeIds1.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; relatedExchangeIds1.Value = "MONEP"; underlyingAsset.RelatedExchangeIds.Add(relatedExchangeIds1); } var instrumentIds = new Tns.InstrumentIdCt(); { instrumentIds.InstrumentIdScheme = "RIC"; instrumentIds.Value = ".FCHI"; underlyingAsset.InstrumentIds.Add(instrumentIds); } underlyingAsset.Description = "France CAC 40 Index"; { var currency = new Tns.CurrencyCt(); currency.Value = "EUR"; underlyingAsset.Currency = currency; } { var exchangeId = new Tns.ExchangeIdCt(); exchangeId.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; exchangeId.Value = "EuroNext"; underlyingAsset.ExchangeId = exchangeId; } basketConstituents.UnderlyingAsset = underlyingAsset; } { var constituentWeight = new Tns.ConstituentWeightCt(); constituentWeight.OpenUnits = BigDecimal.Parse("960"); basketConstituents.ConstituentWeight = constituentWeight; } basket.BasketConstituents.Add(basketConstituents); } var basketConstituents1 = new Tns.BasketConstituentCt(); { { var underlyingAsset = new Tns.IndexElm(); var relatedExchangeIds = new Tns.ExchangeIdCt(); { relatedExchangeIds.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; relatedExchangeIds.Value = "MEFF"; underlyingAsset.RelatedExchangeIds.Add(relatedExchangeIds); } var instrumentIds = new Tns.InstrumentIdCt(); { instrumentIds.InstrumentIdScheme = "http://www.fpml.org/spec/2003/instrument-id-Reuters-RIC-1-0"; instrumentIds.Value = ".IBEX"; underlyingAsset.InstrumentIds.Add(instrumentIds); } underlyingAsset.Description = "IBEX 35"; { var currency = new Tns.CurrencyCt(); currency.Value = "EUR"; underlyingAsset.Currency = currency; } basketConstituents1.UnderlyingAsset = underlyingAsset; } { var constituentWeight = new Tns.ConstituentWeightCt(); constituentWeight.OpenUnits = BigDecimal.Parse("260"); basketConstituents1.ConstituentWeight = constituentWeight; } basket.BasketConstituents.Add(basketConstituents1); } var basketConstituents2 = new Tns.BasketConstituentCt(); { { var underlyingAsset = new Tns.IndexElm(); var instrumentIds = new Tns.InstrumentIdCt(); { instrumentIds.InstrumentIdScheme = "http://www.fpml.org/spec/2003/instrument-id-Reuters-RIC-1-0"; instrumentIds.Value = ".HSI"; underlyingAsset.InstrumentIds.Add(instrumentIds); } underlyingAsset.Description = "Hong Kong Hang Seng Index"; { var currency = new Tns.CurrencyCt(); currency.Value = "HKD"; underlyingAsset.Currency = currency; } { var exchangeId = new Tns.ExchangeIdCt(); exchangeId.ExchangeIdScheme = "http://www.fpml.org/schemes/4.0/exchangeId"; exchangeId.Value = "Hong Kong Stock Exchange"; underlyingAsset.ExchangeId = exchangeId; } basketConstituents2.UnderlyingAsset = underlyingAsset; } { var constituentWeight = new Tns.ConstituentWeightCt(); constituentWeight.OpenUnits = BigDecimal.Parse("580"); basketConstituents2.ConstituentWeight = constituentWeight; } basket.BasketConstituents.Add(basketConstituents2); } equityLegs.Underlyer.Basket = basket; } { var netPrice = new Tns.ActualPriceCt(); { var currency = new Tns.CurrencyCt(); currency.Value = "USD"; netPrice.Currency = currency; } netPrice.Amount = BigDecimal.Parse("5591987.41"); netPrice.PriceExpression = Tns.PriceExpressionEnumEnum.AbsoluteTerms; equityLegs.Valuation.InitialPrice.NetPrice = netPrice; } equityLegs.Valuation.EquityNotionalReset = true; { var valuationPriceInterim = new Tns.EquitySwapValuationCt.ValuationPriceInterimElm(); valuationPriceInterim.ValuationTimeType = Tns.TimeTypeEnumEnum.Close; valuationPriceInterim.EquityValuationDates.Id = "InterimValuationDate"; { var adjustableDates = new Tns.AdjustableDatesCt(); var unadjustedDates = new Tns.AdjustableDatesCt.UnadjustedDateElm(); { unadjustedDates.Value = new LxDateTime(LxDateTimeType.Date, 2002, 10, 21, 0, 0, 0, 0, 0, 0, false); adjustableDates.UnadjustedDates.Add(unadjustedDates); } var unadjustedDates1 = new Tns.AdjustableDatesCt.UnadjustedDateElm(); { unadjustedDates1.Value = new LxDateTime(LxDateTimeType.Date, 2003, 1, 20, 0, 0, 0, 0, 0, 0, false); adjustableDates.UnadjustedDates.Add(unadjustedDates1); } var unadjustedDates2 = new Tns.AdjustableDatesCt.UnadjustedDateElm(); { unadjustedDates2.Value = new LxDateTime(LxDateTimeType.Date, 2003, 4, 22, 0, 0, 0, 0, 0, 0, false); adjustableDates.UnadjustedDates.Add(unadjustedDates2); } adjustableDates.DateAdjustments.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; valuationPriceInterim.EquityValuationDates.AdjustableDates = adjustableDates; } valuationPriceInterim.DeterminationMethod = "PublishedIndexAtValuationTime"; equityLegs.Valuation.ValuationPriceInterim = valuationPriceInterim; } equityLegs.Valuation.ValuationPriceFinal.EquityValuationDate.Id = "FinalValuationDate"; { var adjustableDate = new Tns.AdjustableDateCt(); adjustableDate.UnadjustedDate.Value = new LxDateTime(LxDateTimeType.Date, 2003, 7, 21, 0, 0, 0, 0, 0, 0, false); adjustableDate.DateAdjustments.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; equityLegs.Valuation.ValuationPriceFinal.EquityValuationDate.AdjustableDate = adjustableDate; } equityLegs.Valuation.ValuationPriceFinal.DeterminationMethod = "HedgeUnwind"; equityLegs.Valuation.EquityPaymentDates.Id = "EquityPaymentDate"; { var equityPaymentDatesInterim = new Tns.AdjustableOrRelativeDatesCt(); equityPaymentDatesInterim.Id = "InterimEquityPaymentDate"; { var relativeDates = new Tns.RelativeDatesCt(); relativeDates.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.FOLLOWING; { var businessCenters = new Tns.BusinessCentersCt(); businessCenters.Id = "PrimaryBusinessCenter"; var businessCenters1 = new Tns.BusinessCenterCt(); { businessCenters1.Value = "EUTA"; businessCenters.BusinessCenters.Add(businessCenters1); } var businessCenters2 = new Tns.BusinessCenterCt(); { businessCenters2.Value = "HKHK"; businessCenters.BusinessCenters.Add(businessCenters2); } relativeDates.BusinessCenters = businessCenters; } relativeDates.DateRelativeTo.Href = "InterimValuationDate"; relativeDates.DayType = Tns.DayTypeEnumEnum.CurrencyBusiness; relativeDates.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); relativeDates.Period = Tns.PeriodEnumEnum.D; equityPaymentDatesInterim.RelativeDates = relativeDates; } equityLegs.Valuation.EquityPaymentDates.EquityPaymentDatesInterim = equityPaymentDatesInterim; } equityLegs.Valuation.EquityPaymentDates.EquityPaymentDateFinal.Id = "FinalEquityPaymentDate"; { var relativeDate2 = new Tns.RelativeDateOffsetCt(); relativeDate2.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.FOLLOWING; { var businessCentersReference = new Tns.BusinessCentersReferenceCt(); businessCentersReference.Href = "PrimaryBusinessCenter"; relativeDate2.BusinessCentersReference = businessCentersReference; } relativeDate2.DateRelativeTo.Href = "FinalValuationDate"; relativeDate2.DayType = Tns.DayTypeEnumEnum.CurrencyBusiness; relativeDate2.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); relativeDate2.Period = Tns.PeriodEnumEnum.D; equityLegs.Valuation.EquityPaymentDates.EquityPaymentDateFinal.RelativeDate = relativeDate2; } equityLegs.Notional.Id = "EquityNotionalAmount"; { var notionalAmount = new Tns.MoneyCt(); notionalAmount.Currency.Value = "USD"; notionalAmount.Amount = BigDecimal.Parse("5591987.41"); equityLegs.Notional.NotionalAmount = notionalAmount; } equityLegs.EquityAmount.CashSettlement = true; equityLegs.EquityAmount.PaymentCurrency.Href = "ReferenceCurrency"; { var referenceAmount = new Tns.LegAmountCt.ReferenceAmountElm(); referenceAmount.Value = "Standard ISDA"; equityLegs.EquityAmount.ReferenceAmount = referenceAmount; } equityLegs.Return_.ReturnType = Tns.ReturnTypeEnumEnum.Price; equityLegs.NotionalAdjustments = Tns.NotionalAdjustmentEnumEnum.Standard; { var fxTerms = new Tns.EquityLegCt.FxTermsElm(); { var quanto = new Tns.EquityLegCt.FxTermsElm.QuantoElm(); quanto.ReferenceCurrency.Id = "ReferenceCurrency"; quanto.ReferenceCurrency.Value = "USD"; var fxRates = new Tns.FxRateCt(); { fxRates.QuotedCurrencyPair.Currency1.Value = "USD"; fxRates.QuotedCurrencyPair.Currency2.Value = "EUR"; fxRates.QuotedCurrencyPair.QuoteBasis = Tns.QuoteBasisEnumEnum.Currency2PerCurrency1; fxRates.Rate = BigDecimal.Parse("0.9914"); quanto.FxRates.Add(fxRates); } var fxRates1 = new Tns.FxRateCt(); { fxRates1.QuotedCurrencyPair.Currency1.Value = "USD"; fxRates1.QuotedCurrencyPair.Currency2.Value = "HKD"; fxRates1.QuotedCurrencyPair.QuoteBasis = Tns.QuoteBasisEnumEnum.Currency2PerCurrency1; fxRates1.Rate = BigDecimal.Parse("7.8"); quanto.FxRates.Add(fxRates1); } fxTerms.Quanto = quanto; } equityLegs.FxTerms = fxTerms; } product.EquityLegs.Add(equityLegs); } var interestLegs = new Tns.InterestLegCt(); { interestLegs.PayerPartyReference.Href = "PartyB"; interestLegs.ReceiverPartyReference.Href = "PartyA"; interestLegs.InterestLegCalculationPeriodDates.Id = "InterestLegPeriodDates"; { var relativeDate = new Tns.RelativeDateOffsetCt(); relativeDate.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; relativeDate.DateRelativeTo.Href = "TradeDate"; relativeDate.DayType = Tns.DayTypeEnumEnum.ExchangeBusiness; relativeDate.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); relativeDate.Period = Tns.PeriodEnumEnum.D; interestLegs.InterestLegCalculationPeriodDates.EffectiveDate.RelativeDate = relativeDate; } { var relativeDate1 = new Tns.RelativeDateOffsetCt(); relativeDate1.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; relativeDate1.DateRelativeTo.Href = "FinalEquityPaymentDate"; relativeDate1.PeriodMultiplier = System.Numerics.BigInteger.Parse("0"); relativeDate1.Period = Tns.PeriodEnumEnum.D; interestLegs.InterestLegCalculationPeriodDates.TerminationDate.RelativeDate = relativeDate1; } interestLegs.InterestLegCalculationPeriodDates.InterestLegResetDates.CalculationPeriodDatesReference.Href = "InterestLegPeriodDates"; interestLegs.InterestLegCalculationPeriodDates.InterestLegResetDates.ResetRelativeTo = Tns.ResetRelativeToEnumEnum.CalculationPeriodStartDate; { var relativeDates = new Tns.RelativeDatesCt(); relativeDates.BusinessDayConvention = Tns.BusinessDayConventionEnumEnum.NotApplicable; relativeDates.DateRelativeTo.Href = "EquityPaymentDate"; relativeDates.PeriodMultiplier = System.Numerics.BigInteger.Parse("0"); relativeDates.Period = Tns.PeriodEnumEnum.D; interestLegs.InterestLegCalculationPeriodDates.InterestLegPaymentDates.RelativeDates = relativeDates; } { var amountRelativeTo = new Tns.AmountRelativeToCt(); amountRelativeTo.Href = "EquityNotionalAmount"; amountRelativeTo.Value = ""; interestLegs.Notional.AmountRelativeTo = amountRelativeTo; } interestLegs.InterestAmount.PaymentCurrency.Href = "ReferenceCurrency"; { var referenceAmount = new Tns.LegAmountCt.ReferenceAmountElm(); referenceAmount.Value = "Standard ISDA"; interestLegs.InterestAmount.ReferenceAmount = referenceAmount; } { var floatingRateCalculation = new Tns.FloatingRateCalculationCt(); floatingRateCalculation.FloatingRateIndex.Value = "USD-LIBOR-Telerate"; { var indexTenor = new Tns.IntervalCt(); indexTenor.PeriodMultiplier = System.Numerics.BigInteger.Parse("3"); indexTenor.Period = Tns.PeriodEnumEnum.M; floatingRateCalculation.IndexTenor = indexTenor; } { var spreadSchedule = new Tns.ScheduleCt(); spreadSchedule.InitialValue = BigDecimal.Parse("-0.0022"); floatingRateCalculation.SpreadSchedule = spreadSchedule; } interestLegs.InterestCalculation.FloatingRateCalculation = floatingRateCalculation; } interestLegs.InterestCalculation.DayCountFraction = Tns.DayCountFractionEnumEnum.ACT_360; product.InterestLegs.Add(interestLegs); } { var productType = new Tns.ProductTypeCt(); productType.Value = "IndexQuantoSwap"; product.ProductType = productType; } trades.Product = product; } { var calculationAgent = new Tns.CalculationAgentCt(); var calculationAgentPartyReferences = new Tns.PartyReferenceCt(); { calculationAgentPartyReferences.Href = "PartyA"; calculationAgent.CalculationAgentPartyReferences.Add(calculationAgentPartyReferences); } trades.CalculationAgent = calculationAgent; } { var documentation = new Tns.DocumentationCt(); { var masterAgreement = new Tns.MasterAgreementCt(); masterAgreement.MasterAgreementType.Value = "ISDA2002"; documentation.MasterAgreement = masterAgreement; } var contractualDefinitions = new Tns.ContractualDefinitionsCt(); { contractualDefinitions.Value = "ISDA2000"; documentation.ContractualDefinitions.Add(contractualDefinitions); } var contractualDefinitions1 = new Tns.ContractualDefinitionsCt(); { contractualDefinitions1.Value = "ISDA1996Equity"; documentation.ContractualDefinitions.Add(contractualDefinitions1); } trades.Documentation = documentation; } { var governingLaw = new Tns.GoverningLawCt(); governingLaw.Value = "GBEN"; trades.GoverningLaw = governingLaw; } dataDocumentCt.Trades.Add(trades); } var parties = new Tns.PartyCt(); { parties.Id = "PartyA"; parties.PartyId.Value = "Party A"; dataDocumentCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "PartyB"; parties1.PartyId.Value = "Party B"; dataDocumentCt.Parties.Add(parties1); } dataDocumentCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.DataDocumentCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, dataDocumentCt); return writer.ToString(); } #endregion } } }
<?xml version="1.0" encoding="utf-8"?> <!-- Created with Liquid XML Objects - Registered to 'Test20130115 ' - https://www.liquid-technologies.com/xml-objects --> <FpML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DataDocument" version="4-0" xmlns="http://www.fpml.org/2003/FpML-4-0"> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href="PartyA" /> <tradeId tradeIdScheme="http://www.partyA.com/eqs-trade-id">1734</tradeId> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href="PartyB" /> <tradeId tradeIdScheme="http://www.partyB.com/eqs-trade-id">5648</tradeId> </partyTradeIdentifier> <tradeDate id="TradeDate">2002-07-19</tradeDate> </tradeHeader> <equitySwap> <productType>IndexQuantoSwap</productType> <equityLeg> <payerPartyReference href="PartyA" /> <receiverPartyReference href="PartyB" /> <effectiveDate id="EffectiveDate"> <relativeDate> <periodMultiplier>3</periodMultiplier> <period>D</period> <dayType>ExchangeBusiness</dayType> <businessDayConvention>NotApplicable</businessDayConvention> <dateRelativeTo href="TradeDate" /> </relativeDate> </effectiveDate> <terminationDate id="TerminationDate"> <relativeDate> <periodMultiplier>0</periodMultiplier> <period>D</period> <businessDayConvention>NotApplicable</businessDayConvention> <dateRelativeTo href="FinalEquityPaymentDate" /> </relativeDate> </terminationDate> <underlyer> <basket> <openUnits>1</openUnits> <basketConstituent> <index> <instrumentId instrumentIdScheme="RIC">.FCHI</instrumentId> <description>France CAC 40 Index</description> <currency>EUR</currency> <exchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">EuroNext</exchangeId> <relatedExchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">MATIF</relatedExchangeId> <relatedExchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">MONEP</relatedExchangeId> </index> <constituentWeight> <openUnits>960</openUnits> </constituentWeight> </basketConstituent> <basketConstituent> <index> <instrumentId instrumentIdScheme="http://www.fpml.org/spec/2003/instrument-id-Reuters-RIC-1-0">.IBEX</instrumentId> <description>IBEX 35</description> <currency>EUR</currency> <relatedExchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">MEFF</relatedExchangeId> </index> <constituentWeight> <openUnits>260</openUnits> </constituentWeight> </basketConstituent> <basketConstituent> <index> <instrumentId instrumentIdScheme="http://www.fpml.org/spec/2003/instrument-id-Reuters-RIC-1-0">.HSI</instrumentId> <description>Hong Kong Hang Seng Index</description> <currency>HKD</currency> <exchangeId exchangeIdScheme="http://www.fpml.org/schemes/4.0/exchangeId">Hong Kong Stock Exchange</exchangeId> </index> <constituentWeight> <openUnits>580</openUnits> </constituentWeight> </basketConstituent> </basket> </underlyer> <valuation> <initialPrice> <netPrice> <currency>USD</currency> <amount>5591987.41</amount> <priceExpression>AbsoluteTerms</priceExpression> </netPrice> </initialPrice> <equityNotionalReset>true</equityNotionalReset> <valuationPriceInterim> <determinationMethod>PublishedIndexAtValuationTime</determinationMethod> <valuationTimeType>Close</valuationTimeType> <equityValuationDates id="InterimValuationDate"> <adjustableDates> <unadjustedDate>2002-10-21</unadjustedDate> <unadjustedDate>2003-01-20</unadjustedDate> <unadjustedDate>2003-04-22</unadjustedDate> <dateAdjustments> <businessDayConvention>NotApplicable</businessDayConvention> </dateAdjustments> </adjustableDates> </equityValuationDates> </valuationPriceInterim> <valuationPriceFinal> <determinationMethod>HedgeUnwind</determinationMethod> <equityValuationDate id="FinalValuationDate"> <adjustableDate> <unadjustedDate>2003-07-21</unadjustedDate> <dateAdjustments> <businessDayConvention>NotApplicable</businessDayConvention> </dateAdjustments> </adjustableDate> </equityValuationDate> </valuationPriceFinal> <equityPaymentDates id="EquityPaymentDate"> <equityPaymentDatesInterim id="InterimEquityPaymentDate"> <relativeDates> <periodMultiplier>3</periodMultiplier> <period>D</period> <dayType>CurrencyBusiness</dayType> <businessDayConvention>FOLLOWING</businessDayConvention> <businessCenters id="PrimaryBusinessCenter"> <businessCenter>EUTA</businessCenter> <businessCenter>HKHK</businessCenter> </businessCenters> <dateRelativeTo href="InterimValuationDate" /> </relativeDates> </equityPaymentDatesInterim> <equityPaymentDateFinal id="FinalEquityPaymentDate"> <relativeDate> <periodMultiplier>3</periodMultiplier> <period>D</period> <dayType>CurrencyBusiness</dayType> <businessDayConvention>FOLLOWING</businessDayConvention> <businessCentersReference href="PrimaryBusinessCenter" /> <dateRelativeTo href="FinalValuationDate" /> </relativeDate> </equityPaymentDateFinal> </equityPaymentDates> </valuation> <notional id="EquityNotionalAmount"> <notionalAmount> <currency>USD</currency> <amount>5591987.41</amount> </notionalAmount> </notional> <equityAmount> <paymentCurrency href="ReferenceCurrency" /> <referenceAmount>Standard ISDA</referenceAmount> <cashSettlement>true</cashSettlement> </equityAmount> <return> <returnType>Price</returnType> </return> <notionalAdjustments>Standard</notionalAdjustments> <fxTerms> <quanto> <referenceCurrency id="ReferenceCurrency">USD</referenceCurrency> <fxRate> <quotedCurrencyPair> <currency1>USD</currency1> <currency2>EUR</currency2> <quoteBasis>Currency2PerCurrency1</quoteBasis> </quotedCurrencyPair> <rate>0.9914</rate> </fxRate> <fxRate> <quotedCurrencyPair> <currency1>USD</currency1> <currency2>HKD</currency2> <quoteBasis>Currency2PerCurrency1</quoteBasis> </quotedCurrencyPair> <rate>7.8</rate> </fxRate> </quanto> </fxTerms> </equityLeg> <interestLeg> <payerPartyReference href="PartyB" /> <receiverPartyReference href="PartyA" /> <interestLegCalculationPeriodDates id="InterestLegPeriodDates"> <effectiveDate> <relativeDate> <periodMultiplier>3</periodMultiplier> <period>D</period> <dayType>ExchangeBusiness</dayType> <businessDayConvention>NotApplicable</businessDayConvention> <dateRelativeTo href="TradeDate" /> </relativeDate> </effectiveDate> <terminationDate> <relativeDate> <periodMultiplier>0</periodMultiplier> <period>D</period> <businessDayConvention>NotApplicable</businessDayConvention> <dateRelativeTo href="FinalEquityPaymentDate" /> </relativeDate> </terminationDate> <interestLegResetDates> <calculationPeriodDatesReference href="InterestLegPeriodDates" /> <resetRelativeTo>CalculationPeriodStartDate</resetRelativeTo> </interestLegResetDates> <interestLegPaymentDates> <relativeDates> <periodMultiplier>0</periodMultiplier> <period>D</period> <businessDayConvention>NotApplicable</businessDayConvention> <dateRelativeTo href="EquityPaymentDate" /> </relativeDates> </interestLegPaymentDates> </interestLegCalculationPeriodDates> <notional> <amountRelativeTo href="EquityNotionalAmount"></amountRelativeTo> </notional> <interestAmount> <paymentCurrency href="ReferenceCurrency" /> <referenceAmount>Standard ISDA</referenceAmount> </interestAmount> <interestCalculation> <floatingRateCalculation> <floatingRateIndex>USD-LIBOR-Telerate</floatingRateIndex> <indexTenor> <periodMultiplier>3</periodMultiplier> <period>M</period> </indexTenor> <spreadSchedule> <initialValue>-0.0022</initialValue> </spreadSchedule> </floatingRateCalculation> <dayCountFraction>ACT/360</dayCountFraction> </interestCalculation> </interestLeg> </equitySwap> <calculationAgent> <calculationAgentPartyReference href="PartyA" /> </calculationAgent> <documentation> <masterAgreement> <masterAgreementType>ISDA2002</masterAgreementType> </masterAgreement> <contractualDefinitions>ISDA2000</contractualDefinitions> <contractualDefinitions>ISDA1996Equity</contractualDefinitions> </documentation> <governingLaw>GBEN</governingLaw> </trade> <party id="PartyA"> <partyId>Party A</partyId> </party> <party id="PartyB"> <partyId>Party B</partyId> </party> </FpML>
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var dataDocumentCt = new Tns.DataDocumentCt(); var trades = new Tns.TradeCt(); { var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "CITI"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.citi.com/fx/trade-id"; tradeIds.Value = "CITI10014"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } var partyTradeIdentifiers1 = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers1.PartyReference.Href = "UBSW"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.ubsw.com/fx/trade-id"; tradeIds.Value = "UBSW20014"; partyTradeIdentifiers1.TradeIds.Add(tradeIds); } trades.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers1); } trades.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2001, 11, 12, 0, 0, 0, 0, 0, 0, false); { var product = new Tns.FxDigitalOptionElm(); product.BuyerPartyReference.Href = "UBSW"; product.SellerPartyReference.Href = "CITI"; product.ExpiryDateTime.ExpiryDate = new LxDateTime(LxDateTimeType.Date, 2001, 11, 26, 0, 0, 0, 0, 0, 0, false); product.ExpiryDateTime.ExpiryTime.HourMinuteTime = new LxDateTime(LxDateTimeType.Time, 0, 0, 0, 14, 0, 0, 0, 0, 0, false); product.ExpiryDateTime.ExpiryTime.BusinessCenter.Value = "GBLO"; { var cutName = new Tns.CutNameCt(); cutName.Value = "LONDON"; product.ExpiryDateTime.CutName = cutName; } var fxOptionPremiums = new Tns.FXOptionPremiumCt(); { fxOptionPremiums.PayerPartyReference.Href = "UBSW"; fxOptionPremiums.ReceiverPartyReference.Href = "CITI"; fxOptionPremiums.PremiumAmount.Currency.Value = "GBP"; fxOptionPremiums.PremiumAmount.Amount = BigDecimal.Parse("53000"); fxOptionPremiums.PremiumSettlementDate = new LxDateTime(LxDateTimeType.Date, 2001, 11, 14, 0, 0, 0, 0, 0, 0, false); product.FxOptionPremiums.Add(fxOptionPremiums); } product.ValueDate = new LxDateTime(LxDateTimeType.Date, 2001, 11, 28, 0, 0, 0, 0, 0, 0, false); product.QuotedCurrencyPair.Currency1.Value = "GBP"; product.QuotedCurrencyPair.Currency2.Value = "USD"; product.QuotedCurrencyPair.QuoteBasis = Tns.QuoteBasisEnumEnum.Currency2PerCurrency1; product.SpotRate = BigDecimal.Parse("1.48"); var fxEuropeanTriggers = new Tns.FXEuropeanTriggerCt(); { fxEuropeanTriggers.TriggerCondition = Tns.TriggerConditionEnumEnum.Above; fxEuropeanTriggers.QuotedCurrencyPair.Currency1.Value = "GBP"; fxEuropeanTriggers.QuotedCurrencyPair.Currency2.Value = "USD"; fxEuropeanTriggers.QuotedCurrencyPair.QuoteBasis = Tns.QuoteBasisEnumEnum.Currency2PerCurrency1; fxEuropeanTriggers.TriggerRate = BigDecimal.Parse("1.48"); var informationSources = new Tns.InformationSourceCt(); { informationSources.RateSource.Value = "Reuters"; { var rateSourcePage = new Tns.RateSourcePageCt(); rateSourcePage.Value = "GBP="; informationSources.RateSourcePage = rateSourcePage; } fxEuropeanTriggers.InformationSources.Add(informationSources); } product.FxEuropeanTriggers.Add(fxEuropeanTriggers); } product.TriggerPayout.PayoutStyle = Tns.PayoutEnumEnum.Immediate; product.TriggerPayout.Currency.Value = "GBP"; product.TriggerPayout.Amount = BigDecimal.Parse("750000"); { var productType = new Tns.ProductTypeCt(); productType.Value = "Euro Binary"; product.ProductType = productType; } trades.Product = product; } dataDocumentCt.Trades.Add(trades); } var parties = new Tns.PartyCt(); { parties.Id = "CITI"; parties.PartyId.Value = "CITIUS33"; dataDocumentCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "UBSW"; parties1.PartyId.Value = "UBSWGB2L"; dataDocumentCt.Parties.Add(parties1); } dataDocumentCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.DataDocumentCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, dataDocumentCt); return writer.ToString(); } #endregion } } }
<?xml version="1.0" encoding="utf-8"?> <!-- == Copyright (c) 2002-2003. All rights reserved. == Financial Products Markup Language is subject to the FpML public license. == A copy of this license is available at http://www.fpml.org/documents/license --> <!-- This example is an FX OTC Euro Binary Option == UBS buys a two week GBP/USD European binary option and pays a premium. == At expiry, if the spot rate is above the trigger rate, UBS receives a payout. --> <FpML version="4-0" xsi:type="DataDocument" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/2003/FpML-4-0 ../fpml-main-4-0.xsd" xmlns="http://www.fpml.org/2003/FpML-4-0" > <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href="CITI" /> <tradeId tradeIdScheme="http://www.citi.com/fx/trade-id">CITI10014</tradeId> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href="UBSW" /> <tradeId tradeIdScheme="http://www.ubsw.com/fx/trade-id">UBSW20014</tradeId> </partyTradeIdentifier> <tradeDate>2001-11-12</tradeDate> </tradeHeader> <fxDigitalOption> <productType>Euro Binary</productType> <buyerPartyReference href="UBSW" /> <sellerPartyReference href="CITI" /> <expiryDateTime> <expiryDate>2001-11-26</expiryDate> <expiryTime> <hourMinuteTime>14:00:00</hourMinuteTime> <businessCenter>GBLO</businessCenter> </expiryTime> <cutName>LONDON</cutName> </expiryDateTime> <fxOptionPremium> <payerPartyReference href="UBSW" /> <receiverPartyReference href="CITI" /> <premiumAmount> <currency>GBP</currency> <amount>53000</amount> </premiumAmount> <premiumSettlementDate>2001-11-14</premiumSettlementDate> </fxOptionPremium> <valueDate>2001-11-28</valueDate> <quotedCurrencyPair> <currency1>GBP</currency1> <currency2>USD</currency2> <quoteBasis>Currency2PerCurrency1</quoteBasis> </quotedCurrencyPair> <spotRate>1.4800</spotRate> <fxEuropeanTrigger> <triggerCondition>Above</triggerCondition> <quotedCurrencyPair> <currency1>GBP</currency1> <currency2>USD</currency2> <quoteBasis>Currency2PerCurrency1</quoteBasis> </quotedCurrencyPair> <triggerRate>1.4800</triggerRate> <informationSource> <rateSource>Reuters</rateSource> <rateSourcePage>GBP=</rateSourcePage> </informationSource> </fxEuropeanTrigger> <triggerPayout> <currency>GBP</currency> <amount>750000</amount> <payoutStyle>Immediate</payoutStyle> </triggerPayout> </fxDigitalOption> </trade> <party id="CITI"> <partyId>CITIUS33</partyId> </party> <party id="UBSW"> <partyId>UBSWGB2L</partyId> </party> </FpML>
The following code shows how to create an XML document using the FpML nuget.
First the object is constructed and populated, then the LxSerializer is used to convert the object representation into XML.
using System; using System.Numerics; using System.IO; using System.Text; using LiquidTechnologies.XmlObjects; using LiquidTechnologies.XmlObjects.FpML40; using System.Xml.Linq; using LiquidTechnologies.XmlObjects; namespace LiquidTechnologies.Samples { public class XmlGeneratorSample { public static string CreateXml() { #region Writing var tradeConfirmedCt = new Tns.TradeConfirmedCt(); var partyTradeIdentifiers = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers.PartyReference.Href = "JPMC"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.jpmorgan.com/fpmltid"; tradeIds.Value = "XYZ789"; partyTradeIdentifiers.TradeIds.Add(tradeIds); } tradeConfirmedCt.Trade.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers); } var partyTradeIdentifiers1 = new Tns.PartyTradeIdentifierCt(); { partyTradeIdentifiers1.PartyReference.Href = "UBSW"; var tradeIds = new Tns.TradeIdCt(); { tradeIds.TradeIdScheme = "http://www.ubsw.com/fpmltid"; tradeIds.Value = "FX1234"; partyTradeIdentifiers1.TradeIds.Add(tradeIds); } tradeConfirmedCt.Trade.TradeHeader.PartyTradeIdentifiers.Add(partyTradeIdentifiers1); } tradeConfirmedCt.Trade.TradeHeader.TradeDate.Value = new LxDateTime(LxDateTimeType.Date, 2003, 4, 2, 0, 0, 0, 0, 0, 0, false); { var product = new Tns.FxSingleLegElm(); product.ExchangedCurrency1.PayerPartyReference.Href = "UBSW"; product.ExchangedCurrency1.ReceiverPartyReference.Href = "JPMC"; product.ExchangedCurrency1.PaymentAmount.Currency.Value = "GBP"; product.ExchangedCurrency1.PaymentAmount.Amount = BigDecimal.Parse("1000000"); product.ExchangedCurrency2.PayerPartyReference.Href = "JPMC"; product.ExchangedCurrency2.ReceiverPartyReference.Href = "UBSW"; product.ExchangedCurrency2.PaymentAmount.Currency.Value = "USD"; product.ExchangedCurrency2.PaymentAmount.Amount = BigDecimal.Parse("1520000"); product.ValueDate = new LxDateTime(LxDateTimeType.Date, 2004, 4, 4, 0, 0, 0, 0, 0, 0, false); product.ExchangeRate.QuotedCurrencyPair.Currency1.Value = "GBP"; product.ExchangeRate.QuotedCurrencyPair.Currency2.Value = "USD"; product.ExchangeRate.QuotedCurrencyPair.QuoteBasis = Tns.QuoteBasisEnumEnum.Currency2PerCurrency1; product.ExchangeRate.Rate = BigDecimal.Parse("1.52"); tradeConfirmedCt.Trade.Product = product; } var parties = new Tns.PartyCt(); { parties.Id = "UBSW"; parties.PartyId.Value = "UBSW"; tradeConfirmedCt.Parties.Add(parties); } var parties1 = new Tns.PartyCt(); { parties1.Id = "JPMC"; parties1.PartyId.Value = "JPMC"; tradeConfirmedCt.Parties.Add(parties1); } tradeConfirmedCt.Header.MessageId.MessageIdScheme = "http://www.example.com/messageId"; tradeConfirmedCt.Header.MessageId.Value = "MS/2003/04/02/15-38"; tradeConfirmedCt.Header.SentBy.Value = "MATCHSRV"; var sendTos = new Tns.PartyIdCt(); { sendTos.Value = "UBSW"; tradeConfirmedCt.Header.SendTos.Add(sendTos); } tradeConfirmedCt.Header.CreationTimestamp = new LxDateTime(LxDateTimeType.DateTime, 2003, 4, 2, 15, 38, 0, 0, 0, 0, 0, 0); tradeConfirmedCt.Version = Ns.VersionEnum.N4_0; var serializer = new LxSerializer<Tns.TradeConfirmedCt>(); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, tradeConfirmedCt); return writer.ToString(); } #endregion } } }
<?xml version = "1.0" encoding = "utf-8"?> <!-- == Copyright (c) 2002-2003. All rights reserved. == Financial Products Markup Language is subject to the FpML public license. == A copy of this license is available at http://www.fpml.org/documents/license --> <!-- == This examples shows how to use the RequestTradeConfirmation type to initiate a == confirmation process. --> <FpML version = "4-0" xsi:type = "TradeConfirmed" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.fpml.org/2003/FpML-4-0 ../fpml-main-4-0.xsd" xmlns = "http://www.fpml.org/2003/FpML-4-0"> <header> <messageId messageIdScheme="http://www.example.com/messageId">MS/2003/04/02/15-38</messageId> <sentBy>MATCHSRV</sentBy> <sendTo>UBSW</sendTo> <creationTimestamp>2003-04-02T15:38:00-00:00</creationTimestamp> </header> <trade> <tradeHeader> <partyTradeIdentifier> <partyReference href = "JPMC"/> <tradeId tradeIdScheme = "http://www.jpmorgan.com/fpmltid">XYZ789</tradeId> </partyTradeIdentifier> <partyTradeIdentifier> <partyReference href = "UBSW"/> <tradeId tradeIdScheme = "http://www.ubsw.com/fpmltid">FX1234</tradeId> </partyTradeIdentifier> <tradeDate>2003-04-02</tradeDate> </tradeHeader> <fxSingleLeg> <exchangedCurrency1> <payerPartyReference href = "UBSW"/> <receiverPartyReference href = "JPMC"/> <paymentAmount> <currency>GBP</currency> <amount>1000000</amount> </paymentAmount> </exchangedCurrency1> <exchangedCurrency2> <payerPartyReference href = "JPMC"/> <receiverPartyReference href = "UBSW"/> <paymentAmount> <currency>USD</currency> <amount>1520000</amount> </paymentAmount> </exchangedCurrency2> <valueDate>2004-04-04</valueDate> <exchangeRate> <quotedCurrencyPair> <currency1>GBP</currency1> <currency2>USD</currency2> <quoteBasis>Currency2PerCurrency1</quoteBasis> </quotedCurrencyPair> <rate>1.52</rate> </exchangeRate> </fxSingleLeg> </trade> <party id = "UBSW"> <partyId>UBSW</partyId> </party> <party id = "JPMC"> <partyId>JPMC</partyId> </party> </FpML>
Video Tutorial
This video tutorial demonstrates the basic usage of the XML Objects tool, showing how to generate code from an XSD, read an XML document into the object model, modify the data and write out the XML.