-
Notifications
You must be signed in to change notification settings - Fork 3
/
TraderEngine.h
62 lines (56 loc) · 1.93 KB
/
TraderEngine.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef TRADERENGINE_HPP
#define TRADERENGINE_HPP
#include <vector>
#include <stdlib.h>
#include "HPPackClient.h"
#include "HPPackRiskClient.h"
#include "YMLConfig.hpp"
#include "XPluginEngine.hpp"
#include "IPCLockFreeQueue.hpp"
#include "LockFreeQueue.hpp"
#include "TraderAPI/TradeGateWay.hpp"
class TraderEngine
{
public:
TraderEngine();
void LoadConfig(const std::string& path);
void SetCommand(const std::string& cmd);
void LoadTradeGateWay(const std::string& soPath);
void Run();
protected:
void WorkFunc();
void RegisterClient(const char *ip, unsigned int port);
void RegisterRiskClient(const char *ip, unsigned int port);
void ReadRequestFromMemory();
void ReadRequestFromClient();
void HandleRequestMessage();
void HandleRiskResponse();
void HandleExecuteReport();
void HandleCommand(const Message::PackMessage& msg);
void WriteExecuteReportToMemory();
void SendRequest(const Message::PackMessage& request);
void SendRiskCheckReqeust(const Message::PackMessage& request);
void SendMonitorMessage(const Message::PackMessage& msg);
void InitRiskCheck();
bool IsTrading()const;
void CheckTrading();
void InitAppStatus();
void UpdateAppStatus(const std::string& cmd, Message::TAppStatus& AppStatus);
private:
HPPackClient* m_HPPackClient;
HPPackRiskClient* m_RiskClient;
Utils::XTraderConfig m_XTraderConfig;
bool m_Trading;
unsigned long m_CurrentTimeStamp;
int m_OpenTime;
int m_CloseTime;
TradeGateWay* m_TradeGateWay;
std::string m_Command;
Utils::IPCLockFreeQueue<Message::PackMessage, 1000> m_OrderChannelQueue;
Utils::IPCLockFreeQueue<Message::PackMessage, 1000> m_ReportChannelQueue;
Utils::LockFreeQueue<Message::PackMessage> m_RequestMessageQueue;
Utils::LockFreeQueue<Message::PackMessage> m_ReportMessageQueue;
std::vector<int> m_CPUSETVector;
std::thread* m_pWorkThread;
};
#endif // TRADERENGINE_HPP