lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master b7b20c4 5/7: Resurrect ancient code for 7702


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b7b20c4 5/7: Resurrect ancient code for 7702 (loan) interest
Date: Mon, 22 Feb 2021 07:46:31 -0500 (EST)

branch: master
commit b7b20c480c3e94cd7b6b2021f118820fdb2f0c24
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Resurrect ancient code for 7702 (loan) interest
    
    View this revision with '--ignore-all-space' to see clearly that it
    changes the condition on a block, from unconditional suppression with
    '/*...*/', to conditional with 'if(condition) {}', depending on the
    recently added database entity DB_IgnoreLoanRateFor7702.
    
    Although the resurrected code (which has been suppressed since before
    the lmi epoch) contains a (marked) defect, this commit has no effect on
    regression tests because it suppresses DB_IgnoreLoanRateFor7702 for the
    nonce.
---
 dbdict.cpp       |  2 ++
 ihs_basicval.cpp | 80 +++++++++++++++++++++++++++++---------------------------
 2 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/dbdict.cpp b/dbdict.cpp
index a7baf1d..f1d64dc 100644
--- a/dbdict.cpp
+++ b/dbdict.cpp
@@ -1493,6 +1493,8 @@ sample2xyz::sample2xyz()
     // This is determined by law, in a way that varies by product;
     // 2021 products use this two-percent rate.
     Add({DB_AnnInterestRate7702 , 0.02});
+    // Temporary workaround to sidestep a defect in revived code:
+    Add({DB_IgnoreLoanRateFor7702, true});
     // Arguably the most complex ledger type.
     Add({DB_LedgerType          , mce_finra});
     // Certain group-quote columns are available only when these two
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index c166b95..ff8f833 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -434,49 +434,51 @@ void BasicValues::Init7702()
 
     std::vector<double> guar_int;
     database().query_into(DB_GuarInt, guar_int);
-// TAXATION !! Rework this. The intention is to make the 7702 interest
-// rate no less, at any duration, than the guaranteed loan rate--here,
-// the fixed rate charged on loans, minus the guaranteed loan spread
-// (if any).
-/*
-    switch(yare_input_.LoanRateType)
+
+    if(!database().query<bool>(DB_IgnoreLoanRateFor7702))
         {
-        case mce_fixed_loan_rate:
-            {
-            std::vector<double> gross_loan_rate;
-            database().query_into(DB_FixedLoanRate    , gross_loan_rate);
-            std::vector<double> guar_loan_spread;
-            database().query_into(DB_GuarRegLoanSpread, guar_loan_spread);
-            // ET !! std::vector<double> guar_loan_rate = gross_loan_rate - 
guar_loan_spread;
-            std::vector<double> guar_loan_rate(Length);
-            std::transform
-                (gross_loan_rate.begin()
-                ,gross_loan_rate.end()
-                ,guar_loan_spread.begin()
-                ,guar_loan_rate.begin()
-                ,std::minus<double>()
-                );
-            // ET !! guar_int = max(guar_int, guar_loan_spread);
-            // TODO ?? But that looks incorrect when written clearly!
-            // Perhaps this old comment:
-            //   APL: guar_int gets guar_int max gross_loan_rate - 
guar_loan_spread
-            // suggests the actual intention.
-            std::transform
-                (guar_int.begin()
-                ,guar_int.end()
-                ,guar_loan_spread.begin()
-                ,guar_int.begin()
-                ,greater_of<double>()
-                );
-            }
-            break;
-        case mce_variable_loan_rate:
+    // TAXATION !! Rework this. The intention is to make the 7702 interest
+    // rate no less, at any duration, than the guaranteed loan rate--here,
+    // the fixed rate charged on loans, minus the guaranteed loan spread
+    // (if any).
+        switch(yare_input_.LoanRateType)
             {
-            // do nothing
+            case mce_fixed_loan_rate:
+                {
+                std::vector<double> gross_loan_rate;
+                database().query_into(DB_FixedLoanRate    , gross_loan_rate);
+                std::vector<double> guar_loan_spread;
+                database().query_into(DB_GuarRegLoanSpread, guar_loan_spread);
+                // ET !! std::vector<double> guar_loan_rate = gross_loan_rate 
- guar_loan_spread;
+                std::vector<double> guar_loan_rate(Length);
+                std::transform
+                    (gross_loan_rate.begin()
+                    ,gross_loan_rate.end()
+                    ,guar_loan_spread.begin()
+                    ,guar_loan_rate.begin()
+                    ,std::minus<double>()
+                    );
+                // ET !! guar_int = max(guar_int, guar_loan_spread);
+                // TODO ?? But that looks incorrect when written clearly!
+                // Perhaps this old comment:
+                //   APL: guar_int gets guar_int max gross_loan_rate - 
guar_loan_spread
+                // suggests the actual intention.
+                std::transform
+                    (guar_int.begin()
+                    ,guar_int.end()
+                    ,guar_loan_spread.begin()
+                    ,guar_int.begin()
+                    ,greater_of<double>()
+                    );
+                }
+                break;
+            case mce_variable_loan_rate:
+                {
+                // do nothing
+                }
+                break;
             }
-            break;
         }
-*/
 
     Mly7702iGlp.assign(Length, 0.0);
     assign



reply via email to

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