Corrected calculation of market valuation expressions
This commit is contained in:
parent
c86bff2707
commit
17a84642fb
1 changed files with 12 additions and 6 deletions
|
|
@ -97,14 +97,20 @@ commodity_t::find_price_from_expr(expr_t& expr,
|
||||||
DEBUG("commodity.price.find", "");
|
DEBUG("commodity.price.find", "");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
call_scope_t call_args(*scope_t::default_scope);
|
value_t result(expr.calc(*scope_t::default_scope));
|
||||||
|
|
||||||
|
if (is_expr(result)) {
|
||||||
|
value_t call_args;
|
||||||
|
|
||||||
call_args.push_back(string_value(base_symbol()));
|
call_args.push_back(string_value(base_symbol()));
|
||||||
call_args.push_back(moment);
|
call_args.push_back(moment);
|
||||||
if (commodity)
|
if (commodity)
|
||||||
call_args.push_back(string_value(commodity->symbol()));
|
call_args.push_back(string_value(commodity->symbol()));
|
||||||
|
|
||||||
return price_point_t(moment, expr.calc(call_args).to_amount());
|
result = as_expr(result)->call(call_args, *scope_t::default_scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
return price_point_t(moment, result.to_amount());
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<price_point_t>
|
optional<price_point_t>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue