/// <summary> /// Builds this instance and returns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public PropertyTransaction Build() { //var equity = UnderlyingEquity.(); var buyerPartyReference = PartyReferenceHelper.Parse(BuyerReference); var sellerPartyReference = PartyReferenceHelper.Parse(SellerReference); var productType = new object[] { ProductTypeHelper.Create("PropertyTransaction") }; //var productId = new ProductId {Value = "BondTransaction"}; var itemName = new[] { ItemsChoiceType2.productType }; //TODO extend this //var productIds = new[] {productId}; var property = XmlSerializerHelper.Clone(PropertyInfo); var purchasePrice = XmlSerializerHelper.Clone(PurchasePrice); var propertyTransaction = new PropertyTransaction { buyerPartyReference = buyerPartyReference, sellerPartyReference = sellerPartyReference, id = Id, //productId = productIds, Items = productType, ItemsElementName = itemName, purchasePrice = purchasePrice, property = property }; return(propertyTransaction); }
/// <summary> /// Creates floater (swap with single floating stream of coupons) /// </summary> /// <param name="singleStream"></param> /// <param name="productTypeTaxonomy"></param> /// <returns></returns> public static Swap Create(InterestRateStream singleStream, string productTypeTaxonomy) { var result = new Swap { swapStream = new[] { singleStream }, productType = new[] { ProductTypeHelper.Create(productTypeTaxonomy) }, }; return(result); }
/// <summary> /// Creates floater (swap with single floating stream of coupons) /// </summary> /// <param name="singleStream"></param> /// <returns></returns> public static Swap Create(InterestRateStream singleStream) { var result = new Swap { swapStream = new[] { singleStream }, Items = new object[] { ProductTypeHelper.Create("Floater") }, ItemsElementName = new[] { ItemsChoiceType2.productType } }; return(result); }
/// <summary> /// Builds this instance and returns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public FxSwap Build() { var fxSwap = new FxSwap(); var leg1 = Legs[0].Build(); var leg2 = Legs[1].Build(); fxSwap.nearLeg = leg1; fxSwap.farLeg = leg2; fxSwap.id = Id; fxSwap.Items = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.FxSwap.ToString()) }; fxSwap.ItemsElementName = new[] { ItemsChoiceType2.productType }; return(fxSwap); }
/// <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); }
/// <summary> /// Builds this instance. /// </summary> /// <returns></returns> public BulletPayment Build() { var px = new BulletPayment { payment = new Payment { paymentAmount = MoneyHelper.GetNonNegativeAmount(PaymentAmount.amount, PaymentAmount.currency.Value) }, Items = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.BulletPayment.ToString()) }, ItemsElementName = new[] { ItemsChoiceType2.productType } }; //Setting the items array which contains product type and product is information. //payment type information px.payment.paymentType = PaymentTypeHelper.Create("Payment"); //Set the party information px.payment.payerPartyReference = new PartyReference { href = "Party2" }; px.payment.receiverPartyReference = new PartyReference { href = "Party1" }; if (PayerIsBaseParty) { px.payment.payerPartyReference = new PartyReference { href = "Party1" }; px.payment.receiverPartyReference = new PartyReference { href = "Party2" }; } //The payment date px.payment.paymentDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, PaymentDateAdjustments); if (CalculationPerformedIndicator) { px.payment.discountFactor = PaymentDiscountFactor; px.payment.discountFactorSpecified = true; px.payment.presentValueAmount = MoneyHelper.GetAmount(CalculationResults.NPV, PaymentAmount.currency.Value); } return(px); }
/// <summary> /// Builds this instance and retruns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public FutureTransaction Build() { var buyerPartyReference = PartyReferenceHelper.Parse(BuyerReference); var sellerPartyReference = PartyReferenceHelper.Parse(SellerReference); var productType = new object[] { ProductTypeHelper.Create("FuturesTransaction") }; var itemName = new[] { ItemsChoiceType2.productType }; var future = XmlSerializerHelper.Clone(FuturesTypeInfo.Future); var futureTransaction = new FutureTransaction { buyerPartyReference = buyerPartyReference, sellerPartyReference = sellerPartyReference, id = Id, Items = productType, ItemsElementName = itemName, numberOfUnits = NumberOfContracts, unitPrice = XmlSerializerHelper.Clone(PurchasePrice), future = future }; return(futureTransaction); }
/// <summary> /// Builds a bullet payment. /// </summary> /// <param name="productType"></param> /// <param name="payerIsBaseParty"></param> /// <param name="paymentDate"></param> /// <param name="businessDayCalendar"></param> /// <param name="businessDayAdjustments"> </param> /// <param name="currency"></param> /// <param name="amount"></param> /// <returns></returns> public static BulletPayment Parse(string productType, Boolean payerIsBaseParty, DateTime paymentDate, string businessDayCalendar, string businessDayAdjustments, string currency, decimal amount) { var px = new BulletPayment { payment = new Payment { paymentAmount = MoneyHelper.GetNonNegativeAmount(amount, currency) }, Items = new object[] { ProductTypeHelper.Create("BulletPayment") }, ItemsElementName = new[] { ItemsChoiceType2.productType } }; var tempDate = DateTypesHelper.ToAdjustableDate(paymentDate, businessDayAdjustments, businessDayCalendar); px.payment.paymentDate = AdjustableOrAdjustedDateHelper.Create(tempDate.unadjustedDate.Value, null, tempDate.dateAdjustments);//TODO //Setting the items array which contains product type and product is information. //payment type information px.payment.paymentType = PaymentTypeHelper.Create("Payment"); //Set the party information px.payment.payerPartyReference = new PartyReference { href = "Party2" }; px.payment.receiverPartyReference = new PartyReference { href = "Party1" }; if (payerIsBaseParty) { px.payment.payerPartyReference = new PartyReference { href = "Party1" }; px.payment.receiverPartyReference = new PartyReference { href = "Party2" }; } return(px); }
/// <summary> /// Builds this instance and retruns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public EquityTransaction Build() { //var equity = UnderlyingEquity.(); var buyerPartyReference = PartyReferenceHelper.Parse(BuyerReference); var sellerPartyReference = PartyReferenceHelper.Parse(SellerReference); var productType = new object[] { ProductTypeHelper.Create("EquityTransaction") }; var itemName = new[] { ItemsChoiceType2.productType }; var equity = XmlSerializerHelper.Clone(EquityTypeInfo.Equity); var equityTransaction = new EquityTransaction { buyerPartyReference = buyerPartyReference, sellerPartyReference = sellerPartyReference, id = Id, Items = productType, ItemsElementName = itemName, numberOfUnits = NumberOfShares, unitPrice = XmlSerializerHelper.Clone(PurchasePrice), equity = equity }; return(equityTransaction); }
/// <summary> /// Builds this instance and retruns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public BondTransaction Build() { var bond = BondTypeInfo.Bond; var buyerPartyReference = PartyReferenceHelper.Parse(BuyerReference); var sellerPartyReference = PartyReferenceHelper.Parse(SellerReference); var productType = new object[] { ProductTypeHelper.Create("BondTransaction") }; var itemName = new[] { ItemsChoiceType2.productType }; //TODO extend this var bondTransaction = new BondTransaction { notionalAmount = NotionalAmount, bond = bond, price = XmlSerializerHelper.Clone(BondPrice), buyerPartyReference = buyerPartyReference, sellerPartyReference = sellerPartyReference, id = Id, Items = productType, ItemsElementName = itemName }; return(bondTransaction); }
/// <summary> /// Builds a term deposit. /// </summary> /// <param name="productType"></param> /// <param name="tradeDate"></param> /// <param name="startDate"></param> /// <param name="maturityDate"></param> /// <param name="currency"></param> /// <param name="notionalAmount"></param> /// <param name="fixedRate"></param> /// <param name="dayCount"></param> /// <returns></returns> public static TermDeposit Parse(string productType, DateTime tradeDate, DateTime startDate, DateTime maturityDate, string currency, decimal notionalAmount, decimal fixedRate, string dayCount) { var termDeposit = new TermDeposit { dayCountFraction = DayCountFractionHelper.Parse(dayCount), fixedRate = fixedRate, fixedRateSpecified = true, principal = MoneyHelper.GetPositiveMoney(notionalAmount, currency), startDate = startDate, startDateSpecified = true, maturityDate = maturityDate, maturityDateSpecified = true, payerPartyReference = PartyReferenceHelper.Parse("Party1"), receiverPartyReference = PartyReferenceHelper.Parse("Party2"), Items = new object[] { ProductTypeHelper.Create(ProductTypeSimpleEnum.TermDeposit.ToString()) }, ItemsElementName = new[] { ItemsChoiceType2.productType } }; //Set the party information return(termDeposit); }
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); }