| 1 | # Compute Returns |
| 2 | |
| 3 | This directory contains code which computes investment returns on a variety of |
| 4 | assets, as recorded by Beancount, fed directly from a Beancount file. |
| 5 | |
| 6 | See this document for details: |
| 7 | https://docs.google.com/document/d/1nPsMIunLnDvdsg6TSsd0PZb7jngojNpFlqnaX36WRp8/ |
| 8 | |
| 9 | ## Scripts |
| 10 | |
| 11 | There are three related scripts: |
| 12 | |
| 13 | - configure.py: This attempts to automatically infer and generate configuration |
| 14 | to compute returns from an existing Beancount ledger. |
| 15 | |
| 16 | - compute_returns.py: This extracts data for each of the investments defined in |
| 17 | the configuration and computes the returns and generates output for each |
| 18 | requested returns report. |
| 19 | |
| 20 | - download_prices.py: The compute_returns.py script outputs a list of missing |
| 21 | (or inadequately dated) price directives to properly do its job as a |
| 22 | side-product. This script can read that file and fetch those missing dates, |
| 23 | which you can insert in your ledger and then rerun compute_returns.py for a |
| 24 | more precise calculation. |
| 25 | |
| 26 | ## Example |
| 27 | |
| 28 | To run the example: |
| 29 | ``` |
| 30 | cd example |
| 31 | uv run beangrow-returns ledger.beancount config.pbtxt ./reports |
| 32 | ``` |
| 33 | |
| 34 | The reports are available at `example/reports/groups`. |