Tighten up argument passing related to fn_market()

This commit is contained in:
John Wiegley 2012-03-11 03:55:25 -05:00
parent 2303aa993c
commit 363670d35b
21 changed files with 154 additions and 161 deletions

View file

@ -728,16 +728,16 @@ void amount_t::in_place_unreduce()
}
optional<amount_t>
amount_t::value(const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of) const
amount_t::value(const datetime_t& moment,
const commodity_t * in_terms_of) const
{
if (quantity) {
#if defined(DEBUG_ON)
DEBUG("commodity.price.find",
"amount_t::value of " << commodity().symbol());
if (moment)
if (! moment.is_not_a_date_time())
DEBUG("commodity.price.find",
"amount_t::value: moment = " << *moment);
"amount_t::value: moment = " << moment);
if (in_terms_of)
DEBUG("commodity.price.find",
"amount_t::value: in_terms_of = " << in_terms_of->symbol());
@ -745,7 +745,7 @@ amount_t::value(const optional<datetime_t>& moment,
if (has_commodity() &&
(in_terms_of || ! commodity().has_flags(COMMODITY_PRIMARY))) {
optional<price_point_t> point;
optional<commodity_t&> comm(in_terms_of);
const commodity_t * comm(in_terms_of);
if (has_annotation() && annotation().price) {
if (annotation().has_flags(ANNOTATION_PRICE_FIXATED)) {
@ -755,7 +755,7 @@ amount_t::value(const optional<datetime_t>& moment,
"amount_t::value: fixated price = " << point->price);
}
else if (! comm) {
comm = annotation().price->commodity();
comm = annotation().price->commodity_ptr();
}
}
@ -869,15 +869,10 @@ bool amount_t::fits_in_long() const
commodity_t * amount_t::commodity_ptr() const
{
return (has_commodity() ?
return (commodity_ ?
commodity_ : commodity_pool_t::current_pool->null_commodity);
}
commodity_t& amount_t::commodity() const
{
return *commodity_ptr();
}
bool amount_t::has_commodity() const
{
return commodity_ && commodity_ != commodity_->pool().null_commodity;

View file

@ -404,8 +404,8 @@ public:
$100.00.
*/
optional<amount_t>
value(const optional<datetime_t>& moment = none,
const optional<commodity_t&>& in_terms_of = none) const;
value(const datetime_t& moment = datetime_t(),
const commodity_t * in_terms_of = NULL) const;
optional<amount_t> price() const;
@ -534,7 +534,9 @@ public:
useful for accessing just the numeric portion of an amount.
*/
commodity_t * commodity_ptr() const;
commodity_t& commodity() const;
commodity_t& commodity() const {
return *commodity_ptr();
}
bool has_commodity() const;
void set_commodity(commodity_t& comm) {

View file

@ -241,16 +241,16 @@ bool annotated_commodity_t::operator==(const commodity_t& comm) const
}
optional<price_point_t>
annotated_commodity_t::find_price(const optional<commodity_t&>& commodity,
const optional<datetime_t>& moment,
const optional<datetime_t>& oldest) const
annotated_commodity_t::find_price(const commodity_t * commodity,
const datetime_t& moment,
const datetime_t& oldest) const
{
DEBUG("commodity.price.find",
"annotated_commodity_t::find_price(" << symbol() << ")");
datetime_t when;
if (moment)
when = *moment;
if (! moment.is_not_a_date_time())
when = moment;
else if (epoch)
when = *epoch;
else
@ -258,7 +258,7 @@ annotated_commodity_t::find_price(const optional<commodity_t&>& commodity,
DEBUG("commodity.price.find", "reference time: " << when);
optional<commodity_t&> target;
const commodity_t * target = NULL;
if (commodity)
target = commodity;
@ -272,7 +272,7 @@ annotated_commodity_t::find_price(const optional<commodity_t&>& commodity,
}
else if (! target) {
DEBUG("commodity.price.find", "setting target commodity from price");
target = details.price->commodity();
target = details.price->commodity_ptr();
}
}
@ -285,7 +285,7 @@ annotated_commodity_t::find_price(const optional<commodity_t&>& commodity,
return find_price_from_expr(const_cast<expr_t&>(*details.value_expr),
commodity, when);
return commodity_t::find_price(commodity, moment, oldest);
return commodity_t::find_price(target, moment, oldest);
}
commodity_t&

View file

@ -256,9 +256,9 @@ public:
}
optional<price_point_t>
virtual find_price(const optional<commodity_t&>& commodity = none,
const optional<datetime_t>& moment = none,
const optional<datetime_t>& oldest = none) const;
virtual find_price(const commodity_t * commodity = NULL,
const datetime_t& moment = datetime_t(),
const datetime_t& oldest = datetime_t()) const;
virtual commodity_t& strip_annotations(const keep_details_t& what_to_keep);
virtual void write_annotations(std::ostream& out,

View file

@ -185,8 +185,8 @@ balance_t& balance_t::operator/=(const amount_t& amt)
}
optional<balance_t>
balance_t::value(const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of) const
balance_t::value(const datetime_t& moment,
const commodity_t * in_terms_of) const
{
balance_t temp;
bool resolved = false;

View file

@ -384,8 +384,8 @@ public:
}
optional<balance_t>
value(const optional<datetime_t>& moment = none,
const optional<commodity_t&>& in_terms_of = none) const;
value(const datetime_t& moment = datetime_t(),
const commodity_t * in_terms_of = NULL) const;
/**
* Truth tests. An balance may be truth test in two ways:

View file

@ -71,12 +71,12 @@ void commodity_t::remove_price(const datetime_t& date, commodity_t& commodity)
}
void commodity_t::map_prices(function<void(datetime_t, const amount_t&)> fn,
const optional<datetime_t>& moment,
const optional<datetime_t>& _oldest)
const datetime_t& moment,
const datetime_t& _oldest)
{
datetime_t when;
if (moment)
when = *moment;
if (! moment.is_not_a_date_time())
when = moment;
else if (epoch)
when = *epoch;
else
@ -86,8 +86,7 @@ void commodity_t::map_prices(function<void(datetime_t, const amount_t&)> fn,
}
optional<price_point_t>
commodity_t::find_price_from_expr(expr_t& expr,
const optional<commodity_t&>& commodity,
commodity_t::find_price_from_expr(expr_t& expr, const commodity_t * commodity,
const datetime_t& moment) const
{
#if defined(DEBUG_ON)
@ -114,31 +113,30 @@ commodity_t::find_price_from_expr(expr_t& expr,
}
optional<price_point_t>
commodity_t::find_price(const optional<commodity_t&>& commodity,
const optional<datetime_t>& moment,
const optional<datetime_t>& oldest) const
commodity_t::find_price(const commodity_t * commodity,
const datetime_t& moment,
const datetime_t& oldest) const
{
DEBUG("commodity.price.find", "commodity_t::find_price(" << symbol() << ")");
optional<commodity_t&> target;
const commodity_t * target = NULL;
if (commodity)
target = commodity;
else if (pool().default_commodity)
target = *pool().default_commodity;
target = &*pool().default_commodity;
if (target && *this == *target)
if (target && this == target)
return none;
optional<base_t::memoized_price_entry>
entry(base_t::memoized_price_entry(moment, oldest,
commodity ? &(*commodity) : NULL));
base_t::memoized_price_entry entry(moment, oldest,
commodity ? commodity : NULL);
DEBUG("commodity.price.find", "looking for memoized args: "
<< (moment ? format_datetime(*moment) : "NONE") << ", "
<< (oldest ? format_datetime(*oldest) : "NONE") << ", "
<< (! moment.is_not_a_date_time() ? format_datetime(moment) : "NONE") << ", "
<< (! oldest.is_not_a_date_time() ? format_datetime(oldest) : "NONE") << ", "
<< (commodity ? commodity->symbol() : "NONE"));
{
base_t::memoized_price_map::iterator i = base->price_map.find(*entry);
base_t::memoized_price_map::iterator i = base->price_map.find(entry);
if (i != base->price_map.end()) {
DEBUG("commodity.price.find", "found! returning: "
<< ((*i).second ? (*i).second->price : amount_t(0L)));
@ -147,8 +145,8 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
}
datetime_t when;
if (moment)
when = *moment;
if (! moment.is_not_a_date_time())
when = moment;
else if (epoch)
when = *epoch;
else
@ -157,40 +155,40 @@ commodity_t::find_price(const optional<commodity_t&>& commodity,
if (base->value_expr)
return find_price_from_expr(*base->value_expr, commodity, when);
optional<price_point_t> point =
target ?
pool().commodity_price_history.find_price(*this, *target, when, oldest) :
pool().commodity_price_history.find_price(*this, when, oldest);
if (entry) {
if (base->price_map.size() > base_t::max_price_map_size) {
DEBUG("history.find",
"price map has grown too large, clearing it by half");
for (std::size_t i = 0; i < base_t::max_price_map_size >> 1; i++)
base->price_map.erase(base->price_map.begin());
}
optional<price_point_t>
point(target ?
pool().commodity_price_history.find_price(*this, *target,
when, oldest) :
pool().commodity_price_history.find_price(*this, when, oldest));
// Record this price point in the memoization map
if (base->price_map.size() > base_t::max_price_map_size) {
DEBUG("history.find",
"remembered: " << (point ? point->price : amount_t(0L)));
base->price_map.insert(base_t::memoized_price_map::value_type(*entry, point));
"price map has grown too large, clearing it by half");
for (std::size_t i = 0; i < base_t::max_price_map_size >> 1; i++)
base->price_map.erase(base->price_map.begin());
}
DEBUG("history.find",
"remembered: " << (point ? point->price : amount_t(0L)));
base->price_map.insert(base_t::memoized_price_map::value_type(entry, point));
return point;
}
optional<price_point_t>
commodity_t::check_for_updated_price(const optional<price_point_t>& point,
const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of)
const datetime_t& moment,
const commodity_t* in_terms_of)
{
if (pool().get_quotes && ! has_flags(COMMODITY_NOMARKET)) {
bool exceeds_leeway = true;
if (point) {
time_duration_t::sec_type seconds_diff;
if (moment) {
seconds_diff = (*moment - point->when).total_seconds();
DEBUG("commodity.download", "moment = " << *moment);
if (! moment.is_not_a_date_time()) {
seconds_diff = (moment - point->when).total_seconds();
DEBUG("commodity.download", "moment = " << moment);
DEBUG("commodity.download", "slip.moment = " << seconds_diff);
} else {
seconds_diff = (TRUE_CURRENT_TIME() - point->when).total_seconds();
@ -209,7 +207,7 @@ commodity_t::check_for_updated_price(const optional<price_point_t>& point,
pool().get_commodity_quote(*this, in_terms_of)) {
if (! in_terms_of ||
(quote->price.has_commodity() &&
quote->price.commodity() == *in_terms_of))
quote->price.commodity_ptr() == in_terms_of))
return quote;
}
}

View file

@ -117,12 +117,12 @@ protected:
optional<amount_t> larger;
optional<expr_t> value_expr;
typedef tuple<optional<datetime_t>,
optional<datetime_t>, commodity_t *> memoized_price_entry;
typedef tuple<datetime_t, datetime_t,
const commodity_t *> memoized_price_entry;
typedef std::map<memoized_price_entry,
optional<price_point_t> > memoized_price_map;
static const std::size_t max_price_map_size = 16;
static const std::size_t max_price_map_size = 8;
mutable memoized_price_map price_map;
public:
@ -272,22 +272,22 @@ public:
void remove_price(const datetime_t& date, commodity_t& commodity);
void map_prices(function<void(datetime_t, const amount_t&)> fn,
const optional<datetime_t>& moment = none,
const optional<datetime_t>& _oldest = none);
const datetime_t& moment = datetime_t(),
const datetime_t& _oldest = datetime_t());
optional<price_point_t>
find_price_from_expr(expr_t& expr, const optional<commodity_t&>& commodity,
find_price_from_expr(expr_t& expr, const commodity_t * commodity,
const datetime_t& moment) const;
optional<price_point_t>
virtual find_price(const optional<commodity_t&>& commodity = none,
const optional<datetime_t>& moment = none,
const optional<datetime_t>& oldest = none) const;
virtual find_price(const commodity_t * commodity = NULL,
const datetime_t& moment = datetime_t(),
const datetime_t& oldest = datetime_t()) const;
optional<price_point_t>
check_for_updated_price(const optional<price_point_t>& point,
const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of);
const datetime_t& moment,
const commodity_t * in_terms_of);
commodity_t& nail_down(const expr_t& expr);

View file

@ -52,15 +52,15 @@ public:
PricePointMap price_point;
PriceRatioMap ratios;
datetime_t reftime;
optional<datetime_t> oldest;
datetime_t reftime;
datetime_t oldest;
recent_edge_weight() { }
recent_edge_weight(EdgeWeightMap _weight,
PricePointMap _price_point,
PriceRatioMap _ratios,
datetime_t _reftime,
const optional<datetime_t>& _oldest = none)
recent_edge_weight(EdgeWeightMap _weight,
PricePointMap _price_point,
PriceRatioMap _ratios,
const datetime_t& _reftime,
const datetime_t& _oldest = datetime_t())
: weight(_weight), price_point(_price_point), ratios(_ratios),
reftime(_reftime), oldest(_oldest) { }
@ -69,8 +69,8 @@ public:
{
#if defined(DEBUG_ON)
DEBUG("history.find", " reftime = " << reftime);
if (oldest) {
DEBUG("history.find", " oldest = " << *oldest);
if (! oldest.is_not_a_date_time()) {
DEBUG("history.find", " oldest = " << oldest);
}
#endif
@ -88,7 +88,7 @@ public:
--low;
assert(((*low).first <= reftime));
if (oldest && (*low).first < *oldest) {
if (! oldest.is_not_a_date_time() && (*low).first < oldest) {
DEBUG("history.find", " edge is out of range");
return false;
}
@ -170,9 +170,9 @@ void commodity_history_t::remove_price(const commodity_t& source,
void commodity_history_t::map_prices(function<void(datetime_t,
const amount_t&)> fn,
const commodity_t& source,
const datetime_t& moment,
const optional<datetime_t>& oldest)
const commodity_t& source,
const datetime_t& moment,
const datetime_t& oldest)
{
vertex_descriptor sv = vertex(*source.graph_index(), price_graph);
@ -193,7 +193,7 @@ void commodity_history_t::map_prices(function<void(datetime_t,
foreach (const price_map_t::value_type& pair, prices) {
const datetime_t& when(pair.first);
if ((! oldest || when >= *oldest) && when <= moment) {
if ((oldest.is_not_a_date_time() || when >= oldest) && when <= moment) {
if (pair.second.commodity() == source) {
amount_t price(pair.second);
price.in_place_invert();
@ -209,9 +209,9 @@ void commodity_history_t::map_prices(function<void(datetime_t,
}
optional<price_point_t>
commodity_history_t::find_price(const commodity_t& source,
const datetime_t& moment,
const optional<datetime_t>& oldest)
commodity_history_t::find_price(const commodity_t& source,
const datetime_t& moment,
const datetime_t& oldest)
{
vertex_descriptor sv = vertex(*source.graph_index(), price_graph);
@ -270,10 +270,10 @@ commodity_history_t::find_price(const commodity_t& source,
}
optional<price_point_t>
commodity_history_t::find_price(const commodity_t& source,
const commodity_t& target,
const datetime_t& moment,
const optional<datetime_t>& oldest)
commodity_history_t::find_price(const commodity_t& source,
const commodity_t& target,
const datetime_t& moment,
const datetime_t& oldest)
{
vertex_descriptor sv = vertex(*source.graph_index(), price_graph);
vertex_descriptor tv = vertex(*target.graph_index(), price_graph);
@ -402,17 +402,16 @@ private:
Name name;
};
void commodity_history_t::print_map(std::ostream& out,
const optional<datetime_t>& moment)
void commodity_history_t::print_map(std::ostream& out, const datetime_t& moment)
{
if (moment) {
FGraph fg(price_graph,
recent_edge_weight<EdgeWeightMap, PricePointMap, PriceRatioMap>
(get(edge_weight, price_graph), pricemap, ratiomap, *moment));
write_graphviz(out, fg, label_writer<FNameMap>(get(vertex_name, fg)));
} else {
if (moment.is_not_a_date_time()) {
write_graphviz(out, price_graph,
label_writer<NameMap>(get(vertex_name, price_graph)));
} else {
FGraph fg(price_graph,
recent_edge_weight<EdgeWeightMap, PricePointMap, PriceRatioMap>
(get(edge_weight, price_graph), pricemap, ratiomap, moment));
write_graphviz(out, fg, label_writer<FNameMap>(get(vertex_name, fg)));
}
}

View file

@ -111,23 +111,22 @@ public:
const datetime_t& date);
void map_prices(function<void(datetime_t, const amount_t&)> fn,
const commodity_t& source,
const datetime_t& moment,
const optional<datetime_t>& _oldest = none);
const commodity_t& source,
const datetime_t& moment,
const datetime_t& _oldest = datetime_t());
optional<price_point_t>
find_price(const commodity_t& source,
const datetime_t& moment,
const optional<datetime_t>& oldest = none);
find_price(const commodity_t& source,
const datetime_t& moment,
const datetime_t& oldest = datetime_t());
optional<price_point_t>
find_price(const commodity_t& source,
const commodity_t& target,
const datetime_t& moment,
const optional<datetime_t>& oldest = none);
find_price(const commodity_t& source,
const commodity_t& target,
const datetime_t& moment,
const datetime_t& oldest = datetime_t());
void print_map(std::ostream& out,
const optional<datetime_t>& moment = none);
void print_map(std::ostream& out, const datetime_t& moment = datetime_t());
};
} // namespace ledger

View file

@ -83,13 +83,12 @@ public:
bool get_quotes; // --download
function<optional<price_point_t>
(commodity_t& commodity, const optional<commodity_t&>& in_terms_of)>
(commodity_t& commodity, const commodity_t * in_terms_of)>
get_commodity_quote;
static shared_ptr<commodity_pool_t> current_pool;
explicit commodity_pool_t();
virtual ~commodity_pool_t() {
TRACE_DTOR(commodity_pool_t);
}

View file

@ -48,12 +48,12 @@ namespace {
return amount.value(CURRENT_TIME());
}
boost::optional<amount_t> py_value_1(const amount_t& amount,
commodity_t& in_terms_of) {
const commodity_t * in_terms_of) {
return amount.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<amount_t> py_value_2(const amount_t& amount,
commodity_t& in_terms_of,
datetime_t& moment) {
const commodity_t * in_terms_of,
const datetime_t& moment) {
return amount.value(moment, in_terms_of);
}

View file

@ -48,12 +48,12 @@ namespace {
return balance.value(CURRENT_TIME());
}
boost::optional<balance_t> py_value_1(const balance_t& balance,
commodity_t& in_terms_of) {
const commodity_t * in_terms_of) {
return balance.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<balance_t> py_value_2(const balance_t& balance,
commodity_t& in_terms_of,
datetime_t& moment) {
const commodity_t * in_terms_of,
const datetime_t& moment) {
return balance.value(moment, in_terms_of);
}

View file

@ -51,12 +51,12 @@ namespace {
return value.value(CURRENT_TIME());
}
boost::optional<value_t> py_value_1(const value_t& value,
commodity_t& in_terms_of) {
const commodity_t * in_terms_of) {
return value.value(CURRENT_TIME(), in_terms_of);
}
boost::optional<value_t> py_value_2(const value_t& value,
commodity_t& in_terms_of,
datetime_t& moment) {
const commodity_t * in_terms_of,
const datetime_t& moment) {
return value.value(moment, in_terms_of);
}

View file

@ -40,7 +40,7 @@ namespace ledger {
optional<price_point_t>
commodity_quote_from_script(commodity_t& commodity,
const optional<commodity_t&>& exchange_commodity)
const commodity_t * exchange_commodity)
{
DEBUG("commodity.download", "downloading quote for symbol " << commodity.symbol());
#if defined(DEBUG_ON)

View file

@ -46,7 +46,7 @@ namespace ledger {
optional<price_point_t>
commodity_quote_from_script(commodity_t& commodity,
const optional<commodity_t&>& exchange_commodity);
const commodity_t * exchange_commodity);
} // namespace ledger

View file

@ -532,12 +532,13 @@ value_t report_t::fn_should_bold(call_scope_t& scope)
value_t report_t::fn_market(call_scope_t& args)
{
optional<datetime_t> moment = (args.has<datetime_t>(1) ?
args.get<datetime_t>(1) :
optional<datetime_t>());
value_t result;
value_t arg0 = args[0];
datetime_t moment;
if (args.has<datetime_t>(1))
moment = args.get<datetime_t>(1);
if (arg0.is_string()) {
amount_t tmp(1L);
commodity_t * commodity =
@ -962,7 +963,7 @@ value_t report_t::pricemap_command(call_scope_t& args)
std::ostream& out(output_stream);
commodity_pool_t::current_pool->commodity_price_history.print_map
(out, args.has<string>(0) ?
optional<datetime_t>(datetime_t(parse_date(args.get<string>(0)))) : none);
datetime_t(parse_date(args.get<string>(0))) : datetime_t());
return true;
}

View file

@ -1399,8 +1399,8 @@ bool value_t::is_zero() const
return false;
}
value_t value_t::value(const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of) const
value_t value_t::value(const datetime_t& moment,
const commodity_t * in_terms_of) const
{
switch (type()) {
case INTEGER:
@ -1432,9 +1432,9 @@ value_t value_t::value(const optional<datetime_t>& moment,
return NULL_VALUE;
}
value_t value_t::exchange_commodities(const std::string& commodities,
const bool add_prices,
const optional<datetime_t>& moment)
value_t value_t::exchange_commodities(const std::string& commodities,
const bool add_prices,
const datetime_t& moment)
{
if (type() == SEQUENCE) {
value_t temp;
@ -1447,7 +1447,7 @@ value_t value_t::exchange_commodities(const std::string& commodities,
// expression, skip the expensive logic below.
if (commodities.find(',') == string::npos &&
commodities.find('=') == string::npos)
return value(moment, *commodity_pool_t::current_pool->find_or_create(commodities));
return value(moment, commodity_pool_t::current_pool->find_or_create(commodities));
std::vector<commodity_t *> comms;
std::vector<bool> force;
@ -1479,7 +1479,7 @@ value_t value_t::exchange_commodities(const std::string& commodities,
break;
DEBUG("commodity.exchange", "Referent doesn't match, pricing...");
if (optional<amount_t> val = as_amount_lval().value(moment, *comm)) {
if (optional<amount_t> val = as_amount_lval().value(moment, comm)) {
DEBUG("commodity.exchange", "Re-priced amount is: " << *val);
return *val;
}
@ -1502,7 +1502,7 @@ value_t value_t::exchange_commodities(const std::string& commodities,
temp += pair.second;
} else {
DEBUG("commodity.exchange", "Referent doesn't match, pricing...");
if (optional<amount_t> val = pair.second.value(moment, *comm)) {
if (optional<amount_t> val = pair.second.value(moment, comm)) {
DEBUG("commodity.exchange", "Re-priced member amount is: " << *val);
temp += *val;
repriced = true;

View file

@ -477,12 +477,12 @@ public:
void in_place_unreduce(); // exists for efficiency's sake
// Return the "market value" of a given value at a specific time.
value_t value(const optional<datetime_t>& moment = none,
const optional<commodity_t&>& in_terms_of = none) const;
value_t value(const datetime_t& moment = datetime_t(),
const commodity_t * in_terms_of = NULL) const;
value_t exchange_commodities(const std::string& commodities,
const bool add_prices = false,
const optional<datetime_t>& moment = none);
value_t exchange_commodities(const std::string& commodities,
const bool add_prices = false,
const datetime_t& moment = datetime_t());
/**
* Truth tests.

View file

@ -2,16 +2,16 @@ test -f $sourcepath/src/amount.h reg -> 7
__ERROR__
While parsing file "$sourcepath/src/amount.h", line 66:
Error: No quantity specified for amount
While parsing file "$sourcepath/src/amount.h", line 732:
While parsing file "$sourcepath/src/amount.h", line 734:
Error: Invalid date/time: line amount_t amoun
While parsing file "$sourcepath/src/amount.h", line 738:
While parsing file "$sourcepath/src/amount.h", line 740:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 744:
While parsing file "$sourcepath/src/amount.h", line 746:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 750:
While parsing file "$sourcepath/src/amount.h", line 752:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/src/amount.h", line 756:
While parsing file "$sourcepath/src/amount.h", line 758:
Error: Invalid date/time: line std::ostream&
While parsing file "$sourcepath/src/amount.h", line 763:
While parsing file "$sourcepath/src/amount.h", line 765:
Error: Invalid date/time: line std::istream&
end test

View file

@ -92,18 +92,18 @@ BOOST_AUTO_TEST_CASE(testPriceHistory)
BOOST_CHECK_EQUAL(string("$2124.122"), amt->to_fullstring());
#endif
amt = x1.value(CURRENT_TIME(), euro);
amt = x1.value(CURRENT_TIME(), &euro);
BOOST_CHECK(amt);
BOOST_CHECK_EQUAL(string("EUR 1787.50"), amt->rounded().to_string());
// Add a newer Euro pricing
aapl.add_price(jan17_07, amount_t("EUR 23.00"));
amt = x1.value(CURRENT_TIME(), euro);
amt = x1.value(CURRENT_TIME(), &euro);
BOOST_CHECK(amt);
BOOST_CHECK_EQUAL(string("EUR 2302.30"), amt->to_string());
amt = x1.value(CURRENT_TIME(), cad);
amt = x1.value(CURRENT_TIME(), &cad);
BOOST_CHECK(amt);
BOOST_CHECK_EQUAL(string("CAD 3223.22"), amt->to_string());
#endif // NOT_FOR_PYTHON