lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master d80db0d 4/5: Refactor to make monthly-deducti


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d80db0d 4/5: Refactor to make monthly-deduction discount factor accessible
Date: Tue, 6 Jun 2017 17:30:30 -0400 (EDT)

branch: master
commit d80db0d4445de16885e6d5d3748f7d3feaac148e
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Refactor to make monthly-deduction discount factor accessible
    
    Formerly, this discount factor was used only for calculating an annuity
    rate, so a single function calculated the former and returned the
    latter.  Soon the discount factor will be needed for another purpose,
    so it deserved a function of its own due to its complexity. The annuity
    calculation is so trivial that it is simply inlined.
---
 basic_values.hpp |  2 +-
 ihs_basicval.cpp | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/basic_values.hpp b/basic_values.hpp
index e618d43..fc4c6e2 100644
--- a/basic_values.hpp
+++ b/basic_values.hpp
@@ -381,7 +381,7 @@ class LMI_SO BasicValues
         ,oenum_modal_prem_type premium_type
         ) const;
     double GetModalSpecAmtMlyDed(double annualized_pmt, mcenum_mode) const;
-    double GetAnnuityValueMlyDed(int a_year, mcenum_mode a_mode) const;
+    double mly_ded_discount_factor(int year, mcenum_mode mode) const;
 
     std::vector<double> GetActuarialTable
         (std::string const& TableFile
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 8d320da..cc1b72f 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -1136,7 +1136,8 @@ double BasicValues::GetModalPremMlyDed
 
     z /= 1.0 - Loads_->target_premium_load_maximum_premium_tax()[a_year];
 
-    z *= GetAnnuityValueMlyDed(a_year, a_mode);
+    double const v12 = mly_ded_discount_factor(a_year, a_mode);
+    z *= (1.0 - std::pow(v12, 12.0 / a_mode)) / (1.0 - v12);
 
     z += annual_charge;
 
@@ -1466,7 +1467,7 @@ std::vector<double> const& BasicValues::GetBandedCoiRates
         }
 }
 
-/// Calculate a special modal factor on the fly.
+/// Calculate a monthly-deduction discount factor on the fly.
 ///
 /// This factor depends on the general-account rate, which is always
 /// specified, even for separate-account-only products.
@@ -1477,16 +1478,16 @@ std::vector<double> const& 
BasicValues::GetBandedCoiRates
 /// may not prevent the contract from lapsing; both those outcomes are
 /// likely to frustrate customers.
 
-double BasicValues::GetAnnuityValueMlyDed(int a_year, mcenum_mode a_mode) const
+double BasicValues::mly_ded_discount_factor(int year, mcenum_mode mode) const
 {
-    LMI_ASSERT(0.0 != a_mode);
+    LMI_ASSERT(0.0 != mode);
     double spread = 0.0;
-    if(mce_monthly != a_mode)
+    if(mce_monthly != mode)
         {
-        spread = MinPremIntSpread_[a_year] * 1.0 / a_mode;
+        spread = MinPremIntSpread_[year] * 1.0 / mode;
         }
     double z = i_upper_12_over_12_from_i<double>()
-        (   yare_input_.GeneralAccountRate[a_year]
+        (   yare_input_.GeneralAccountRate[year]
         -   spread
         );
     double const u = 1.0 + std::max
@@ -1494,10 +1495,9 @@ double BasicValues::GetAnnuityValueMlyDed(int a_year, 
mcenum_mode a_mode) const
         ,InterestRates_->GenAcctNetRate
             (mce_gen_guar
             ,mce_monthly_rate
-            )[a_year]
+            )[year]
         );
-    double const v12 = 1.0 / u;
-    return (1.0 - std::pow(v12, 12.0 / a_mode)) / (1.0 - v12);
+    return 1.0 / u;
 }
 
 /// This forwarding function prevents the 'actuarial_table' module



reply via email to

[Prev in Thread] Current Thread [Next in Thread]