Пример #1
0
        /// <summary>
        /// Builds a fx swap.
        /// </summary>
        /// <returns></returns>
        public static FxSwap Parse(string exchangeCurrency1PayPartyReference, string exchangeCurrency2PayPartyReference,
                                   decimal exchangeCurrency1Amount, string exchangeCurrency1, string exchangeCurrency2, QuoteBasisEnum quoteBasis,
                                   DateTime startValueDate, DateTime forwardValueDate, Decimal startRate, Decimal forwardRate, Decimal?forwardPoints)
        {
            var fxSwap = new FxSwap
            {
                Items            = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.FxSwap.ToString()) },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };
            var leg1 = ParseSpot(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1Amount,
                                 exchangeCurrency1, exchangeCurrency2, quoteBasis, startValueDate, startRate);
            var leg2 = PriceableFxSwapLeg.ParseForward(exchangeCurrency2PayPartyReference, exchangeCurrency1PayPartyReference, exchangeCurrency1Amount,
                                                       exchangeCurrency1, exchangeCurrency2, quoteBasis, forwardValueDate, forwardRate, forwardRate, forwardPoints);

            fxSwap.nearLeg = leg1;
            fxSwap.farLeg  = leg2;
            return(fxSwap);
        }
Пример #2
0
        public static Trade CreateFxSwap(string tradeId, DateTime tradeDate, string exchangeCurrency1PayPartyReference, string exchangeCurrency2PayPartyReference,
                                         decimal exchangeCurrency1Amount, string exchangeCurrency1, string exchangeCurrency2, QuoteBasisEnum quoteBasis,
                                         DateTime valueDate, Decimal spotRate, Decimal?forwardRate, Decimal?forwardPoints)
        {
            var trade = new Trade {
                id = tradeId, tradeHeader = new TradeHeader()
            };
            var party1 = PartyTradeIdentifierHelper.Parse(tradeId, "party1");
            var party2 = PartyTradeIdentifierHelper.Parse(tradeId, "party2");

            trade.tradeHeader.partyTradeIdentifier = new[] { party1, party2 };
            trade.tradeHeader.tradeDate            = new IdentifiedDate {
                Value = tradeDate
            };
            var nearLeg = new FxSwapLeg();
            var farLeg  = new FxSwapLeg();

            if (forwardRate == null)
            {
                nearLeg = ParseSpot(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1Amount,
                                    exchangeCurrency1, exchangeCurrency2, quoteBasis, valueDate, spotRate);
            }
            else
            {
                farLeg = PriceableFxSwapLeg.ParseForward(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1Amount,
                                                         exchangeCurrency1, exchangeCurrency2, quoteBasis, valueDate, spotRate, (decimal)forwardRate, forwardPoints);
            }
            var fxSwap = new FxSwap
            {
                nearLeg          = nearLeg,
                farLeg           = farLeg,
                Items            = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.FxSwap.ToString()) },
                ItemsElementName = new[] { ItemsChoiceType2.productType }
            };

            FpMLFieldResolver.TradeSetFxSwap(trade, fxSwap);
            return(trade);
        }
Пример #3
0
        /// <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;
        }