lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/004 296ee07 5/9: Set 7702 and 7702A interest


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/004 296ee07 5/9: Set 7702 and 7702A interest rates OAOO
Date: Tue, 29 Dec 2020 14:46:02 -0500 (EST)

branch: valyuta/004
commit 296ee072fafacf34c92ad14ee96f9a8452ef19e6
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Set 7702 and 7702A interest rates OAOO
    
    These rates are about to change; imbuing them with the OAOO nature now
    makes a correct change in their values more likely.
---
 Makefile.am          |  1 +
 gpt_server.cpp       |  5 ++++-
 gpt_test.cpp         |  5 +++--
 ihs_basicval.cpp     |  5 +++--
 interest_rates.cpp   |  9 +++++----
 irc7702_interest.hpp | 43 +++++++++++++++++++++++++++++++++++++++++++
 irc7702_tables.cpp   |  9 +++++----
 mec_server.cpp       |  3 ++-
 8 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1d7db18..24f9dc7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1360,6 +1360,7 @@ noinst_HEADERS = \
     input_sequence_parser.hpp \
     interest_rates.hpp \
     interpolate_string.hpp \
+    irc7702_interest.hpp \
     irc7702_tables.hpp \
     istream_to_string.hpp \
     ledger.hpp \
diff --git a/gpt_server.cpp b/gpt_server.cpp
index aa4e2a5..04f6b09 100644
--- a/gpt_server.cpp
+++ b/gpt_server.cpp
@@ -38,6 +38,7 @@
 #include "ieee754.hpp"                  // ldbl_eps_plus_one_times()
 #include "ihs_irc7702a.hpp"
 #include "ihs_server7702.hpp"           // RunServer7702FromStruct()
+#include "irc7702_interest.hpp"         // iglp(), igsp()
 #include "materially_equal.hpp"         // material_difference()
 #include "math_functions.hpp"
 #include "mc_enum_types_aux.hpp"        // mc_state_from_string()
@@ -197,9 +198,11 @@ gpt_state test_one_days_gpt_transactions
         (Mly7702iGlp
         ,apply_unary
             (i_upper_12_over_12_from_i<double>()
-            ,apply_binary(greater_of<double>(), 0.04, guar_int) - spread
+            ,apply_binary(greater_of<double>(), iglp(), guar_int) - spread
             )
         );
+    // TAXATION !! Similarly, GSP should be calculated, using igsp(), if
+    // this code is to be kept.
 
     std::vector<double> Mly7702ig;
     database.query_into(DB_NaarDiscount, Mly7702ig);
diff --git a/gpt_test.cpp b/gpt_test.cpp
index d590979..2f8420c 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -26,6 +26,7 @@
 
 #include "assert_lmi.hpp"
 #include "cso_table.hpp"
+#include "irc7702_interest.hpp"         // iglp(), igsp()
 #include "materially_equal.hpp"
 #include "math_functions.hpp"
 #include "ssize_lmi.hpp"
@@ -236,8 +237,8 @@ class gpt_test
 
 void gpt_test::initialize(int issue_age)
 {
-    static double const i_m_4 = i_upper_12_over_12_from_i<double>()(0.04);
-    static double const i_m_6 = i_upper_12_over_12_from_i<double>()(0.06);
+    static double const i_m_4 = i_upper_12_over_12_from_i<double>()(iglp());
+    static double const i_m_6 = i_upper_12_over_12_from_i<double>()(igsp());
     q_m = sample_q(issue_age);
     int const length = lmi::ssize(q_m);
     glp_ic               .assign(length,     i_m_4);
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 5bc92ed..e557a9b 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -41,6 +41,7 @@
 #include "ihs_irc7702a.hpp"
 #include "input.hpp"
 #include "interest_rates.hpp"
+#include "irc7702_interest.hpp"         // iglp(), igsp()
 #include "lingo.hpp"
 #include "loads.hpp"
 #include "math_functions.hpp"
@@ -456,7 +457,7 @@ void BasicValues::Init7702()
         (Mly7702iGlp
         ,apply_unary
             (i_upper_12_over_12_from_i<double>()
-            ,apply_binary(greater_of<double>(), 0.04, guar_int) - 
SpreadFor7702_
+            ,apply_binary(greater_of<double>(), iglp(), guar_int) - 
SpreadFor7702_
             )
         );
 
@@ -465,7 +466,7 @@ void BasicValues::Init7702()
         (Mly7702iGsp
         ,apply_unary
             (i_upper_12_over_12_from_i<double>()
-            ,apply_binary(greater_of<double>(), 0.06, guar_int) - 
SpreadFor7702_
+            ,apply_binary(greater_of<double>(), igsp(), guar_int) - 
SpreadFor7702_
             )
         );
 
diff --git a/interest_rates.cpp b/interest_rates.cpp
index 69001aa..7a797fe 100644
--- a/interest_rates.cpp
+++ b/interest_rates.cpp
@@ -28,6 +28,7 @@
 #include "basic_values.hpp"
 #include "database.hpp"
 #include "dbnames.hpp"
+#include "irc7702_interest.hpp"         // iglp(), igsp()
 #include "math_functions.hpp"           // assign_midpoint()
 #include "miscellany.hpp"               // each_equal()
 #include "ssize_lmi.hpp"
@@ -1022,12 +1023,12 @@ void InterestRates::Initialize7702Rates()
     std::vector<double> const& annual_guar_rate = 
GenAcctGrossRate_[mce_gen_guar];
 
     MlyGlpRate_.resize(Length_);
-    // ET !! MlyGlpRate_ = max(0.04, annual_guar_rate);
+    // ET !! MlyGlpRate_ = max(iglp(), annual_guar_rate);
     std::transform
         (annual_guar_rate.begin()
         ,annual_guar_rate.end()
         ,MlyGlpRate_.begin()
-        ,[](double x) { return std::max(0.04, x); }
+        ,[](double x) { return std::max(iglp(), x); }
         );
     // ET !! This ought to be implicit, at least in some 'safe' mode:
     LMI_ASSERT(MlyGlpRate_.size() == SpreadFor7702_.size());
@@ -1099,7 +1100,7 @@ void InterestRates::Initialize7702Rates()
 */
 
     // ET !! Mly7702iGlp = i_upper_12_over_12_from_i(max(.04, guar_int) - 
SpreadFor7702_);
-    Mly7702iGlp.assign(Length, 0.04);
+    Mly7702iGlp.assign(Length, iglp());
     std::transform
         (guar_int.begin()
         ,guar_int.end()
@@ -1122,7 +1123,7 @@ void InterestRates::Initialize7702Rates()
         );
 
     // ET !! Mly7702iGlp = i_upper_12_over_12_from_i(max(.06, guar_int) - 
