Example #1
0
        public static Trade CreateFxSwap(string tradeId, DateTime tradeDate, string exchangeCurrency1PayPartyReference, string exchangeCurrency2PayPartyReference,
                                         decimal exchangeCurrency1Amount, string exchangeCurrency1, string exchangeCurrency2, QuoteBasisEnum quoteBasis,
                                         DateTime startValueDate, DateTime forwardValueDate, Decimal startRate, 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 fxSwap = Parse(exchangeCurrency1PayPartyReference, exchangeCurrency2PayPartyReference, exchangeCurrency1Amount,
                               exchangeCurrency1, exchangeCurrency2, quoteBasis, startValueDate, forwardValueDate, startRate, forwardRate, forwardPoints);

            FpMLFieldResolver.TradeSetFxSwap(trade, fxSwap);
            return(trade);
        }
Example #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);
        }