libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
types.hpp
Go to the documentation of this file.
1 #ifndef ISIMUD_EXCHANGES_MIT_COMMON_TYPES_HPP
2 #define ISIMUD_EXCHANGES_MIT_COMMON_TYPES_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 "../../common/config.h"
23 
24 #include <array>
25 #include <iostream>
26 #include <limits>
27 
28 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace MIT { namespace common {
29 
30 using CrossType_t=std::uint8_t;
31 using MsgType_t=char;
32 using SeqNum_t=std::int32_t;
33 using Price_t=std::int64_t;
34 using SecurityID_t=std::int32_t;
35 using TransactTime_t=std::uint64_t;
36 
37 using Account_t=std::array<char, 10>;
38 using ClientOrderID_t=std::array<char, 20>;
39 using CommonSymbol_t=std::array<char, 8>;
40 using Counterparty_t=std::array<char, 11>;
41 using CrossID_t=std::array<char, 20>;
42 using ExecutionID_t=std::array<char, 12>;
43 using ExecutionReportRefID_t=std::array<char, 12>;
44 using ExpireDateTime_t=std::uint32_t;
45 using OrderID_t=std::array<char, 12>;
46 using Password_t=std::array<char, 25>;
47 using PasswordExpiryDayCount_t=std::array<char, 30>;
48 using PublicOrderID_t=std::array<char, 12>;
49 using Reason_t=std::array<char, 20>;
50 using RejectReason_t=std::array<char, 30>;
51 using Segment_t=std::array<char, 4>;
52 using TraderID_t=std::array<char, 11>;
53 using UserName_t=std::array<char, 25>;
54 
55 using ReservedField2_t=std::array<char, 2>;
56 using ReservedField3_t=std::array<char, 3>;
57 using ReservedField4_t=std::array<char, 4>;
58 using ReservedField6_t=std::array<char, 6>;
59 using ReservedField9_t=std::array<char, 9>;
60 using ReservedField10_t=std::array<char, 10>;
61 using ReservedField12_t=std::array<char, 12>;
62 using ReservedField20_t=std::array<char, 20>;
63 
64 /// The number of implied decimal-places for MIT use.
65 /**
66  From Section 7 "Data Types".
67 */
68 constexpr const Price_t implied_decimal_places=100000000;
69 
70 /**
71  From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
72 17 August 2015
73  Section: "8.1.1 Administrative messages"
74 */
75 enum class AdminMsgType : MsgType_t {
76  LogonRequest='A',
77  LogonReply='B',
78  LogoutRequest='5',
79  Heartbeat='0',
82  MissedMessageReport='P', ///< Or TransmissionComplete for JSE.
83  Reject='3',
84  SystemStatus='n',
85  MatchAll=std::numeric_limits<MsgType_t>::max()-1, ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
86  Exit=std::numeric_limits<MsgType_t>::max() ///< For the meta-state machine: the exit state to exit the msm.
87 };
88 
89 inline std::ostream &
90 operator<<(std::ostream &os, AdminMsgType v) noexcept(false) {
91  os<<static_cast<std::underlying_type<AdminMsgType>::type>(v);
92  return os;
93 }
94 
95 /**
96  From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
97 17 August 2015
98  Section: "8.1.2.1 Client-initiated"
99 */
100 enum class ClientMsgType : MsgType_t {
101  NewOrder='D',
102  OrderCancelRequest='F',
105  NewQuote='S',
108  MatchAll=std::numeric_limits<MsgType_t>::max()-1, ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
109  Exit=std::numeric_limits<MsgType_t>::max() ///< For the meta-state machine: the exit state to exit the msm.
110 };
111 
112 inline std::ostream &
113 operator<<(std::ostream &os, ClientMsgType v) noexcept(false) {
114  os<<static_cast<std::underlying_type<ClientMsgType>::type>(v);
115  return os;
116 }
117 
118 /**
119  From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
120 17 August 2015
121  Section: "8.1.2.2 Server-initiated"
122 */
123 enum class ServerMsgType : MsgType_t {
124  ExecutionReport='8',
125  OrderCancelReject='9',
128  MatchAll=std::numeric_limits<MsgType_t>::max()-1, ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
129  Exit=std::numeric_limits<MsgType_t>::max() ///< For the meta-state machine: the exit state to exit the msm.
130 };
131 
132 inline std::ostream &
133 operator<<(std::ostream &os, ServerMsgType v) noexcept(false) {
134  os<<static_cast<std::underlying_type<ServerMsgType>::type>(v);
135  return os;
136 }
137 
138 enum class ClearingAccount : std::uint8_t {
139  Client=1u,
140  House=3u
141 };
142 
143 inline std::ostream &
144 operator<<(std::ostream &os, ClearingAccount v) {
145  os<<static_cast<std::underlying_type<ClearingAccount>::type>(v);
146  return os;
147 }
148 
149 enum class Capacity : std::uint8_t {
151  Principal=2u,
152  Agency=3u,
153  CFDGiveUp=4u
154 };
155 
156 inline std::ostream &
157 operator<<(std::ostream &os, Capacity v) {
158  os<<static_cast<std::underlying_type<Capacity>::type>(v);
159  return os;
160 }
161 
162 enum class AutoCancel : std::uint8_t {
163  DoNotCancel=0u,
164  Cancel=1u
165 };
166 
167 inline std::ostream &
168 operator<<(std::ostream &os, AutoCancel v) {
169  os<<static_cast<std::underlying_type<AutoCancel>::type>(v);
170  return os;
171 }
172 
173 enum class OrderType : std::uint8_t {
174  Market=1u,
175  Limit=2u,
176  Stop=3u,
177  StopLimit=4u,
178  Pegged=50u,
179  PeggedLimitOrder=51u
180 };
181 
182 inline std::ostream &
183 operator<<(std::ostream &os, OrderType v) {
184  os<<static_cast<std::underlying_type<OrderType>::type>(v);
185  return os;
186 }
187 
188 inline std::istream &
189 operator>>(std::istream &os, OrderType &v) {
190  std::underlying_type<OrderType>::type t;
191  os>>t;
192  v=static_cast<OrderType>(t);
193  return os;
194 }
195 
196 enum class Anonymity : std::uint8_t {
197  Anonymous=0u,
198  Named=1u
199 };
200 
201 inline std::ostream &
202 operator<<(std::ostream &os, Anonymity v) {
203  os<<static_cast<std::underlying_type<Anonymity>::type>(v);
204  return os;
205 }
206 
207 enum class TIF : std::uint8_t {
208  Day=0u,
209  GTC=1u, ///< Good Till Cancel (GTC); JSE.
210  IOC=3u, ///< Immediate or Cancel (IOC).
211  FOK=4u, ///< Fill or Kill (FOK).
212  OPG=5u, ///< At the Opening (OPG).
213  GTD=6u, ///< Good Till Date (GTD).
214  GTT=8u, ///< Good Till Time (GTT).
215  GFA1=9u, ///< Good For Auction (GFA); BIT & JSE.
216  ATC=10u, ///< At the Close (ATC).
217  CPX=12u, ///< Close Price Cross; JSE.
218  GFA2=50u, ///< Good for Auction (GFA); LSE or Good for EOD Volume Auction Uncross (GDX) JSE.
219  GFX=51u, ///< Good for Intraday Auction (GFX).
220  GFS=52u ///< Good for Scheduled Auction (GFS).
221 };
222 
223 inline std::ostream &
224 operator<<(std::ostream &os, TIF v) {
225  os<<static_cast<std::underlying_type<TIF>::type>(v);
226  return os;
227 }
228 
229 inline std::istream &
230 operator>>(std::istream &os, TIF &v) {
231  std::underlying_type<TIF>::type t;
232  os>>t;
233  v=static_cast<TIF>(t);
234  return os;
235 }
236 
237 enum class Side : std::uint8_t {
238  Buy=1u,
239  Sell=2u
240 };
241 
242 inline std::ostream &
243 operator<<(std::ostream &os, Side v) {
244  os<<static_cast<std::underlying_type<Side>::type>(v);
245  return os;
246 }
247 
248 inline std::istream &
249 operator>>(std::istream &os, Side &v) {
250  std::underlying_type<Side>::type t;
251  os>>t;
252  v=static_cast<Side>(t);
253  return os;
254 }
255 
256 enum class PassiveOnlyOrder : std::uint8_t {
257  NoConstraint=0u,
263 };
264 
265 inline std::ostream &
266 operator<<(std::ostream &os, PassiveOnlyOrder v) {
267  os<<static_cast<std::underlying_type<PassiveOnlyOrder>::type>(v);
268  return os;
269 }
270 
271 enum class OrderSubType : std::uint8_t {
272  Order=0u,
273  Quote=3u,
274  PeggedOrder=5u,
275  PeggedMid=50u,
276  Random=51u, ///< Or Pegged To Bid for JSE.
277  PeggedOffer=52u
278 };
279 
280 inline std::ostream &
281 operator<<(std::ostream &os, OrderSubType v) {
282  os<<static_cast<std::underlying_type<OrderSubType>::type>(v);
283  return os;
284 }
285 
286 enum class AppID : std::uint8_t {
287  Partition1=1u,
288  Partition2=2u,
289  Partition3=3u
290 };
291 
292 inline std::ostream &
293 operator<<(std::ostream &os, AppID v) {
294  os<<static_cast<std::underlying_type<AppID>::type>(v);
295  return os;
296 }
297 
298 static inline constexpr const AppID default_appID=AppID::Partition1;
299 
300 enum class MESQualifier : std::int8_t {
301  NonMES=0,
302  MES=1
303 };
304 
305 inline std::ostream &
306 operator<<(std::ostream &os, MESQualifier v) {
307  os<<static_cast<std::underlying_type<MESQualifier>::type>(v);
308  return os;
309 }
310 
311 enum class OrderSource : std::int8_t {
317 };
318 
319 inline std::ostream &
320 operator<<(std::ostream &os, OrderSource v) {
321  os<<static_cast<std::underlying_type<OrderSource>::type>(v);
322  return os;
323 }
324 
327  OrderRePriced=3u,
328  MarketOption=8u,
330  OrderReplenishment=100u
331 };
332 
333 inline std::ostream &
334 operator<<(std::ostream &os, RestatementReason v) {
335  os<<static_cast<std::underlying_type<RestatementReason>::type>(v);
336  return os;
337 }
338 
339 enum class ExecType : char {
340  New='0',
341  Cancelled='4',
342  Replaced='5',
343  Rejected='8',
344  Suspended='9',
345  Expired='C',
346  Restated='D',
347  Trade='F',
348  TradeCorrect='G',
349  TradeCancel='H',
350  Triggered='L'
351 };
352 
353 inline std::ostream &
354 operator<<(std::ostream &os, ExecType v) {
355  os<<static_cast<std::underlying_type<ExecType>::type>(v);
356  return os;
357 }
358 
359 enum class OrderStatus : std::uint8_t {
360  New=0u,
361  Partiallyfilled=1u,
362  Filled=2u,
363  Cancelled=4u,
364  Expired=6u,
365  Rejected=8u,
366  Suspended=9u
367 };
368 
369 inline std::ostream &
370 operator<<(std::ostream &os, OrderStatus v) {
371  os<<static_cast<std::underlying_type<OrderStatus>::type>(v);
372  return os;
373 }
374 
375 enum class Container : std::uint8_t {
376  None=0u,
377  OrderBook=1u, ///< Or Main on JSE.
379  ParkedOrderQueue=5u,
380  StopOrderQueue=6u,
382  PeggedOrder=20u, ///< On JSE.
383  EODVolumeAuctionUncross=21u ///< On JSE.
384 };
385 
386 enum class TradeLiquidityIndicator : char {
387  AddedLiquidity='A',
388  RemovedLiquidity='R',
389  Auction='C'
390 };
391 
392 enum class PriceDifferential : char {
393  Aggressive='A',
394  NewVisibleBBO='B',
395  JoinVisibleBBO='1',
404  Passive='P'
405 };
406 
407 enum class TypeOfTrade : std::uint8_t {
408  Visible=0u,
409  Hidden=1u,
410  NotSpecified=2u
411 };
412 
417  AllFirmOrders=8u,
420 };
421 
422 enum class AppStatus : std::uint8_t {
426 };
427 
429  Rejected=0u,
430  Accepted=7u
431 };
432 
433 enum class TargetBook : std::int8_t {
434  LitOrderBook=0,
435  DarkMidpointOrderBook=1 ///< Or Regular on JSE.
436 };
437 
438 enum class ExecInstruction : std::int8_t {
439  Default=0,
441  ContinuousOnly=2,
443 };
444 
445 enum class PegPriceType : std::int8_t {
446  MidPoint=0
447 };
448 
449 enum class OrderBook : std::int8_t {
450  Regular=1
451 };
452 
457 };
458 
459 enum class Status : std::uint8_t {
463 };
464 
465 enum class CrossType : std::uint8_t {
466  InternalCross=5
467 };
468 
470  No=0u,
471  Yes=1u
472 };
473 
474 } } } } }
475 
476 #endif