public static FxLeg CreateSpot(string exchangeCurrency1PayPartyReference, string exchangeCurrency2PayPartyReference, decimal exchangeCurrency1Amount, string exchangeCurrency1, string exchangeCurrency2, QuoteBasisEnum quoteBasis, DateTime valueDate, Decimal spotRate) { decimal exchange2Amount; if (quoteBasis == QuoteBasisEnum.Currency2PerCurrency1) { exchange2Amount = exchangeCurrency1Amount * spotRate; } else { exchange2Amount = exchangeCurrency1Amount / spotRate; } var fxforward = new FxLeg { exchangedCurrency1 = PaymentHelper.Create(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1, exchangeCurrency1Amount), exchangedCurrency2 = PaymentHelper.Create(exchangeCurrency2PayPartyReference, exchangeCurrency1PayPartyReference, exchangeCurrency2, exchange2Amount), Items = new[] { valueDate }, exchangeRate = ExchangeRate.Create(exchangeCurrency1, exchangeCurrency2, quoteBasis, spotRate), ItemsElementName = new[] { ItemsChoiceType15.valueDate } }; return(fxforward); }
/// <summary> /// Gets and sets the required pricing structures to value this leg. /// </summary> public override List <String> GetRequiredPricingStructures() { var result = new List <String>(); var putCurrency = PaymentHelper.Create(buyerPartyReference.href, sellerPartyReference.href, putCurrencyAmount.currency.Value, putCurrencyAmount.amount, valueDate); var callCurrency = PaymentHelper.Create(sellerPartyReference.href, buyerPartyReference.href, callCurrencyAmount.currency.Value, callCurrencyAmount.amount, valueDate); result.AddRange(putCurrency.GetRequiredPricingStructures()); result.AddRange(callCurrency.GetRequiredPricingStructures()); result.AddRange(GetRequiredVolatilitySurfaces()); if (fxOptionPremium != null) { foreach (var premium in fxOptionPremium) { var ps = premium.GetRequiredPricingStructures(); result.AddRange(ps); } } return(result.Distinct().ToList()); }
/// <summary> /// /// </summary> /// <param name="hasExpired"></param> /// <param name="putCurrencyPayPartyReference"></param> /// <param name="callCurrencyPayPartyReference"></param> /// <param name="putCurrencyAmount"></param> /// <param name="putCurrency"></param> /// <param name="callCurrencyAmount"></param> /// <param name="callCurrency"></param> /// <param name="strikeQuoteBasis"></param> /// <param name="valueDate"></param> /// <param name="fxRate"></param> /// <returns></returns> public static FxLeg CreateFxLeg(bool hasExpired, string putCurrencyPayPartyReference, string callCurrencyPayPartyReference, decimal putCurrencyAmount, string putCurrency, decimal callCurrencyAmount, string callCurrency, StrikeQuoteBasisEnum strikeQuoteBasis, DateTime valueDate, Decimal fxRate) { QuoteBasisEnum quoteBasis = strikeQuoteBasis == StrikeQuoteBasisEnum.CallCurrencyPerPutCurrency ? QuoteBasisEnum.Currency2PerCurrency1 : QuoteBasisEnum.Currency1PerCurrency2; ExchangeRate exchangeRate = hasExpired ? ExchangeRate.Create(putCurrency, callCurrency, quoteBasis, fxRate) : ExchangeRate.Create(putCurrency, callCurrency, quoteBasis, fxRate, fxRate, null); var fxforward = new FxLeg { exchangedCurrency1 = PaymentHelper.Create(putCurrencyPayPartyReference, callCurrencyPayPartyReference, putCurrency, putCurrencyAmount), exchangedCurrency2 = PaymentHelper.Create(callCurrencyPayPartyReference, putCurrencyPayPartyReference, callCurrency, callCurrencyAmount), Items = new[] { valueDate }, exchangeRate = exchangeRate, ItemsElementName = new[] { ItemsChoiceType15.valueDate } }; return(fxforward); }