Add Bot.h and Bot.cpp

This commit is contained in:
Lev
2021-06-13 17:11:24 -05:00
parent 312341dca6
commit fdfd01b0f3
14 changed files with 362 additions and 347 deletions

View File

@ -2,39 +2,44 @@
#include <string>
enum class OrderBookType{bid, ask, unknown, asksale, bidsale};
enum class OrderBookType
{
bid,
ask,
unknown,
asksale,
bidsale
};
class OrderBookEntry
{
public:
public:
OrderBookEntry(double _price,
double _amount,
std::string _timestamp,
std::string _product,
OrderBookType _orderType,
std::string username = "dataset");
OrderBookEntry( double _price,
double _amount,
std::string _timestamp,
std::string _product,
OrderBookType _orderType,
std::string username = "dataset");
static OrderBookType stringToOrderBookType(std::string s);
static OrderBookType stringToOrderBookType(std::string s);
static bool compareByTimestamp(OrderBookEntry &e1, OrderBookEntry &e2)
{
return e1.timestamp < e2.timestamp;
}
static bool compareByPriceAsc(OrderBookEntry &e1, OrderBookEntry &e2)
{
return e1.price < e2.price;
}
static bool compareByPriceDesc(OrderBookEntry &e1, OrderBookEntry &e2)
{
return e1.price > e2.price;
}
static bool compareByTimestamp(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.timestamp < e2.timestamp;
}
static bool compareByPriceAsc(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.price < e2.price;
}
static bool compareByPriceDesc(OrderBookEntry& e1, OrderBookEntry& e2)
{
return e1.price > e2.price;
}
double price;
double amount;
std::string timestamp;
std::string product;
OrderBookType orderType;
std::string username;
double price;
double amount;
std::string timestamp;
std::string product;
OrderBookType orderType;
std::string username;
};