/// <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);
        }
示例#2
0
        /// <summary>
        /// Builds this instance and retruns the underlying instrument associated with the controller
        /// </summary>
        /// <returns></returns>
        public Fra Build()
        {
            var fra = new Fra
            {
                fixingDateOffset      = FixingOffSet,
                fixedRate             = FixedRate,
                fixedRateSpecified    = true,
                adjustedEffectiveDate = new RequiredIdentifierDate {
                    Value = EffectiveDate
                },
                floatingRateIndex                = FloatingRateIndex,
                fraDiscounting                   = FraDiscounting,
                fraDiscountingSpecified          = true,
                adjustedTerminationDate          = TerminationDate,
                adjustedTerminationDateSpecified = true,
                dayCountFraction                 = DayCountFraction,
                notional   = Notional,
                indexTenor = IndexTenor,
                calculationPeriodNumberOfDays = NumberOfDays.ToString(CultureInfo.InvariantCulture),
                buyerPartyReference           =
                    PartyReferenceHelper.Parse("Party1"),
                sellerPartyReference =
                    PartyReferenceHelper.Parse("Party2"),
                paymentDate = AdjustablePaymentDate
            };
            var product = new ProductType {
                Value = ProductTypeSimpleEnum.FRA.ToString()
            };

            fra.Items            = new object[] { product };
            fra.ItemsElementName = new[] { ItemsChoiceType2.productType };
            return(fra);
        }
        /// <summary>
        /// Builds this instance and returns the underlying instrument associated with the controller
        /// </summary>
        /// <returns></returns>
        public TermDeposit Build()
        {
            var deposit = new TermDeposit
            {
                Items = new object[] { new ProductType {
                                           Value = ProductType.ToString()
                                       } },
                ItemsElementName      = new[] { ItemsChoiceType2.productType },
                dayCountFraction      = DayCountFraction,
                principal             = MoneyHelper.GetPositiveMoney(Principal),
                maturityDate          = TerminationDate,
                maturityDateSpecified = true,
                startDate             = EffectiveDate,
                startDateSpecified    = true,
                fixedRate             = FixedRate,
                fixedRateSpecified    = true
            };

            if (BasePartyPayingFixed)//From the viewpoint of the counterparty!
            {
                deposit.receiverPartyReference = PartyReferenceHelper.Parse(BaseParty);
                deposit.payerPartyReference    = PartyReferenceHelper.Parse(CounterParty);
            }
            else
            {
                deposit.payerPartyReference    = PartyReferenceHelper.Parse(BaseParty);
                deposit.receiverPartyReference = PartyReferenceHelper.Parse(CounterParty);
            }
            //deposit payments.
            if (deposit.payment?.Length == 3)
            {
                var initialDate  = AdjustableOrAdjustedDateHelper.Create(null, EffectiveDate, null);
                var maturityDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, null);
                deposit.payment[0].paymentDate = initialDate;
                deposit.payment[1].paymentDate = maturityDate;
                deposit.payment[2].paymentDate = maturityDate;
            }
            var interest = System.Math.Abs(InterestAmount.AccruedInterest);

            deposit.interest = MoneyHelper.GetAmount(interest, deposit.principal.currency.Value);
            return(deposit);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        /// <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);
        }