コード例 #1
0
ファイル: Loan.cs プロジェクト: wtain/FinCalc
 public Loan(decimal principal, double rate, DateTime startDate, int duration, Calendar calendar)
 {
     m_principal = principal;
     m_rate = rate;
     m_startDate = startDate;
     m_calendar = calendar;
     int nPaymentsPerYear = 12; // Monthly; duration - months
     double flowRate = rate / nPaymentsPerYear;
     m_payment = (decimal) (((double) principal * flowRate) / (1 - 1 / Math.Pow(1 + flowRate, duration)));
     decimal amount = principal;
     DateTime date = startDate; // ! paying immediately, percents for the month forward; in case of full deal the principal payment would be 1 month off
     m_payments = new List<Cashflow>(duration);
     for (long i = 0; i < duration; ++i)
     {
         decimal interestPayment = (decimal) ((double) amount * flowRate);
         decimal principalPayment = m_payment - interestPayment;
         amount -= principalPayment;
         m_payments.Add(new Cashflow(date, principalPayment, interestPayment));
         date = date.AddMonths(1); // don't respect calendar
     }
     Debug.Assert(Math.Abs(amount) < 0.01m);
     Debug.Assert(m_payments.Count == duration);
 }
コード例 #2
0
ファイル: CombinedCalendar.cs プロジェクト: wtain/FinCalc
 public void Add(Calendar calendar)
 {
     calendars.Add(calendar);
 }