SpreadFor7702_);
-    Mly7702iGsp.assign(Length, 0.06);
+    Mly7702iGsp.assign(Length, igsp());
     std::transform
         (guar_int.begin()
         ,guar_int.end()
diff --git a/irc7702_interest.hpp b/irc7702_interest.hpp
new file mode 100644
index 0000000..6438aac
--- /dev/null
+++ b/irc7702_interest.hpp
@@ -0,0 +1,43 @@
+// 7702 (and 7702A) interest rate.
+//
+// Copyright (C) 2020 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// https://savannah.nongnu.org/projects/lmi
+// email: <gchicares@sbcglobal.net>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#ifndef irc7702_interest_hpp
+#define irc7702_interest_hpp
+
+#include "config.hpp"
+
+#include "so_attributes.hpp"
+
+/// Statutory interest rate for 7702 and 7702A (except GSP).
+
+LMI_SO inline double iglp()
+{
+    return 0.04;
+}
+
+/// Statutory interest rate for 7702 (GSP only).
+
+LMI_SO inline double igsp()
+{
+    return 0.06;
+}
+
+#endif // irc7702_interest_hpp
diff --git a/irc7702_tables.cpp b/irc7702_tables.cpp
index 54c386b..d2ecade 100644
--- a/irc7702_tables.cpp
+++ b/irc7702_tables.cpp
@@ -27,6 +27,7 @@
 #include "commutation_functions.hpp"
 #include "cso_table.hpp"
 #include "et_vector.hpp"
+#include "irc7702_interest.hpp"         // iglp()
 #include "math_functions.hpp"
 #include "ssize_lmi.hpp"
 
@@ -54,12 +55,12 @@ irc7702_tables::irc7702_tables
     std::vector<double> q12(length_);
     assign(q12, apply_binary(coi_rate_from_q<double>(), q_, max_coi_rate));
 
-    // ic: 0.04 is the statutory rate.
+    // ic: iglp() is the statutory rate.
     // ig: Argument 'naar_discount' corresponds to DB_NaarDiscount,
     //   which is assumed to be rounded appropriately if at all.
     std::vector<double> const ic
         (length_
-        ,i_upper_12_over_12_from_i<double>()(0.04)
+        ,i_upper_12_over_12_from_i<double>()(iglp())
         );
     std::vector<double> const& ig(naar_discount);
 
@@ -77,8 +78,8 @@ irc7702_tables::irc7702_tables
     E7aN.erase(E7aN.begin(), 7 + E7aN.begin());
     ul_7pp_ += (ulcf.aDomega() + ulcf.kM()) / (ulcf.aN() - E7aN);
 
-    double const i_over_delta = 0.04 / std::log(1.04);
-    std::vector<double> const i(length_, 0.04);
+    double const i_over_delta = iglp() / std::log(1 + iglp());
+    std::vector<double> const i(length_, iglp());
     OLCommFns const olcf(q_, i);
 
     // Alternative calculations that may be useful someday are given
diff --git a/mec_server.cpp b/mec_server.cpp
index 4345919..ac22016 100644
--- a/mec_server.cpp
+++ b/mec_server.cpp
@@ -35,6 +35,7 @@
 #include "et_vector.hpp"
 #include "ieee754.hpp"                  // ldbl_eps_plus_one_times()
 #include "ihs_irc7702a.hpp"
+#include "irc7702_interest.hpp"         // iglp()
 #include "materially_equal.hpp"         // material_difference()
 #include "math_functions.hpp"
 #include "mc_enum_types_aux.hpp"        // mc_state_from_string()
@@ -180,7 +181,7 @@ mec_state test_one_days_7702A_transactions
         (Mly7702iGlp
         ,apply_unary
             (i_upper_12_over_12_from_i<double>()
-            ,apply_binary(greater_of<double>(), 0.04, guar_int) - spread
+            ,apply_binary(greater_of<double>(), iglp(), guar_int) - spread
             )
         );
 



reply via email to

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