Update fixed the price comparison

This commit is contained in:
Lev
2021-06-12 10:54:37 -05:00
parent 01becd46fa
commit 028aec9a1d

View File

@ -2,36 +2,40 @@
#include <string>
enum class OrderBookType{bid, ask, unknown, sale};
enum class OrderBookType
{
bid,
ask,
unknown,
sale
};
class OrderBookEntry
{
public:
public:
OrderBookEntry(double _price,
double _amount,
std::string _timestamp,
std::string _product,
OrderBookType _orderType);
OrderBookEntry( double _price,
double _amount,
std::string _timestamp,
std::string _product,
OrderBookType _orderType);
static OrderBookType stringToOrderBookType(std::string s);
static bool compareByTimestamp(OrderBookEntry &entry1, OrderBookEntry &entry2)
{
return entry1.timestamp < entry2.timestamp;
}
static bool compareByPriceAsc(OrderBookEntry &entry1, OrderBookEntry &entry2)
{
return entry1.price < entry2.price;
}
static bool compareByPriceDesc(OrderBookEntry &entry1, OrderBookEntry &entry2)
{
return entry1.price > entry2.price;
}
static OrderBookType stringToOrderBookType(std::string s);
static bool compareByTimestamp(OrderBookEntry& entry1, OrderBookEntry& entry2)
{
return entry1.timestamp < entry2.timestamp;
}
static bool compareByPriceAsc (OrderBookEntry& entry1, OrderBookEntry& entry2)
{
return entry1.timestamp < entry2.timestamp;
}
static bool compareByPriceDesc (OrderBookEntry& entry1, OrderBookEntry& entry2)
{
return entry1.timestamp > entry2.timestamp;
}
double price;
double amount;
std::string timestamp;
std::string product;
OrderBookType orderType;
double price;
double amount;
std::string timestamp;
std::string product;
OrderBookType orderType;
};