コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="cache">The cache.</param>
 /// <param name="baseParty">THe base party is either Party1 or Party2</param>
 /// <param name="depositFpML">THe FpML representation of the deposit correctly built.</param>
 public TermDepositPricer(ILogger logger, ICoreCache cache, TermDeposit depositFpML, string baseParty)
 {
     Multiplier        = 1.0m;
     OrderedPartyNames = new List <string>();
     FixedRate         = depositFpML.fixedRate;
     EffectiveDate     = depositFpML.startDate;
     TerminationDate   = depositFpML.maturityDate;
     DayCountFraction  = new DayCountFraction {
         Value = depositFpML.dayCountFraction.Value
     };
     BasePartyPayingFixed = !IsBasePartyLender(baseParty, depositFpML);
     if (BasePartyPayingFixed)//From the viewpoint of the counterparty!
     {
         BaseParty    = depositFpML.receiverPartyReference.href;
         CounterParty = depositFpML.payerPartyReference.href;
     }
     else
     {
         BaseParty    = depositFpML.payerPartyReference.href;
         CounterParty = depositFpML.receiverPartyReference.href;
     }
     PaymentDate      = TerminationDate;
     RiskMaturityDate = TerminationDate;
     Principal        = MoneyHelper.GetMoney(depositFpML.principal);
     Payments         = new List <PriceablePayment>();
     if (depositFpML.payment != null && depositFpML.payment.Length == 3)
     {
         //Modify to be principal and interest.
         //A principal payment ->priceable payment
         //An interest payment -> priceable fixed coupon
         var initialDate  = AdjustableOrAdjustedDateHelper.Create(null, EffectiveDate, null);
         var maturityDate = AdjustableOrAdjustedDateHelper.Create(null, PaymentDate, null);
         depositFpML.payment[0].paymentDate = initialDate;
         depositFpML.payment[1].paymentDate = maturityDate;
         depositFpML.payment[2].paymentDate = maturityDate;//Remove this and replace with depositFpML.interest
         Payments.AddRange(PriceableInstrumentsFactory.CreatePriceablePayments(BaseParty, depositFpML.payment, null));
         AddCashFlow(depositFpML, BasePartyPayingFixed);
     }
     else//This will change the input FpML as well!
     {
         var initial = PaymentHelper.Create(depositFpML.payerPartyReference.href, depositFpML.receiverPartyReference.href, Principal.currency.Value, Principal.amount, EffectiveDate);
         Payments.Add(PriceableInstrumentsFactory.CreatePriceablePayment(BaseParty, initial, null));
         var final = PaymentHelper.Create(depositFpML.receiverPartyReference.href, depositFpML.payerPartyReference.href, depositFpML.principal.currency.Value, Principal.amount, TerminationDate);
         Payments.Add(PriceableInstrumentsFactory.CreatePriceablePayment(BaseParty, final, null));
         //Payments.Add(PaymentHelper.Create("interest payment");
         AddCashFlow(depositFpML, !BasePartyPayingFixed);
     }
     //Set the product type.
     ProductType       = ProductTypeSimpleEnum.TermDeposit;
     Currency          = depositFpML.principal.currency;
     PaymentCurrencies = new List <string> {
         Currency.Value
     };
     //Set the default discount curve name.
     DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true);
 }
コード例 #2
0
        private void AddCashFlow(TermDeposit depositFpML, bool isLenderBase)
        {
            var fixedInterest = new PriceableFixedRateCoupon(depositFpML.id + "FixedCoupon_1"
                                                             , BasePartyPayingFixed
                                                             , EffectiveDate
                                                             , TerminationDate
                                                             , depositFpML.dayCountFraction
                                                             , depositFpML.fixedRate
                                                             , isLenderBase ? MoneyHelper.GetMoney(depositFpML.principal) : MoneyHelper.Neg(depositFpML.principal)
                                                             , null
                                                             , PaymentDate
                                                             , null
                                                             , null
                                                             , null
                                                             , null);

            InterestAmount = fixedInterest;
        }