/// <summary> /// Build the fx leg /// </summary> /// <param name="exchangeCurrency1PayPartyReference"></param> /// <param name="exchangeCurrency2PayPartyReference"></param> /// <param name="exchangeCurrency1Amount"></param> /// <param name="exchangeCurrency1"></param> /// <param name="exchangeCurrency2"></param> /// <param name="quoteBasis"></param> /// <param name="valueDate"></param> /// <param name="spotRate"></param> /// <returns></returns> public static FxSingleLeg ParseSpot(string exchangeCurrency1PayPartyReference, string exchangeCurrency2PayPartyReference, decimal exchangeCurrency1Amount, string exchangeCurrency1, string exchangeCurrency2, QuoteBasisEnum quoteBasis, DateTime valueDate, Decimal spotRate) { var fxLeg = FxSingleLeg.CreateSpot(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1Amount, exchangeCurrency1, exchangeCurrency2, quoteBasis, valueDate, spotRate); return(fxLeg); }
/// <summary> /// Initializes a new instance of the <see cref="FxSingleLegPricer"/> class. All the cashfloews must be signed. /// </summary> /// <param name="fxLeg">The fxLeg.</param> /// <param name="baseParty">The the base party.</param> /// <param name="productType">THe product type: This should only be FxSpot or FxForward.</param> public FxSingleLegPricer(FxSingleLeg fxLeg, string baseParty, ProductTypeSimpleEnum productType) { Multiplier = 1.0m; OrderedPartyNames = new List <string>(); Id = fxLeg.id; AnalyticsModel = new FxLegAnalytic(); ProductType = productType; ExchangeRate = fxLeg.exchangeRate; HybridValuation = true; //Get the currency. PaymentCurrencies = new List <string>(); Currency1 = fxLeg.exchangedCurrency1.paymentAmount.currency; Currency2 = fxLeg.exchangedCurrency2.paymentAmount.currency; if (!PaymentCurrencies.Contains(Currency1.Value)) { PaymentCurrencies.Add(Currency1.Value); } if (!PaymentCurrencies.Contains(Currency2.Value)) { PaymentCurrencies.Add(Currency2.Value); } //Set the default discount curve name. Currency1DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency1.Value, true); //Set the default discount curve name. Currency2DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency2.Value, true); //TODO //Set the appropraiet cross //if the quotebasis is : Currency1PerCurrency2 the currency curve is: currency1-currency2 if (ExchangeRate.quotedCurrencyPair.quoteBasis == QuoteBasisEnum.Currency2PerCurrency1) { FxIndexCurveName = MarketEnvironmentHelper.ResolveFxCurveNames(Currency1.Value, Currency2.Value); } //Otherwise it is Currency2-Currency1 else { FxIndexCurveName = MarketEnvironmentHelper.ResolveFxCurveNames(Currency2.Value, Currency1.Value); } if (fxLeg.nonDeliverableSettlement != null)//TODO Not implemented yet. { IsNonDeliverableForward = true; SettlementCurrency = fxLeg.nonDeliverableSettlement.settlementCurrency; SettlementCurrencyDiscountCurveName = CurveNameHelpers.GetDiscountCurveName(SettlementCurrency.Value, true); } //Build the coupons and principal exchanges. Payments = PriceableInstrumentsFactory.CreatePriceableFxLegPayment(baseParty, fxLeg); //TODO: add extra cashflowss. RiskMaturityDate = fxLeg.Items1ElementName[0] == Items1ChoiceType.valueDate ? fxLeg.Items1[0] : LastDate(); }
/// <summary> /// Builds this instance. /// </summary> /// <returns></returns> public FxSingleLeg Build()//TODO implement this. { var fxLeg = new FxSingleLeg { Items = new object[] { new ProductType { Value = ProductType.ToString() } }, ItemsElementName = new[] { ItemsChoiceType2.productType }, exchangedCurrency1 = Payments[0].Build(), exchangedCurrency2 = Payments[1].Build(), exchangeRate = ExchangeRate, id = Id, Items1 = new[] { RiskMaturityDate }, Items1ElementName = new[] { Items1ChoiceType.valueDate } }; return(fxLeg); }
public static void TradeSetFxSingleLeg(Trade trade, FxSingleLeg swap) { trade.Item = swap; trade.ItemElementName = ItemChoiceType15.fxSingleLeg; }
/// <summary> /// /// </summary> /// <param name="baseParty"></param> /// <param name="fxLeg"></param> /// <returns></returns> public static IList <PriceablePayment> CreatePriceableFxLegPayment(string baseParty, FxSingleLeg fxLeg)//TODO Fix this. { string id1 = fxLeg.exchangedCurrency1.id ?? "Payment_" + fxLeg.exchangedCurrency1.paymentAmount.currency.Value; string id2 = fxLeg.exchangedCurrency2.id ?? "Payment_" + fxLeg.exchangedCurrency2.paymentAmount.currency.Value; var priceablePayments = new List <PriceablePayment>(); bool payerIsBase = false; //payment1 var paymentAmount1 = fxLeg.exchangedCurrency1.paymentAmount.amount; if (baseParty == fxLeg.exchangedCurrency1.payerPartyReference.href) { paymentAmount1 *= -1; // *fxLeg.exchangedCurrency1.paymentAmount.amount; payerIsBase = true; } var paymentDate = new DateTime(); if (fxLeg.Items1ElementName != null && fxLeg.Items1 != null) { var index = 0; foreach (var element in fxLeg.Items1ElementName) { if (element == Items1ChoiceType.valueDate) { paymentDate = fxLeg.Items1[index]; index++; } } } var currency1 = fxLeg.exchangedCurrency1.paymentAmount.currency.Value; priceablePayments.Add(new PriceablePayment(id1, fxLeg.exchangedCurrency1.payerPartyReference.href, fxLeg.exchangedCurrency2.payerPartyReference.href, payerIsBase, paymentAmount1, currency1, paymentDate, null)); //payment2 var paymentAmount2 = fxLeg.exchangedCurrency2.paymentAmount.amount; if (baseParty == fxLeg.exchangedCurrency2.payerPartyReference.href) { paymentAmount2 *= -1; // *fxLeg.exchangedCurrency2.paymentAmount.amount; payerIsBase = true; } var currency2 = fxLeg.exchangedCurrency2.paymentAmount.currency.Value; priceablePayments.Add(new PriceablePayment(id2, fxLeg.exchangedCurrency1.payerPartyReference.href, fxLeg.exchangedCurrency2.payerPartyReference.href, payerIsBase, paymentAmount2, currency2, paymentDate, null)); return(priceablePayments); }