ATS
An algorithmic trading system completely written in C++
BinanceExchangeManager.h
Go to the documentation of this file.
1 
15 #ifndef ATS_BINANCEEXCHANGEMANAGER_H
16 #define ATS_BINANCEEXCHANGEMANAGER_H
17 
18 #include "ExchangeManager.h"
19 #include "thread"
20 #include "binance.h"
21 #include "json/json.h"
22 #include "binance_logger.h"
23 
24 namespace ats {
25  using namespace binance;
26 
32  private:
33  Server mServer;
34  Market mMarket;
35  Account mAccount;
36  bool mIsSimulation;
37  bool mRunning;
38  std::thread mExchangeManagerThread;
39  std::map<long, long> omsToEmsId, emsToOmsId;
40  time_t mUpdateInterval;
41 
42  public:
52  explicit BinanceExchangeManager(OrderManager &orderManager, bool isSimulation = true, time_t updateInterval=1, std::string apiKey = "",
53  std::string secretKey = "");
54 
59 
63  void start();
64 
68  void run();
69 
73  void stop();
74 
80  bool isRunning();
81 
87  bool isSimulation();
88 
93  void updateOpenOrders();
94 
101  double sendOrder(Order &order) override;
102 
109  void modifyOrder(Order &oldOrder, Order &newOrder) override;
110 
117  void cancelOrder(long orderId, std::string symbol);
118 
124  void cancelOrder(Order &order) override;
125 
132  void getOrderStatus(Order &order, Json::Value &result) override;
133 
140  std::vector<Order> getOpenOrders(std::string symbol="") override;
141 
148  std::vector<Trade> getTradeHistory(std::string symbol) override;
149 
156  double getPrice(std::string symbol) override;
157 
168  void getKlines(Json::Value& result, std::string symbol, std::string interval, time_t start_date=0, time_t end_date=0, int limit=500) override;
169 
176  Order jsonToOrder(Json::Value &result);
177 
184  Trade jsonToTrade(Json::Value &result);
185 
191  void getUserInfo(Json::Value &result);
192 
198  std::map<std::string,double> getBalances() override;
199 
206  virtual OrderBook getOrderBook(std::string symbol) override;
207  };
208 
209 } // ats
210 
211 #endif //ATS_BINANCEEXCHANGEMANAGER_H
Contains an abstract class ExchangeManager The ExchangeManager class is an abstract class that define...
The BinanceExchangeManager class is a class that defines the interface for managing orders on the Bin...
Definition: BinanceExchangeManager.h:31
The ExchangeManager class is an abstract class that defines the interface for managing orders on an e...
Definition: ExchangeManager.h:27
A class for managing orders.
Definition: OrderManager.h:154
Class representing a trade executed on an exchange.
Definition: Trade.h:16
Namespace for the algorithmic trading system.
Definition: BinanceExchangeManager.cpp:8
The OrderBook struct represents the orderbook.
Definition: OrderManager.h:131
The Order struct represents an order to be placed on an exchange.
Definition: OrderManager.h:78