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 /src/report.h | |
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 'src/report.h')
-rw-r--r-- | src/report.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/report.h b/src/report.h index 5325c3a2..c1dc75c2 100644 --- a/src/report.h +++ b/src/report.h @@ -189,6 +189,8 @@ public: value_t fn_ansify_if(call_scope_t& scope); value_t fn_percent(call_scope_t& scope); value_t fn_commodity(call_scope_t& scope); + value_t fn_commodity_price(call_scope_t& scope); + value_t fn_set_commodity_price(call_scope_t& scope); value_t fn_nail_down(call_scope_t& scope); value_t fn_lot_date(call_scope_t& scope); value_t fn_lot_price(call_scope_t& scope); |