-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmsg_orders.h
91 lines (82 loc) · 2.86 KB
/
msg_orders.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
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
#include <string>
#include "fix_builder.h"
#include "fixed.h"
enum class OrderType {
Market=1,
Limit=2
};
inline std::ostream& operator<< (std::ostream& os, OrderType ethertype)
{
switch (ethertype)
{
case OrderType::Market : return os << "Market" ;
case OrderType::Limit : return os << "Limit" ;
};
}
enum class OrderSide {
Buy=1,
Sell=2
};
enum class OrderStatus {
New=0,
PartiallyFilled=1,
Filled=2,
Canceled=4,
Rejected=8
};
enum class ExecType {
New='0',
PartiallyFilled='1',
Filled='2',
Canceled='4',
Rejected='8',
Status='I'
};
struct NewOrderSingle {
constexpr const static char * msgType = "D";
template <int nPlaces=7> static void build(FixBuilder& fix,const std::string_view& symbol,const OrderType& orderType,const OrderSide& side, Fixed<nPlaces> price,Fixed<nPlaces> quantity,const std::string_view orderId) {
fix.addField(55,symbol);
fix.addField(11,orderId);
fix.addField(38,quantity);
fix.addField(44,price);
fix.addField(54,int(side));
fix.addField(40,int(orderType));
}
};
struct OrderCancelRequest {
constexpr const static char * msgType = "F";
template <int nPlaces=7> static void build(FixBuilder& fix,const long exchangeId,const std::string_view& symbol,const OrderType& orderType,const OrderSide& side, Fixed<nPlaces> price,Fixed<nPlaces> quantity,const std::string_view orderId) {
fix.addField(55,symbol);
fix.addField(37,exchangeId);
fix.addField(11,orderId);
fix.addField(41,orderId);
fix.addField(54,int(side));
}
};
struct OrderCancelReject {
constexpr const static char * msgType = "9";
template <int nPlaces=7> static void build(FixBuilder& fix,const long exchangeId,const std::string_view orderId,const OrderStatus& status) {
fix.addField(37,exchangeId);
fix.addField(11,orderId);
fix.addField(41,orderId);
fix.addField(434,1);
fix.addField(39,int(status));
}
};
struct ExecutionReport {
constexpr const static char * msgType = "b";
template <int nPlaces=7> static void build(FixBuilder& fix,const std::string_view& orderId,const std::string_view& symbol, const OrderSide& side, Fixed<nPlaces> lastPrice,Fixed<nPlaces> lastQty,Fixed<nPlaces> cumQty,Fixed<nPlaces> avgPrice, Fixed<nPlaces> remaining,const long exchangeId,const ExecType& execType,const long execId,const OrderStatus& status) {
fix.addField(37,exchangeId);
fix.addField(11,orderId);
fix.addField(17,execId);
fix.addField(20,char(execType));
fix.addField(39,int(status));
fix.addField(55,symbol);
fix.addField(54,int(side));
fix.addField(31, lastPrice);
fix.addField(32, lastQty);
fix.addField(151, remaining);
fix.addField(14, cumQty);
fix.addField(6, avgPrice);
}
};