/// <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); }
/// <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); }