[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
- [lmi-commits] [lmi] master updated (dc99d2e -> a62fbec), Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master d162b18 1/7: Improve documentation, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master e143602 3/7: Hard-code 7702 i for another unit test, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master 6c4deff 4/7: Use 7702 statutory i from database, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master 7b18d1d 2/7: Hard-code 7702 i for a unit test, Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master b7b20c4 5/7: Resurrect ancient code for 7702 (loan) interest,
Greg Chicares <=
- [lmi-commits] [lmi] master 1a3d3e6 6/7: Fix defect introduced 20050114T1947Z: used the wrong variable [301], Greg Chicares, 2021/02/22
- [lmi-commits] [lmi] master a62fbec 7/7: Loan rate affects 7702 if loans allowed, not only if elected, Greg Chicares, 2021/02/22