Exemple #1
0
        public static FxSingleLeg 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 FxSingleLeg
            {
                exchangedCurrency1 =
                    PaymentHelper.Create(exchangeCurrency1PayPartyReference,
                                         exchangeCurrency2PayPartyReference, exchangeCurrency1,
                                         exchangeCurrency1Amount),
                exchangedCurrency2 =
                    PaymentHelper.Create(exchangeCurrency2PayPartyReference,
                                         exchangeCurrency1PayPartyReference, exchangeCurrency2,
                                         exchange2Amount),
                Items1       = new[] { valueDate },
                exchangeRate =
                    ExchangeRate.Create(exchangeCurrency1, exchangeCurrency2, quoteBasis, spotRate),
                Items1ElementName = new[] { Items1ChoiceType.valueDate }
            };

            return(fxforward);
        }
Exemple #2
0
        /// <summary>
        /// Builds an  fx trade from the current vanillar fx option class.
        /// </summary>
        /// <param name="hasExpired"></param>
        /// <returns></returns>
        public FxSingleLeg CreateFxSingleLeg(bool hasExpired)//TODO This is not correct and will need to be fixed
        {
            QuoteBasisEnum quoteBasis   = strike.strikeQuoteBasis == StrikeQuoteBasisEnum.CallCurrencyPerPutCurrency ? QuoteBasisEnum.Currency2PerCurrency1 : QuoteBasisEnum.Currency1PerCurrency2;
            ExchangeRate   exchangeRate = hasExpired ? ExchangeRate.Create(putCurrencyAmount.currency.Value, putCurrencyAmount.currency.Value, quoteBasis, strike.rate)
                                            : ExchangeRate.Create(putCurrencyAmount.currency.Value, putCurrencyAmount.currency.Value, quoteBasis, strike.rate, strike.rate, null);
            var fxforward = new FxSingleLeg
            {
                exchangedCurrency1 =
                    PaymentHelper.Create(sellerAccountReference.href, buyerAccountReference.href,
                                         putCurrencyAmount.currency.Value, putCurrencyAmount.amount),
                exchangedCurrency2 =
                    PaymentHelper.Create(buyerAccountReference.href, sellerAccountReference.href,
                                         callCurrencyAmount.currency.Value, callCurrencyAmount.amount),

                exchangeRate      = exchangeRate,
                Items1ElementName = new[] { Items1ChoiceType.valueDate }
            };
            var exercise = Item as FxEuropeanExercise;

            if (exercise != null)
            {
                fxforward.Items1 = new[] { exercise.expiryDate };
            }
            return(fxforward);
        }
Exemple #3
0
        /// <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 FxSingleLeg CreateFxSingleLeg(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 FxSingleLeg
            {
                exchangedCurrency1 =
                    PaymentHelper.Create(putCurrencyPayPartyReference, callCurrencyPayPartyReference,
                                         putCurrency, putCurrencyAmount),
                exchangedCurrency2 =
                    PaymentHelper.Create(callCurrencyPayPartyReference, putCurrencyPayPartyReference,
                                         callCurrency, callCurrencyAmount),
                Items1            = new[] { valueDate },
                Items1ElementName = new[] { Items1ChoiceType.valueDate },
                exchangeRate      = exchangeRate,
            };

            return(fxforward);
        }
        //public static Trade[] TradeValuationItemGetTradeArray(TradeValuationItem tradeValuationItem)
        //{
        //    return tradeValuationItem.Items.Cast<Trade>().ToArray();
        //}

        #region Trade GetXXX/SetXXX methods

        public static void TradeSetFxSingleLeg(Trade trade, FxSingleLeg swap)
        {
            trade.Item = swap;
            //trade.ItemElementName = ItemChoiceType15.fxSingleLeg;
        }