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_BATSBOE_common_types_hpp
2 #define ISIMUD_EXCHANGES_BATSBOE_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/iso_4217_currency_codes.hpp"
23 
24 #include <array>
25 #include <iostream>
26 #include <limits>
27 
28 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace BATSBOE { namespace common {
29 
30 using DateTime_t=std::uint64_t;
31 using MsgType_t=std::uint8_t;
32 using Price_t=std::uint64_t;
33 using Quantity_t=std::uint32_t;
34 using SeqNum_t=std::uint32_t;
35 using SPrice_t=std::int64_t;
36 
37 using Account_t=std::array<char, 16>;
38 using ClearingAccount_t=std::array<char, 4>;
39 using ClearingFirm_t=std::array<char, 4>;
40 using ClientOrderID_t=std::array<char, 20>;
41 using ContraBroker_t=std::array<char, 4>;
43 using LogoutReasonText_t=std::array<char, 60>;
44 using Password_t=std::array<char, 10>;
45 using PreventParticipantMatch_t=std::array<char, 3>;
46 using RoutingInst_t=std::array<char, 4>;
47 using SecurityExchange_t=std::array<char, 4>;
48 using SecurityID_t=std::array<char, 16>;
49 using SessionSubID_t=std::array<char, 4>;
50 using Symbol_t=std::array<char, 8>;
51 using SymbolSfx_t=std::array<char, 8>;
52 using Text_t=std::array<char, 60>;
53 using TradeReportID_t=std::array<char, 20>;
54 using TradeReportRefID_t=std::array<char, 20>;
55 using UserName_t=std::array<char, 4>;
56 
57 /// The number of implied decimal-places for MIT use.
58 /**
59  From Section 10 "List of Optional Fields".
60 */
61 constexpr Price_t implied_decimal_places=10000;
62 
63 enum class MsgType : MsgType_t {
64  LogoutRequest=0x02,
65  ClientHeartbeat=0x03,
66  Logout=0x08,
67  ServerHeartbeat=0x09,
68  ReplayComplete=0x13,
69  NewOrder=0x04,
70  CancelOrder=0x05,
71  ModifyOrder=0x06,
73  OrderRejected=0x0B,
74  OrderModified=0x0C,
75  OrderRestated=0x0D,
76  UserModifyRejected=0x0E,
77  OrderCancelled=0x0F,
78  CancelRejected=0x10,
79  OrderExecution=0x11,
81  MatchAll=std::numeric_limits<MsgType_t>::max()-1, ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
82  Exit=std::numeric_limits<MsgType_t>::max() ///< For the meta-state machine: the exit state to exit the msm.
83 };
84 
85 inline std::ostream &
86 operator<<(std::ostream &os, MsgType m) {
87  os<<static_cast<unsigned int>(m);
88  return os;
89 }
90 
91 enum class LoginResponseStatus : char {
92  LoginAccepted='A',
93  NotAuthorized='N',
94  SessionDisabled='D',
95  SessionInUse='B',
96  InvalidSession='S',
101 };
102 
103 inline std::ostream &
104 operator<<(std::ostream &os, LoginResponseStatus m) {
105  os<<static_cast<char>(m);
106  return os;
107 }
108 
109 enum class LogoutReason : char {
110  UserRequested='U',
111  EndofDay='E',
112  Administrative='A',
114 };
115 
116 inline std::ostream &
117 operator<<(std::ostream &os, LogoutReason m) {
118  os<<static_cast<char>(m);
119  return os;
120 }
121 
122 enum class Side : char {
123  Buy='1',
124  Sell='2',
125  Sell_short='5',
127 };
128 
129 inline std::ostream &
130 operator<<(std::ostream &os, Side v) {
131  os<<static_cast<std::underlying_type<Side>::type>(v);
132  return os;
133 }
134 
135 inline std::istream &
136 operator>>(std::istream &os, Side &v) {
137  std::underlying_type<Side>::type t;
138  os>>t;
139  v=static_cast<Side>(t);
140  return os;
141 }
142 
143 enum class ExecInst : char {
144  NoSpecialHandling='\0',
145  MarketPeg='P',
146  PrimaryPeg='R',
147  Midpoint='M',
148  AlternateMidpoint='L',
149  ExternalDarkOnly='u',
150  ExternalDarkLit='v',
151  ExternalLitOnly='w'
152 };
153 
154 enum class OrdType : char {
155  Market='1',
156  Limit='2',
157  Pegged='P'
158 };
159 
160 inline std::ostream &
161 operator<<(std::ostream &os, OrdType v) {
162  os<<static_cast<std::underlying_type<OrdType>::type>(v);
163  return os;
164 }
165 
166 inline std::istream &
167 operator>>(std::istream &os, OrdType &v) {
168  std::underlying_type<OrdType>::type t;
169  os>>t;
170  v=static_cast<OrdType>(t);
171  return os;
172 }
173 
174 enum class TIF : char {
175  Day='0',
176  GTC='1', ///< GTC (allowed, but treated as Day).
177  ATO='2', ///< At The Open (reserved for future use).
178  IOC='3', ///< IOC (Portion not filled immediately is cancelled. Market orders are implicitly IOC.).
179  GTD='6', ///< GTD (expires at earlier of specified ExpireTime or end of day).
180  ATC='7' ///< At The Close (reserved for future use).
181 };
182 
183 inline std::ostream &
184 operator<<(std::ostream &os, TIF v) {
185  os<<static_cast<std::underlying_type<TIF>::type>(v);
186  return os;
187 }
188 
189 inline std::istream &
190 operator>>(std::istream &os, TIF &v) {
191  std::underlying_type<TIF>::type t;
192  os>>t;
193  v=static_cast<TIF>(t);
194  return os;
195 }
196 
197 enum class IDSource : char {
198  ISIN='4',
199  RIC='5'
200 };
201 
202 enum class Capacity : char {
203  Agency='A',
204  Principal='P',
205  Riskless='R'
206 };
207 
208 enum class DisplayIndicator : char {
209  DisplayedOrder='X',
210  Invisible='I'
211 };
212 
213 enum class BookingType : char {
214  RegularBooking='0',
215  CFD='1' ///< Contract for difference.
216 };
217 
218 enum class CancelOrigOnReject : char {
219  LeaveOriginal='N',
220  CancelOriginal='Y'
221 };
222 
223 enum class PreviouslyReported : char {
224  TradeWillPrint='N',
226 };
227 
228 enum class TransactionCategory : char {
229  RegularTrade='P', ///< Aka Plain-Vanilla Trade.
230  SpecialPrice='F', ///< Aka Trade with Conditions.
231  DarkTrade='D',
232  TechnicalTrade='T',
234 };
235 
237  New=0,
238  Cancel=1,
239  Replace=2,
240  Release=3
241 };
242 
243 enum class VenueType : char {
244  OffBook='X'
245 };
246 
253  PostTrading=5,
255 };
256 
257 enum class MatchType : std::uint8_t {
258  OffExchange=1,
259  OnExchange=3,
261 };
262 
263 enum class SecondaryTrdType : std::uint8_t {
264  BenchmarkTrade=58
265 };
266 
268  CumDividend=0,
269  ExDividend=2
270 };
271 
273  PublishTrade=1,
275 };
276 
277 enum class ExecutionMethod : char {
278  Automated='A',
279  Manual='M',
280  Unspecified='U'
281 };
282 
283 enum class BaseLiquidityIndicator : char {
284  AddedLiquidity='A',
285  RemovedLiquidity='R',
287  AuctionTrade='C'
288 };
289 
290 enum class SubLiquidityIndicator : char {
291  DarkPoolExecution='D',
292  AddedRPILiquidity='E',
293  RemovedLiquidity='T', ///< From the BATS Dark Pool by IOC order.
297  AddedLiquidityHiddenPortionIceberg='K', ///< Trade added Liquidity from the hidden (reserve) portion of an iceberg order.
300 };
301 
302 enum class CCP : char {
304  LCHClearnet='L',
305  SIXXXClear='X',
306  EuroCCP='C',
308 };
309 
310 enum class OrderRejectReason : char {
311  Admin='A',
312  CapacityUndefined='C',
313  DuplicateClOrdID='D',
314  Halted='H',
316  TooLateToCancel='J',
319  MaxSizeExceeded='M', ///< OrderQty would cause LeavesQty to exceed allowable size.
323  AwaitingFirstTrade='Q',
324  RoutingUnavailable='R',
326  UserRequested='U',
327  WouldWash='V',
329  OrderExpired='X',
330  SymbolNotSupported='Y',
331  UnforeseenReason='Z',
332  BrokerOption='b',
333  LargeinScale='l',
334  ReserveReload='r',
337  CrossedMarket='x',
339 };
340 
341 inline std::ostream &
342 operator<<(std::ostream &os, OrderRejectReason m) {
343  os<<static_cast<char>(m);
344  return os;
345 }
346 
347 enum class RestatementReason : char {
349  Reroute='R',
350  LockedInCross='X',
351  Wash='W',
352  Reload='L',
353  LiquidityUpdated='Q'
354 };
355 
356 enum class Reason : char {
357  Admin='A',
360  SymbolNotSupported='Y',
361  UnforseenReason='Z'
362 };
363 
364 enum class AttributedQuote : char {
367 };
368 
369 } } } } }
370 
371 #endif