I am trying to calculate the average of the entries, but for some reason I am getting an unexpected error:
error: no match for ‘operator+’ (operand types are ‘double’ and ‘const OrderBookEntry’)
__init = __init + *__first;"
~~~~~~~^~~~~~~~~~
I am new to C++ and tried to solve this for a while, but nothing worked.
int MerkelBot::predictMarketPrice()
{
int prediction = 0;
for (std::string const& p : orderBook.getKnownProducts())
{
std::cout << "Product: " << p << std::endl;
std::vector<OrderBookEntry> entries = orderBook.getOrders(OrderBookType::ask,
p, currentTime);
double sum = accumulate(entries.cbegin(), entries.cend(), 0.0);
prediction = sum / entries.size();
std::cout << "Price Prediction is: " << prediction << std::endl;
}
}