Git Product home page Git Product logo

compute_real_interest's Introduction

compute_real_interest

Reads a transaction history CSV file from Percent.com and for each investment in the file, reports the effective (real) interest rate.

Read a CSV file from Percent.com containing the transaction history for an account, and for each investment listed in the file, calculate the effective (real) interest rate from the first investment to the earlier of (1) the date the principal was paid off or (2) an "as-of" date supplied by the user, or if not supplied, the date the program is run.

Key insight

$\text{total interest paid} = \text{rate} \cdot \int_t balance(t)$, where $balance(t)$ is the outstanding principal at time $t$.

Therefore, $\text{effective rate} = (\text{total interest paid} - \text{fees}) / \int_t balance(t)$ .

Assumptions

  1. The file goes all the way back, i.e. each investment's initial deposit is listed in the file.
  2. The file is current, i.e. no transactions have occurred since the last item listed in the file.
  3. This version does not account for sale or purchase of an existing investment to/from another investor, a feature Percent.com says they're planning to implement.
  4. The user wants to interpret any fee associated with an investment as a reduction in the effective interest rate paid.
  5. The file has transactions listed in reverse chronological order, i.e. with the newest entries at the top of the file after a header row.
  6. Principal is only added to a given investment once (which is how Percent.com investments have worked so far).
  7. A year = 365 days (not, e.g., 360 days).

Sample output

Input:

python compute_real_interest.py Percent_History_2024_02_16.csv # run on Feb. 19, 2024

Output:

Unhandled CSV file row(s):
{'Date': '2022-06-17', 'Transaction Type': 'Credit - Promotion', 'Description': 'Promotion', 'Amount': '150.00'}
{'Date': '2023-04-24', 'Transaction Type': 'Credit - Adjustment', 'Description': 'Other adjustment (credit)', 'Amount': '20.00'}

Summary of effective interest rate for each investment in this account:
=======================================================================
    Code      Initial P  Interest     Fees    Balance  Effective rate
=======================================================================
 CFI1 2023-2   $  2,550  $    160  $      0  $  1,973       15.3% *
 ESP1 2022-1   $    653  $     19  $      0  $      0       11.8%
 FTL1 2023-1   $    603  $     16  $      0  $      0       12.0%
 IDG1 2022-8   $    775  $     53  $      0  $     -0       11.0%
 PBN1 2023-1   $  5,000  $    645  $     71  $  5,000       10.9% *
 PBN6 2023-1   $  5,097  $    467  $     58  $  5,097       10.5% *
 PCT1 2022-1   $  2,000  $    225  $      0  $      0       14.9%
 RAP1 2022-6   $    500  $     12  $      0  $      0       13.8%
 TAP1 2022-5   $    500  $      5  $      0  $      0        9.0%
 TOR1 2022-5   $    500  $     14  $      0  $      0       11.3%
 TSM1 2023-1   $  1,000  $     40  $      0  $      0       16.0%
 TSM1 2023-3   $  1,000  $     53  $      0  $      0       15.8%
 WSF1 2022-2   $    500  $     50  $      0  $      0       15.0%
 WSF1 2022-3   $    535  $     59  $      0  $      0       15.0%
 WSF1 2023-4   $    764  $     93  $      0  $     -0       17.4%
 WSF1 2023-7   $  5,098  $    468  $      0  $  5,098       17.3% *
 WSF1 2023-9   $  2,666  $    152  $     15  $  2,666       14.1% *
=======================================================================
               $ 29,741  $  2,531  $    144  $ 19,834       13.6%

Mean effective rate 13.6% is weighted by initial principal.

* = effective rate will increase if interest is paid after 2024-02-19.

compute_real_interest's People

Contributors

kbmd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.