/// <summary> /// The main constructor. /// </summary> /// <param name="fxSwapFpML"></param> /// <param name="basePartyReference"></param> public FxSwapPricer(FxSwap fxSwapFpML, string basePartyReference) { //BusinessCentersResolver.ResolveBusinessCenters(swapFpML); Multiplier = 1.0m; Id = fxSwapFpML.id; OrderedPartyNames = new List <string>(); //We make the assumption that the termination date is the same for all legs.. var lastDate = new DateTime(); ProductType = ProductTypeSimpleEnum.FxSwap; PaymentCurrencies = new List <string>(); var tempDate = new DateTime(); var fxSwapStream = fxSwapFpML.nearLeg; if (fxSwapStream != null) { //Set the id of the first stream. fxSwapStream.id = fxSwapStream.id + "_" + "nearLeg"; var leg = new PriceableFxSwapLeg(fxSwapStream, basePartyReference, ProductTypeSimpleEnum.FxSwap); Legs.Add(leg); //Add the currencies for the trade pricer. if (!PaymentCurrencies.Contains(leg.Currency1.Value)) { PaymentCurrencies.Add(leg.Currency1.Value); } if (!PaymentCurrencies.Contains(leg.Currency2.Value)) { PaymentCurrencies.Add(leg.Currency2.Value); } //find the last date. tempDate = leg.LastDate(); //Add the payments Currency1Payments = new List <InstrumentControllerBase>(); Currency2Payments = new List <InstrumentControllerBase>(); Currency1Payments.Add(leg.Currency1Payment); Currency2Payments.Add(leg.Currency2Payment); } fxSwapStream = fxSwapFpML.farLeg; if (fxSwapStream != null) { //Set the id of the first stream. fxSwapStream.id = fxSwapStream.id + "_" + "farLeg"; var leg = new PriceableFxSwapLeg(fxSwapStream, basePartyReference, ProductTypeSimpleEnum.FxSwap); Legs.Add(leg); //Add the currencies for the trade pricer. if (!PaymentCurrencies.Contains(leg.Currency1.Value)) { PaymentCurrencies.Add(leg.Currency1.Value); } if (!PaymentCurrencies.Contains(leg.Currency2.Value)) { PaymentCurrencies.Add(leg.Currency2.Value); } //Add the payments Currency1Payments = new List <InstrumentControllerBase>(); Currency2Payments = new List <InstrumentControllerBase>(); Currency1Payments.Add(leg.Currency1Payment); Currency2Payments.Add(leg.Currency2Payment); } if (lastDate < tempDate) { lastDate = tempDate; } RiskMaturityDate = lastDate; }