diff options
author | John Wiegley <johnw@newartisans.com> | 2019-08-03 13:37:58 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2019-12-06 14:06:22 +0100 |
commit | f77bdf19c307811d4659b6e85d147cdd5eee5ef3 (patch) | |
tree | 7a3dcae3901cb1543feed902dce256cf3b751d69 /src/report.cc | |
parent | 6a140f313433e4ac21882d7995dbbb56124b4079 (diff) | |
download | fork-ledger-f77bdf19c307811d4659b6e85d147cdd5eee5ef3.tar.gz fork-ledger-f77bdf19c307811d4659b6e85d147cdd5eee5ef3.tar.bz2 fork-ledger-f77bdf19c307811d4659b6e85d147cdd5eee5ef3.zip |
Add --averaged-lot-prices
This joins together lots of the same underlying, averaging the reported price
and using the date of the oldest lot.
Diffstat (limited to 'src/report.cc')
-rw-r--r-- | src/report.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc index cc165184..c5d6d14e 100644 --- a/src/report.cc +++ b/src/report.cc @@ -563,6 +563,14 @@ value_t report_t::fn_should_bold(call_scope_t& scope) return false; } +value_t report_t::fn_averaged_lots(call_scope_t& args) +{ + if (args.has<balance_t>(0)) + return average_lot_prices(args.get<balance_t>(0)); + else + return args[0]; +} + value_t report_t::fn_market(call_scope_t& args) { value_t result; @@ -1130,6 +1138,7 @@ option_t<report_t> * report_t::lookup_option(const char * p) else OPT(average); else OPT(account_width_); else OPT(amount_width_); + else OPT(average_lot_prices); break; case 'b': OPT(balance_format_); @@ -1370,6 +1379,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind, return MAKE_FUNCTOR(report_t::fn_ansify_if); else if (is_eq(p, "abs")) return MAKE_FUNCTOR(report_t::fn_abs); + else if (is_eq(p, "averaged_lots")) + return MAKE_FUNCTOR(report_t::fn_averaged_lots); break; case 'b': |