-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientApplication.h
More file actions
107 lines (77 loc) · 3.24 KB
/
ClientApplication.h
File metadata and controls
107 lines (77 loc) · 3.24 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef CLIENTAPPLICATION_H
#define CLIENTAPPLICATION_H
#include <map>
#include <quickfix/Application.h>
#include <quickfix/fix42/MessageCracker.h>
#include <quickfix/FixValues.h>
#include <quickfix/fix42/Reject.h>
#include <quickfix/fix42/ExecutionReport.h>
#include <quickfix/fix42/BusinessMessageReject.h>
#include <quickfix/fix42/OrderCancelReject.h>
#include <quickfix/SessionSettings.h>
#include "Applicationbridge.h"
#include "Entrust.h"
class ClientApplication : public ApplicationBridge, public FIX::Application, public FIX42::MessageCracker {
public:
explicit ClientApplication(FIX::SessionSettings, QObject *parent = nullptr);
~ClientApplication() override = default;
// Application interface
public:
void onCreate(const FIX::SessionID &) override;
void onLogon(const FIX::SessionID &) override;
void onLogout(const FIX::SessionID &) override;
void toAdmin(FIX::Message &, const FIX::SessionID &) override;
void toApp(FIX::Message &, const FIX::SessionID &) override;
void fromAdmin(const FIX::Message &, const FIX::SessionID &) override;
void fromApp(const FIX::Message &, const FIX::SessionID &) override;
void onMessage(const FIX42::ExecutionReport &, const FIX::SessionID &) override;
void onMessage(const FIX42::Reject &, const FIX::SessionID &) override;
void onMessage(const FIX42::BusinessMessageReject &, const FIX::SessionID &) override;
void onMessage(const FIX42::OrderCancelReject &, const FIX::SessionID &) override;
//发送消息, 根据msgType发送下改撤消息
bool send(Order &, Entrust &);
static String trim(String &);
static String getValue(const FIX::Message &m, int tag);
const Entrust *getEntrust(const String &clOrdId) {
auto item = this->entrust_map.find(clOrdId);
if (item == this->entrust_map.end()) {
return nullptr;
}
return &(item->second);
}
Order *getOrder(const String &orderId) {
auto item = this->order_map.find(orderId);
if (item == this->order_map.end()) {
return nullptr;
}
return &(item->second);
}
void getReportList(String &orderId, std::vector<ClientExecutionReport> &res) {
auto item = reportMap.find(orderId);
if (item == reportMap.end()) {
return;
}
auto reportList = item->second;
res.insert(res.end(), reportList.begin(), reportList.end());
}
protected:
FIX::SessionSettings m_settings;
private:
static bool isFinalState(char execType) {
return FIX::ExecType_REJECTED == execType
|| FIX::ExecType_CANCELED == execType
|| FIX::ExecType_EXPIRED == execType
|| FIX::ExecType_DONE_FOR_DAY == execType
|| FIX::ExecType_FILL == execType;
}
typedef std::vector<ClientExecutionReport> ReportList;
typedef std::map<std::string, std::map<std::string, FIX::Message>> MessageMap;
typedef std::map<String/*clOrdId*/, Entrust> EntrustMap;
typedef std::map<String/*orderId*/, Order> OrderMap;
typedef std::map<String/*orderId*/, ReportList> ExecutionReportMap;
MessageMap maps;
EntrustMap entrust_map;
OrderMap order_map;
ExecutionReportMap reportMap;
};
#endif // CLIENTAPPLICATION_H