forked from rhinofi/coding_challenge_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarketMakerBot.h
More file actions
54 lines (35 loc) · 1.39 KB
/
MarketMakerBot.h
File metadata and controls
54 lines (35 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include "DvfSimulator.h"
#include "Common.h"
#include <map>
#include <chrono>
#include <functional>
#include <thread>
#include <atomic>
class MarketMakerBot {
public:
MarketMakerBot();
// can take any custom third party client trading algo
void run(std::function<std::vector<OrderSuggestion>(double, double)> tradingAlgo);
~MarketMakerBot();
protected:
// cancel orders that may damage your portfolio
void cancelOutlierOrders(const double bid, const double ask);
/* checks for any existing order gets filled (clause 5).
If yes, remove from placedOrders, and update PnL ****************/
void updatePnL(const double bestBid, const double bestAsk);
bool creditCheckFailed (const bool isBid, const double price) const;
// void displayPortfolio(const MarketMakerBot * mmb) const
void displayPortfolio() const;
void startTrading();
std::atomic<double> m_balanceETH;
std::atomic<double> m_balanceUSD;
std::multiset<OrderSuggestion, std::greater<OrderSuggestion>> m_placedBidOrders;
std::multiset<OrderSuggestion> m_placedAskOrders;
std::function<std::vector<OrderSuggestion>(double, double)> m_clientTradingAlgo;
std::thread m_orderPlacer;
std::thread m_marketDataFetcher;
std::thread m_balanceDisplayer;
bool m_keepRunning;
IDvfSimulator * m_simulator;
};