8 #ifndef ATS_MARKETDATA_H
9 #define ATS_MARKETDATA_H
12 #include <unordered_map>
13 #include <unordered_set>
22 std::vector<time_t> times;
23 std::vector<double> opens;
24 std::vector<double> highs;
25 std::vector<double> lows;
26 std::vector<double> closes;
27 std::vector<double> volumes;
31 void push_back(time_t time,
double open,
double high,
double low,
double close,
double volume) {
32 times.push_back(time);
33 opens.push_back(open);
34 highs.push_back(high);
36 closes.push_back(close);
37 volumes.push_back(volume);
41 if (times.empty())
return;
56 std::thread mMarketDataThread;
57 std::mutex mDataMutex;
59 std::unordered_set<std::string> mSymbols;
60 std::unordered_map<std::string, std::vector<double>> mPrices;
62 time_t mUpdateInterval;
63 std::unordered_map<std::string,OrderBook> mOrderBooks;
64 std::map<std::string,double> mBalances;
65 std::map<std::pair<std::string,std::string>,
Klines> mKlines;
114 void subscribe(
const std::string& symbol, std::string interval=
"3m");
127 double getPrice(
const std::string& symbol);
134 std::vector<double>
getPrices(
const std::string& symbol);
179 Klines getKlines(
const std::string &symbol,
const std::string& interval);
186 void updatePrice(
const std::string& symbol);
202 void updateOrderBook(
const std::string& symbol);
207 void updateOrderBooks();
212 void updateBalances();
217 double jsonToDouble(Json::Value res);
Contains an abstract class ExchangeManager The ExchangeManager class is an abstract class that define...
Contains the declaration of the OrderManager class and related enums and structs.
The ExchangeManager class is an abstract class that defines the interface for managing orders on an e...
Definition: ExchangeManager.h:27
Handles the streaming of market data for the trading system.
Definition: MarketData.h:54
double getPrice(const std::string &symbol)
Retrieves the current price for a symbol.
Definition: MarketData.cpp:75
Klines getKlines(const std::string &symbol, const std::string &interval)
Retrieves Kline data.
Definition: MarketData.cpp:175
std::string getOrderStatus(long id, const std::string &symbol)
Retrieves order status.
Definition: MarketData.cpp:158
void start()
Starts the market data stream.
Definition: MarketData.cpp:24
MarketData(ExchangeManager &ems, time_t updateInterval=1)
Constructs a new MarketData object.
Definition: MarketData.cpp:10
bool isRunning()
Checks whether the market data stream is running.
Definition: MarketData.cpp:145
std::vector< double > getPrices(const std::string &symbol)
Returns prices recorded for a symbol.
Definition: MarketData.cpp:87
std::map< std::string, double > getBalances()
Retrives user's balances.
Definition: MarketData.cpp:153
double getQtyForPrice(const std::string &symbol, double price)
Retrieves the quantity for a given price and symbol.
Definition: MarketData.cpp:149
~MarketData()
Destroys the MarketData object.
Definition: MarketData.cpp:20
void subscribe(const std::string &symbol, std::string interval="3m")
Subscribes to a symbol for market data.
Definition: MarketData.cpp:52
void stop()
Stops the market data stream.
Definition: MarketData.cpp:46
void run()
Runs the market data stream.
Definition: MarketData.cpp:31
OrderBook getOrderBook(const std::string &symbol)
Retrieves the OrderBook.
Definition: MarketData.cpp:167
std::vector< Trade > getTradeHistory(const std::string &symbol)
Returns trade history for a symbol.
Definition: MarketData.cpp:92
void unsubscribe(const std::string &symbol)
Unsubscribes from a symbol for market data.
Definition: MarketData.cpp:61
Namespace for the algorithmic trading system.
Definition: BinanceExchangeManager.cpp:8
The Klines stores kline data for a specific symbol.
Definition: MarketData.h:21
The OrderBook struct represents the orderbook.
Definition: OrderManager.h:131