-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathorderServer.h
41 lines (30 loc) · 1.02 KB
/
orderServer.h
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
#ifndef ORDERSERVER_H
#define ORDERSERVER_H
#include <map>
#include "types.h"
// some comments:
// * Get rid of all the interfaces
// * Maybe have one handler per order operation type, stored as a static template type per method?
template<typename InsertHandler>
class OrderServer : private IOrderExecutor, private IMarketModuleResponseHandler, public IOrderServer
{
private:
IMarketModule& mMarketModule;
std::map<int, bool> mOrderTagToCallbacks;
InsertHandler mOrderInsertHandler;
AccessKey mAccessKey;
// IOrderExecutor
bool AttemptInsertOrder(const InsertArgs& args, int tag) override;
// IMarketModuleOrderHandler
void OnOrderError(int tag) override;
// IOrderServer
void InsertOrder(int volume, double price, int tag, bool side);
// useful private methods
bool CheckLimits(int volume, double price);
void VerifyCallback(int tag);
public:
OrderServer(IMarketModule& marketModule, InsertHandler handler);
};
// pull in the template implementation
#include "orderServer.cc"
#endif // ORDERSERVER_H