diff options
author | John Wiegley <johnw@newartisans.com> | 2020-04-23 14:44:30 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2020-04-23 14:46:19 -0700 |
commit | 4a86fe57a1b303bbfc983fba5e2ca4d35aee2416 (patch) | |
tree | e685af1c381b47a0260eb851e893a0a0c403d164 /tools | |
parent | 6b2d05306e9cac2ce5881d739fbbc86e365e7a9f (diff) | |
download | fork-ledger-4a86fe57a1b303bbfc983fba5e2ca4d35aee2416.tar.gz fork-ledger-4a86fe57a1b303bbfc983fba5e2ca4d35aee2416.tar.bz2 fork-ledger-4a86fe57a1b303bbfc983fba5e2ca4d35aee2416.zip |
Add two (for the moment undocumented) functions:
- commodity_price(NAME, DATE)
- set_commodity_price(NAME, DATE)
Using these two I am able to compute rate of return over a period of
transactions, taking additional deposits and withdrawals into account, using
the following automated transactions:
P 2019-12-31 12:00:00 ROI $1.00
2020-01-01 Start of record
(ROI) 0 ROI
= expr date >= [2020/01/01] && account =~ /Broker:Cash$/ and any(account =~ /Assets:Checking/)
(ROI) (1 ROI * (amount / commodity_price(1 ROI, date)))
= expr date >= [2020/01/01] && account =~ /:Capital:/
(ROI) (set_commodity_price(1 ROI, date, ((commodity_price(1 ROI, date) * account("ROI").amount) - amount) / account("ROI").amount) || 0 ROI)
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions