From f77bdf19c307811d4659b6e85d147cdd5eee5ef3 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 3 Aug 2019 13:37:58 -0700 Subject: Add --averaged-lot-prices This joins together lots of the same underlying, averaging the reported price and using the date of the oldest lot. --- src/report.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/report.cc') 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(0)) + return average_lot_prices(args.get(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::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': -- cgit v1.2.3