libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
messages_impl.hpp
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
3
**
4
** This library is free software; you can redistribute it and/or
5
** modify it under the terms of the GNU Lesser General Public
6
** License as published by the Free Software Foundation; either
7
** version 2.1 of the License, or (at your option) any later version.
8
**
9
** This library is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
** Lesser General Public License for more details.
13
**
14
** You should have received a copy of the GNU Lesser General Public
15
** License along with this library; if not, write to the Free Software
16
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
namespace
isimud
{
namespace
ISIMUD_VER_NAMESPACE
{
namespace
exchanges {
namespace
MIT
{
namespace
common
{
20
21
template
<
class
MsgT>
22
inline
constexpr
23
Header
::
Header
(MsgT
const
*)
noexcept
(
true
)
24
:
length_
(
static_cast
<
std
::int16_t>(
sizeof
(MsgT)-
sizeof
(
Header
))),
type_
(MsgT::static_type) {
25
}
26
27
inline
constexpr
28
LogonRequest
::
LogonRequest
(
const
logon_args_t::UserName_t &UN,
const
logon_args_t::Password_t &P,
const
logon_args_t::Password_t &NP)
noexcept
(
true
)
29
:
Header_t
(
static_cast
<
LogonRequest
const
*>(
nullptr
)),
userName
(
UN
),
password
(
P
),
newPassword
(
NP
) {
30
assert(length_>0);
31
}
32
33
inline
constexpr
34
LogonRequest
::
LogonRequest
(logon_args_t
const
&a)
noexcept
(
true
)
35
:
LogonRequest
(
a
.
username
,
a
.
password
,
a
.
new_password
) {
36
}
37
38
template
<
class
RejectCode>
39
inline
40
LogonReply
<RejectCode>::
LogonReply
()
noexcept
(
true
)
41
: Header_t(
static_cast
<
LogonReply
const
*>(
nullptr
)) {
42
}
43
44
template
<
class
RejectCode>
45
struct
LogonReply
<RejectCode>::respond {
46
template
<
class
ReplyMsg,
class
Op>
void
47
operator
()(ReplyMsg
const
&msg, Op
const
&o)
const
noexcept
(
false
)
FORCE_INLINE
{
48
switch
(msg.rejectCode()) {
49
case
ReplyMsg::logon_success:
50
o.operator()();
51
break
;
52
default
: {
53
std
::ostringstream os;
54
os<<
"Failed to logon. Reject code="
<<msg.rejectCode();
55
assert(!
"TODO need reject code as string."
);
56
throw
std
::runtime_error(os.str());
57
}
58
}
59
}
60
};
61
62
inline
constexpr
63
LogoutRequest
::
LogoutRequest
()
noexcept
(
true
)
64
:
Header_t
(
static_cast
<
LogoutRequest
const
*>(
nullptr
)),
65
reason_
{
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
} {
66
}
67
68
inline
constexpr
69
LogoutRequest
::
LogoutRequest
(Reason_t r)
noexcept
(
true
)
70
:
Header_t
(
static_cast
<
LogoutRequest
const
*>(
nullptr
)),
reason_
(
r
) {
71
}
72
73
inline
constexpr
74
LogoutRequest
::
LogoutRequest
(
logoff_args_t
const
&a)
noexcept
(
true
)
75
:
LogoutRequest
(
a
.
reason
) {
76
}
77
78
inline
constexpr
79
Heartbeat
::
Heartbeat
()
noexcept
(
true
)
80
:
Header_t
(
static_cast
<
Heartbeat
const
*>(
nullptr
)) {
81
}
82
83
inline
constexpr
84
MissedMessageRequest
::
MissedMessageRequest
(
AppID
a, SeqNum_t l)
noexcept
(
true
)
85
:
Header_t
(
static_cast
<
MissedMessageRequest
const
*>(
nullptr
)),
appID
(a),
lastMsgSeqNum
(l) {
86
}
87
88
inline
89
MissedMessageRequestAck
::
MissedMessageRequestAck
()
noexcept
(
true
)
90
:
Header_t
(
static_cast
<
MissedMessageRequestAck
const
*>(
nullptr
)) {
91
}
92
93
inline
94
MissedMessageReport
::
MissedMessageReport
()
noexcept
(
true
)
95
:
Header_t
(
static_cast
<
MissedMessageReport
const
*>(
nullptr
)) {
96
}
97
98
template
<
class
RejectCode
,
RejectCode
RejectCodeNum
>
99
inline
100
Reject
<
RejectCode
,
RejectCodeNum
>::
Reject
()
noexcept
(
true
)
101
:
Header_t
(
static_cast
<
Reject
const
*>(
nullptr
)) {
102
}
103
104
template
<
class
RejectCode
,
RejectCode
RejectCodeNum
>
105
inline
106
Reject
<
RejectCode
,
RejectCodeNum
>::
Reject
(
RejectCode_t
const
rc
)
noexcept
(
true
)
107
:
Header_t
(
static_cast
<
Reject
const
*>(
nullptr
)),
108
rejectCode_
(
rc
) {
109
}
110
111
template
<
class
RejectCode
,
RejectCode
RejectCodeNum
>
112
inline
113
Reject
<
RejectCode
,
RejectCodeNum
>::
Reject
(
ClientOrderID_t
const
&
clID
,
RejectCode_t
const
rc
)
noexcept
(
true
)
114
:
Reject
(
rc
) {
115
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
116
}
117
118
inline
119
SystemStatus
::
SystemStatus
()
noexcept
(
true
)
120
:
Header_t
(
static_cast
<
SystemStatus
const
*>(
nullptr
)) {
121
}
122
123
template
<
class
Specific1
,
class
Specific2
,
class
Specific3
>
124
inline
constexpr
125
NewOrder
<
Specific1
,
Specific2
,
Specific3
>::
NewOrder
(
std
::
int32_t
,
ClientOrderID_t
const
&
clID
,
OrderType
const
oT
,
TIF
const
t
,
Side
const
s
,
SecurityID_t
instID
,
typename
specific2_t
::
order_qty_t
ordQty
,
Price_t
p
)
noexcept
(
true
)
126
:
Header_t
(
static_cast
<
NewOrder
const
*>(
nullptr
)),
127
specific1
(
instID
),
128
orderType_
(
oT
),
129
tif_
(
t
),
130
side_
(
s
),
131
specific2
(
ordQty
),
132
limitPrice_
(
p
)
133
{
134
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
135
}
136
137
template
<
class
Specific1
,
class
Specific2
>
138
inline
constexpr
139
NewQuote
<
Specific1
,
Specific2
>::
NewQuote
()
noexcept
(
true
)
140
:
Header_t
(
static_cast
<
NewQuote
const
*>(
nullptr
)) {
141
}
142
143
template
<
class
Specific1
,
class
Specific2
,
class
Specific3
>
144
inline
constexpr
145
OrderCancelReplaceRequest
<
Specific1
,
Specific2
,
Specific3
>::
OrderCancelReplaceRequest
(
common
::
ClientOrderID_t
const
&
clID
,
ClientOrderID_t
const
&
origclID
,
SecurityID_t
instID
,
typename
specific2_t
::
order_qty_t
ordQty
,
Price_t
const
p
,
TIF
t
,
Side
s
)
noexcept
(
true
)
146
:
Header_t
(
static_cast
<
OrderCancelReplaceRequest
const
*>(
nullptr
)),
147
specific1
(
instID
),
148
specific2
(
ordQty
),
149
limitPrice_
(
p
),
150
tif_
(
t
),
151
side_
(
s
) {
152
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
153
libjmmcg
::
memcpy_opt
(
origclID
,
originalClientOrderID_
);
154
}
155
156
template
<
class
Specific1
,
class
Specific2
>
157
inline
constexpr
158
OrderCancelRequest
<
Specific1
,
Specific2
>::
OrderCancelRequest
(
ClientOrderID_t
const
&
clID
,
ClientOrderID_t
const
&
origclID
,
SecurityID_t
instID
,
Side
side
)
noexcept
(
true
)
159
:
Header_t
(
static_cast
<
OrderCancelRequest
const
*>(
nullptr
)),
160
specific1
(
instID
),
side_
(
side
) {
161
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
162
libjmmcg
::
memcpy_opt
(
origclID
,
originalClientOrderID_
);
163
}
164
165
template
<
class
Specific1
,
class
Specific2
>
166
inline
constexpr
167
OrderMassCancelRequest
<
Specific1
,
Specific2
>::
OrderMassCancelRequest
(
SecurityID_t
instID
)
noexcept
(
true
)
168
:
Header_t
(
static_cast
<
OrderMassCancelRequest
const
*>(
nullptr
)),
specific1
(
instID
) {
169
}
170
171
template
<
class
Specific1
,
class
Specific2
>
172
inline
constexpr
173
ExecutionReport
<
Specific1
,
Specific2
>::
ExecutionReport
()
noexcept
(
true
)
174
:
Header_t
(
static_cast
<
ExecutionReport
const
*>(
nullptr
)) {
175
}
176
177
template
<
class
Specific1
,
class
Specific2
>
178
inline
constexpr
179
ExecutionReport
<
Specific1
,
Specific2
>::
ExecutionReport
(
SeqNum_t
seqNum
,
ClientOrderID_t
const
&
clID
,
AppID
aID
,
ExecType
eT
,
Price_t
const
price
,
SecurityID_t
instID
,
Side
s
)
noexcept
(
true
)
180
:
Header_t
(
static_cast
<
ExecutionReport
const
*>(
nullptr
)),
181
appID
(
aID
),
182
sequenceNumber
(
seqNum
),
183
execType_
(
eT
),
184
executedPrice_
(
price
),
185
instrumentID_
(
instID
),
186
side_
(
s
) {
187
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
188
}
189
190
template
<
class
Specific1
,
class
Specific2
>
191
inline
constexpr
192
ExecutionReport
<
Specific1
,
Specific2
>::
ExecutionReport
(
SeqNum_t
seqNum
,
ClientOrderID_t
const
&
clID
,
ExecType
eT
,
Price_t
const
price
,
SecurityID_t
instID
,
Side
s
,
typename
specific1_t
::
order_qty_t
execdQty
,
typename
specific1_t
::
order_qty_t
leavesQty
)
noexcept
(
true
)
193
:
ExecutionReport
(
seqNum
,
clID
,
default_appID
,
eT
,
price
,
instID
,
s
) {
194
specific1
.
executedQty
=
execdQty
;
195
specific1
.
leavesQty
=
leavesQty
;
196
}
197
198
template
<
class
Specific
>
199
inline
200
OrderCancelReject
<
Specific
>::
OrderCancelReject
()
noexcept
(
true
)
201
:
Header_t
(
static_cast
<
OrderCancelReject
const
*>(
nullptr
)) {
202
}
203
204
template
<
class
Specific
>
205
inline
206
OrderCancelReject
<
Specific
>::
OrderCancelReject
(
SeqNum_t
seqNum
,
ClientOrderID_t
const
&
clID
)
noexcept
(
true
)
207
:
Header_t
(
static_cast
<
OrderCancelReject
const
*>(
nullptr
)),
208
sequenceNumber
(
seqNum
) {
209
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
210
}
211
212
template
<
class
Specific
>
213
inline
214
OrderMassCancelReport
<
Specific
>::
OrderMassCancelReport
()
noexcept
(
true
)
215
:
Header_t
(
static_cast
<
OrderMassCancelReport
const
*>(
nullptr
)) {
216
}
217
218
template
<
class
Specific
>
219
inline
220
BusinessReject
<
Specific
>::
BusinessReject
()
noexcept
(
true
)
221
:
Header_t
(
static_cast
<
BusinessReject
const
*>(
nullptr
)) {
222
}
223
224
template
<
class
Specific
>
225
inline
226
BusinessReject
<
Specific
>::
BusinessReject
(
SeqNum_t
seqNum
,
ClientOrderID_t
const
&
clID
)
noexcept
(
true
)
227
:
Header_t
(
static_cast
<
BusinessReject
const
*>(
nullptr
)),
228
sequenceNumber
(
seqNum
) {
229
libjmmcg
::
memcpy_opt
(
clID
,
clientOrderID_
);
230
}
231
232
} } } } }
isimud
exchanges
MIT
common
messages_impl.hpp
Generated on Tue May 11 2021 17:24:44 for libjmmcg by
1.9.2