libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
batsboe_common_to_fix_conversions.hpp
Go to the documentation of this file.
1
#
ifndef
ISIMUD_EXCHANGES_conversions_batsboe_common_to_fix_conversions_hpp
2
#
define
ISIMUD_EXCHANGES_conversions_batsboe_common_to_fix_conversions_hpp
3
4
/******************************************************************************
5
** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
6
**
7
** This library is free software; you can redistribute it and/or
8
** modify it under the terms of the GNU Lesser General Public
9
** License as published by the Free Software Foundation; either
10
** version 2.1 of the License, or (at your option) any later version.
11
**
12
** This library is distributed in the hope that it will be useful,
13
** but WITHOUT ANY WARRANTY; without even the implied warranty of
14
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
** Lesser General Public License for more details.
16
**
17
** You should have received a copy of the GNU Lesser General Public
18
** License along with this library; if not, write to the Free Software
19
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*/
21
22
#
include
"../../exchanges/FIX/v5.0sp2/messages.hpp"
23
#
include
"../BATSBOE/common/messages.hpp"
24
25
namespace
isimud
{
namespace
ISIMUD_VER_NAMESPACE
{
namespace
exchanges {
namespace
FIX
{
namespace
common
{
26
27
constexpr
inline
Side
28
convert
(
BATSBOE
::
common
::
Side
a) {
29
switch
(a) {
30
case
BATSBOE
::
common
::
Side
::
Buy
:
31
return
Side
::
Buy
;
32
case
BATSBOE
::
common
::
Side
::
Sell
:
33
return
Side
::
Sell
;
34
case
BATSBOE
::
common
::
Side
::
Sell_short
:
35
return
Side
::
Sell_short
;
36
case
BATSBOE
::
common
::
Side
::
Sell_short_exempt
:
37
default
:
38
return
Side
::
Sell_short_exempt
;
39
};
40
}
41
42
inline
int
43
convert_price
(
BATSBOE
::
common
::Price_t
const
&a,
char
*buff,
std
::size_t sz) {
44
const
double
c=
static_cast
<
double
>(a)/
BATSBOE
::
common
::
implied_decimal_places
;
45
return
libjmmcg
::
tostring
(
c
,
buff
,
sz
)
;
46
}
47
48
template
<>
49
template
<>
inline
50
Message
<
v5_0sp2
::
ExecutionReportSpecific
>::
Message
(
exchanges
::
BATSBOE
::
common
::
OrderExecution
const
&
msg
)
51
:
Header_t
() {
52
underlying_fix_data_buffer
::
iterator
data
=
set_sequence_num
<
MsgTypes
::
ExecutionReport
>(
msg
);
53
data
=
add_field_tag
<
FieldsFast
::
ClOrdID
>(
data
);
54
libjmmcg
::
memcpy_opt
(
msg
.
clientOrderID
(),
reinterpret_cast
<
BATSBOE
::
common
::
ClientOrderID_t
&>(*
data
));
55
data
+=
msg
.
clientOrderID
().
size
()-1;
56
data
=
add_field_tag
<
FieldsFast
::
SecurityIDSource
>(
data
);
57
*
data
=
static_cast
<
std
::
underlying_type
<
SecurityIDSource
>::
type
>(
SecurityIDSource
::
ISIN
);
58
++
data
;
59
data
=
add_field_tag
<
FieldsFast
::
SecurityID
>(
data
);
60
libjmmcg
::
memcpy_opt
(
msg
.
instrumentID
(),
reinterpret_cast
<
BATSBOE
::
common
::
SecurityID_t
&>(*
data
));
61
data
+=
msg
.
instrumentID
().
size
()-1;
62
data
=
add_field_tag
<
FieldsFast
::
Price
>(
data
);
63
const
int
j
=
convert_price
(
msg
.
executedPrice
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
64
assert(j>0);
65
data
+=
j
;
66
data
=
add_field_tag
<
FieldsFast
::
OrderQty
>(
data
);
67
const
int
k
=
convert
(
msg
.
executedQty
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
68
assert(k>0);
69
data
+=
k
;
70
data
=
add_field_tag
<
FieldsFast
::
LeavesQty
>(
data
);
71
const
int
l
=
convert
(
msg
.
leavesQty
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
72
assert(l>0);
73
data
+=
l
;
74
data
=
add_field_tag
<
FieldsFast
::
Side
>(
data
);
75
*
data
=
static_cast
<
std
::
underlying_type
<
Side
>::
type
>(
convert
(
msg
.
side
()));
76
++
data
;
77
// TODO msg.orderRejectCode();
78
finalise_msg
(
data
);
79
}
80
81
template
<>
82
template
<>
inline
83
Message
<
v5_0sp2
::
OrderRejectedSpecific
>::
Message
(
exchanges
::
BATSBOE
::
common
::
OrderRejected
const
&
msg
)
84
:
Header_t
() {
85
underlying_fix_data_buffer
::
iterator
data
=
set_sequence_num
<
MsgTypes
::
Reject
>(
msg
);
86
data
=
add_field_tag
<
FieldsFast
::
ClOrdID
>(
data
);
87
libjmmcg
::
memcpy_opt
(
msg
.
clientOrderID
(),
reinterpret_cast
<
BATSBOE
::
common
::
ClientOrderID_t
&>(*
data
));
88
data
+=
msg
.
clientOrderID
().
size
()-1;
89
data
=
add_field_tag
<
FieldsFast
::
RefSeqNum
>(
data
);
90
const
int
i
=
convert
(
msg
.
sequenceNumber
,
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
91
assert(i>0);
92
data
+=
i
;
93
finalise_msg
(
data
);
94
}
95
96
template
<>
97
template
<>
inline
98
Message
<
v5_0sp2
::
CancelRejectedSpecific
>::
Message
(
exchanges
::
BATSBOE
::
common
::
CancelRejected
const
&
msg
)
99
:
Header_t
() {
100
underlying_fix_data_buffer
::
iterator
data
=
set_sequence_num
<
MsgTypes
::
OrderCancelReject
>(
msg
);
101
data
=
add_field_tag
<
FieldsFast
::
ClOrdID
>(
data
);
102
libjmmcg
::
memcpy_opt
(
msg
.
clientOrderID
(),
reinterpret_cast
<
BATSBOE
::
common
::
ClientOrderID_t
&>(*
data
));
103
data
+=
msg
.
clientOrderID
().
size
()-1;
104
// TODO cancelRejectReason_;
105
// TODO transactTime;
106
finalise_msg
(
data
);
107
}
108
109
template
<>
110
template
<>
inline
111
Message
<
v5_0sp2
::
BusinessMessageRejectSpecific
>::
Message
(
exchanges
::
BATSBOE
::
common
::
UserModifyRejected
const
&
msg
)
112
:
Header_t
() {
113
underlying_fix_data_buffer
::
iterator
data
=
set_sequence_num
<
MsgTypes
::
BusinessMessageReject
>(
msg
);
114
data
=
add_field_tag
<
FieldsFast
::
ClOrdID
>(
data
);
115
libjmmcg
::
memcpy_opt
(
msg
.
clientOrderID
(),
reinterpret_cast
<
BATSBOE
::
common
::
ClientOrderID_t
&>(*
data
));
116
data
+=
msg
.
clientOrderID
().
size
()-1;
117
data
=
add_field_tag
<
FieldsFast
::
RefSeqNum
>(
data
);
118
const
int
i
=
convert
(
msg
.
sequenceNumber
,
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
119
assert(i>0);
120
data
+=
i
;
121
// TODO
122
finalise_msg
(
data
);
123
}
124
125
template
<>
126
template
<>
inline
127
Message
<
v5_0sp2
::
ExecutionReportSpecific
>::
Message
(
exchanges
::
BATSBOE
::
common
::
OrderCancelled
const
&
msg
)
128
:
Header_t
() {
129
underlying_fix_data_buffer
::
iterator
data
=
set_sequence_num
<
MsgTypes
::
ExecutionReport
>(
msg
);
130
data
=
add_field_tag
<
FieldsFast
::
ClOrdID
>(
data
);
131
libjmmcg
::
memcpy_opt
(
msg
.
clientOrderID
(),
reinterpret_cast
<
BATSBOE
::
common
::
ClientOrderID_t
&>(*
data
));
132
data
+=
msg
.
clientOrderID
().
size
()-1;
133
data
=
add_field_tag
<
FieldsFast
::
Price
>(
data
);
134
const
int
j
=
convert_price
(
msg
.
lastPrice
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
135
assert(j>0);
136
data
+=
j
;
137
data
=
add_field_tag
<
FieldsFast
::
OrderQty
>(
data
);
138
const
int
k
=
convert
(
msg
.
orderQty
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
139
assert(k>0);
140
data
+=
k
;
141
data
=
add_field_tag
<
FieldsFast
::
LeavesQty
>(
data
);
142
const
int
l
=
convert
(
msg
.
leavesQty
(),
data
,
this
->
data_
.
size
()-(
data
-
this
->
data_
.
begin
()));
143
assert(l>0);
144
data
+=
l
;
145
data
=
add_field_tag
<
FieldsFast
::
Side
>(
data
);
146
*
data
=
static_cast
<
std
::
underlying_type
<
Side
>::
type
>(
convert
(
msg
.
side
()));
147
++
data
;
148
// TODO msg.orderRejectCode();
149
finalise_msg
(
data
);
150
}
151
152
} } } } }
153
154
#
endif
isimud
exchanges
conversions
batsboe_common_to_fix_conversions.hpp
Generated on Tue May 11 2021 17:25:08 for libjmmcg by
1.9.2