root/isimud/exchanges/MIT/common/types.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef libjmmcg_isimud_exchanges_MIT_common_types_hpp
   2 #define libjmmcg_isimud_exchanges_MIT_common_types_hpp
   3 
   4 /******************************************************************************
   5 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/isimud/exchanges/MIT/common/types.hpp 2332 2018-09-26 04:00:27Z jmmcg $
   6 **
   7 ** Copyright (c) 2015 by J.M.McGuiness, isimud@hussar.me.uk
   8 **
   9 ** This library is free software; you can redistribute it and/or
  10 ** modify it under the terms of the GNU Lesser General Public
  11 ** License as published by the Free Software Foundation; either
  12 ** version 2.1 of the License, or (at your option) any later version.
  13 **
  14 ** This library is distributed in the hope that it will be useful,
  15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17 ** Lesser General Public License for more details.
  18 **
  19 ** You should have received a copy of the GNU Lesser General Public
  20 ** License along with this library; if not, write to the Free Software
  21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22 */
  23 
  24 #include "core/config.h"
  25 
  26 #include <array>
  27 #include <iostream>
  28 #include <limits>
  29 
  30 namespace isimud { namespace exchanges { namespace MIT { namespace common {
  31 
  32 using CrossType_t=std::uint8_t;
  33 using MsgType_t=char;
  34 using Price_t=std::int64_t;
  35 using SecurityID_t=std::int32_t;
  36 using TransactTime_t=std::uint64_t;
  37 
  38 using Account_t=std::array<char, 10>;
  39 using ClientOrderID_t=std::array<char, 20>;
  40 using CommonSymbol_t=std::array<char, 8>;
  41 using Counterparty_t=std::array<char, 11>;
  42 using CrossID_t=std::array<char, 20>;
  43 using ExecutionID_t=std::array<char, 12>;
  44 using ExecutionReportRefID_t=std::array<char, 12>;
  45 using ExpireDateTime_t=std::uint32_t;
  46 using OrderID_t=std::array<char, 12>;
  47 using Password_t=std::array<char, 25>;
  48 using PasswordExpiryDayCount_t=std::array<char, 30>;
  49 using PublicOrderID_t=std::array<char, 12>;
  50 using Reason_t=std::array<char, 20>;
  51 using RejectReason_t=std::array<char, 30>;
  52 using Segment_t=std::array<char, 4>;
  53 using TraderID_t=std::array<char, 11>;
  54 using UserName_t=std::array<char, 25>;
  55 
  56 using ReservedField2_t=std::array<char, 2>;
  57 using ReservedField3_t=std::array<char, 3>;
  58 using ReservedField4_t=std::array<char, 4>;
  59 using ReservedField6_t=std::array<char, 6>;
  60 using ReservedField9_t=std::array<char, 9>;
  61 using ReservedField10_t=std::array<char, 10>;
  62 using ReservedField12_t=std::array<char, 12>;
  63 using ReservedField20_t=std::array<char, 20>;
  64 
  65 /// The number of implied decimal-places for MIT use.
  66 /**
  67         From Section 7 "Data Types".
  68 */
  69 constexpr const Price_t implied_decimal_places=100000000;
  70 
  71 /**
  72         From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
  73 17 August 2015
  74         Section: "8.1.1 Administrative messages"
  75 */
  76 enum class AdminMsgType : MsgType_t {
  77         LogonRequest='A',
  78         LogonReply='B',
  79         LogoutRequest='5',
  80         Heartbeat='0',
  81         MissedMessageRequest='M',
  82         MissedMessageRequestAck='N',
  83         MissedMessageReport='P',        ///< Or TransmissionComplete for JSE.
  84         Reject='3',
  85         SystemStatus='n',
  86         MatchAll=std::numeric_limits<MsgType_t>::max()-1,       ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
  87         Exit=std::numeric_limits<MsgType_t>::max()      ///< For the meta-state machine: the exit state to exit the msm.
  88 };
  89 
  90 inline std::ostream &
  91 operator<<(std::ostream &os, AdminMsgType v) noexcept(false) {
  92         os<<static_cast<std::underlying_type<AdminMsgType>::type>(v);
  93         return os;
  94 }
  95 
  96 /**
  97         From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
  98 17 August 2015
  99         Section: "8.1.2.1 Client-initiated"
 100 */
 101 enum class ClientMsgType : MsgType_t {
 102         NewOrder='D',
 103         OrderCancelRequest='F',
 104         OrderMassCancelRequest='q',
 105         OrderCancelReplaceRequest='G',
 106         NewQuote='S',
 107         NewOrderCrossMessage='C',
 108         CrossOrderCancelRequest='H',
 109         MatchAll=std::numeric_limits<MsgType_t>::max()-1,       ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
 110         Exit=std::numeric_limits<MsgType_t>::max()      ///< For the meta-state machine: the exit state to exit the msm.
 111 };
 112 
 113 inline std::ostream &
 114 operator<<(std::ostream &os, ClientMsgType v) noexcept(false) {
 115         os<<static_cast<std::underlying_type<ClientMsgType>::type>(v);
 116         return os;
 117 }
 118 
 119 /**
 120         From "MIT203 - MILLENNIUM EXCHANGE Native Trading Gateway", Issue 11.6,
 121 17 August 2015
 122         Section: "8.1.2.2 Server-initiated"
 123 */
 124 enum class ServerMsgType : MsgType_t {
 125         ExecutionReport='8',
 126         OrderCancelReject='9',
 127         OrderMassCancelReport='r',
 128         BusinessMessageReject='j',
 129         MatchAll=std::numeric_limits<MsgType_t>::max()-1,       ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
 130         Exit=std::numeric_limits<MsgType_t>::max()      ///< For the meta-state machine: the exit state to exit the msm.
 131 };
 132 
 133 inline std::ostream &
 134 operator<<(std::ostream &os, ServerMsgType v) noexcept(false) {
 135         os<<static_cast<std::underlying_type<ServerMsgType>::type>(v);
 136         return os;
 137 }
 138 
 139 enum class ClearingAccount : std::uint8_t {
 140         Client=1u,
 141         House=3u
 142 };
 143 
 144 inline std::ostream &
 145 operator<<(std::ostream &os, ClearingAccount v) {
 146         os<<static_cast<std::underlying_type<ClearingAccount>::type>(v);
 147         return os;
 148 }
 149 
 150 enum class Capacity : std::uint8_t {
 151         RisklessPrincipal=1u,
 152         Principal=2u,
 153         Agency=3u,
 154         CFDGiveUp=4u
 155 };
 156 
 157 inline std::ostream &
 158 operator<<(std::ostream &os, Capacity v) {
 159         os<<static_cast<std::underlying_type<Capacity>::type>(v);
 160         return os;
 161 }
 162 
 163 enum class AutoCancel : std::uint8_t {
 164         DoNotCancel=0u,
 165         Cancel=1u
 166 };
 167 
 168 inline std::ostream &
 169 operator<<(std::ostream &os, AutoCancel v) {
 170         os<<static_cast<std::underlying_type<AutoCancel>::type>(v);
 171         return os;
 172 }
 173 
 174 enum class OrderType : std::uint8_t {
 175         Market=1u,
 176         Limit=2u,
 177         Stop=3u,
 178         StopLimit=4u,
 179         Pegged=50u,
 180         PeggedLimitOrder=51u
 181 };
 182 
 183 inline std::ostream &
 184 operator<<(std::ostream &os, OrderType v) {
 185         os<<static_cast<std::underlying_type<OrderType>::type>(v);
 186         return os;
 187 }
 188 
 189 inline std::istream &
 190 operator>>(std::istream &os, OrderType &v) {
 191         std::underlying_type<OrderType>::type t;
 192         os>>t;
 193         v=static_cast<OrderType>(t);
 194         return os;
 195 }
 196 
 197 enum class Anonymity : std::uint8_t {
 198         Anonymous=0u,
 199         Named=1u
 200 };
 201 
 202 inline std::ostream &
 203 operator<<(std::ostream &os, Anonymity v) {
 204         os<<static_cast<std::underlying_type<Anonymity>::type>(v);
 205         return os;
 206 }
 207 
 208 enum class TIF : std::uint8_t {
 209         Day=0u,
 210         GTC=1u, ///< Good Till Cancel (GTC); JSE.
 211         IOC=3u, ///< Immediate or Cancel (IOC).
 212         FOK=4u, ///< Fill or Kill (FOK).
 213         OPG=5u, ///< At the Opening (OPG).
 214         GTD=6u, ///< Good Till Date (GTD).
 215         GTT=8u, ///< Good Till Time (GTT).
 216         GFA1=9u,        ///< Good For Auction (GFA); BIT & JSE.
 217         ATC=10u,        ///< At the Close (ATC).
 218         CPX=12u,        ///< Close Price Cross; JSE.
 219         GFA2=50u,       ///< Good for Auction (GFA); LSE or Good for EOD Volume Auction Uncross (GDX) JSE.
 220         GFX=51u,        ///< Good for Intraday Auction (GFX).
 221         GFS=52u ///< Good for Scheduled Auction (GFS). 
 222 };
 223 
 224 inline std::ostream &
 225 operator<<(std::ostream &os, TIF v) {
 226         os<<static_cast<std::underlying_type<TIF>::type>(v);
 227         return os;
 228 }
 229 
 230 inline std::istream &
 231 operator>>(std::istream &os, TIF &v) {
 232         std::underlying_type<TIF>::type t;
 233         os>>t;
 234         v=static_cast<TIF>(t);
 235         return os;
 236 }
 237 
 238 enum class Side : std::uint8_t {
 239         Buy=1u,
 240         Sell=2u
 241 };
 242 
 243 inline std::ostream &
 244 operator<<(std::ostream &os, Side v) {
 245         os<<static_cast<std::underlying_type<Side>::type>(v);
 246         return os;
 247 }
 248 
 249 inline std::istream &
 250 operator>>(std::istream &os, Side &v) {
 251         std::underlying_type<Side>::type t;
 252         os>>t;
 253         v=static_cast<Side>(t);
 254         return os;
 255 }
 256 
 257 enum class PassiveOnlyOrder : std::uint8_t {
 258         NoConstraint=0u,
 259         AcceptOrderIfSettingNewBBOJoiningExistingBBO=1u,
 260         AcceptOrderIfAtBBOInOneVisiblePricePoint=2u,
 261         AcceptOrderIfAtBBOInTwoVisiblePricePoints=3u,
 262         NotMatchWithVisibleContraOrder=99u,
 263         AcceptOrderIfSettingNewVisibleBBO=100u
 264 };
 265 
 266 inline std::ostream &
 267 operator<<(std::ostream &os, PassiveOnlyOrder v) {
 268         os<<static_cast<std::underlying_type<PassiveOnlyOrder>::type>(v);
 269         return os;
 270 }
 271 
 272 enum class OrderSubType : std::uint8_t {
 273         Order=0u,
 274         Quote=3u,
 275         PeggedOrder=5u,
 276         PeggedMid=50u,
 277         Random=51u,     ///< Or Pegged To Bid for JSE.
 278         PeggedOffer=52u
 279 };
 280 
 281 inline std::ostream &
 282 operator<<(std::ostream &os, OrderSubType v) {
 283         os<<static_cast<std::underlying_type<OrderSubType>::type>(v);
 284         return os;
 285 }
 286 
 287 enum class AppID : std::uint8_t {
 288         Partition1=1u,
 289         Partition2=2u,
 290         Partition3=3u
 291 };
 292 
 293 inline std::ostream &
 294 operator<<(std::ostream &os, AppID v) {
 295         os<<static_cast<std::underlying_type<AppID>::type>(v);
 296         return os;
 297 }
 298 
 299 enum class MESQualifier : std::int8_t {
 300         NonMES=0,
 301         MES=1
 302 };
 303 
 304 inline std::ostream &
 305 operator<<(std::ostream &os, MESQualifier v) {
 306         os<<static_cast<std::underlying_type<MESQualifier>::type>(v);
 307         return os;
 308 }
 309 
 310 enum class OrderSource : std::int8_t {
 311         MarketParticipantDealsOnOwnAccount=1,
 312         InstitutionalClientMarketParticipant=3,
 313         RetailClientOrdersRouterDifferentMarketParticipant=7,
 314         InstitutionalClientOrdersRouterDifferentMarketParticipant=8,
 315         RetailClientMarketParticipant=9
 316 };
 317 
 318 inline std::ostream &
 319 operator<<(std::ostream &os, OrderSource v) {
 320         os<<static_cast<std::underlying_type<OrderSource>::type>(v);
 321         return os;
 322 }
 323 
 324 enum class RestatementReason : std::uint8_t {
 325         GTRenewalRestatement=1u,
 326         OrderRePriced=3u,
 327         MarketOption=8u,
 328         PartialDeclineOrderQty=51u,
 329         OrderReplenishment=100u
 330 };
 331 
 332 inline std::ostream &
 333 operator<<(std::ostream &os, RestatementReason v) {
 334         os<<static_cast<std::underlying_type<RestatementReason>::type>(v);
 335         return os;
 336 }
 337 
 338 enum class ExecType : char {
 339         New='0',
 340         Cancelled='4',
 341         Replaced='5',
 342         Rejected='8',
 343         Suspended='9',
 344         Expired='C',
 345         Restated='D',
 346         Trade='F',
 347         TradeCorrect='G',
 348         TradeCancel='H',
 349         Triggered='L'
 350 };
 351 
 352 inline std::ostream &
 353 operator<<(std::ostream &os, ExecType v) {
 354         os<<static_cast<std::underlying_type<ExecType>::type>(v);
 355         return os;
 356 }
 357 
 358 enum class OrderStatus : std::uint8_t {
 359         New=0u,
 360         Partiallyfilled=1u,
 361         Filled=2u,
 362         Cancelled=4u,
 363         Expired=6u,
 364         Rejected=8u,
 365         Suspended=9u
 366 };
 367 
 368 inline std::ostream &
 369 operator<<(std::ostream &os, OrderStatus v) {
 370         os<<static_cast<std::underlying_type<OrderStatus>::type>(v);
 371         return os;
 372 }
 373 
 374 enum class Container : std::uint8_t {
 375         None=0u,
 376         OrderBook=1u,   ///< Or Main on JSE.
 377         MarketOrderContainer=3u,
 378         ParkedOrderQueue=5u,
 379         StopOrderQueue=6u,
 380         PeggedOrderContainer=7u,
 381         PeggedOrder=20u,        ///< On JSE.
 382         EODVolumeAuctionUncross=21u     ///< On JSE.
 383 };
 384 
 385 enum class TradeLiquidityIndicator : char {
 386         AddedLiquidity='A',
 387         RemovedLiquidity='R',
 388         Auction='C'
 389 };
 390 
 391 enum class PriceDifferential : char {
 392         Aggressive='A',
 393         NewVisibleBBO='B',
 394         JoinVisibleBBO='1',
 395         JoiningSetting2ndBestVisiblePrice='2',
 396         JoiningSetting3rdBestVisiblePrice='3',
 397         JoiningSetting4thBestVisiblePrice='4',
 398         JoiningSetting5thBestVisiblePrice='5',
 399         JoiningSetting6thBestVisiblePrice='6',
 400         JoiningSetting7thBestVisiblePrice='7',
 401         JoiningSetting8thBestVisiblePrice='8',
 402         JoiningSetting9thBestVisiblePriceOrWorsePricePoint='9',
 403         Passive='P'
 404 };
 405 
 406 enum class TypeOfTrade : std::uint8_t {
 407         Visible=0u,
 408         Hidden=1u,
 409         NotSpecified=2u
 410 };
 411 
 412 enum class MassCancelRequestType : std::uint8_t {
 413         AllFirmOrdersInstrument=3u,
 414         AllFirmOrdersOfSegment=4u,
 415         AllOrdersSubmittedByTrader=7u,
 416         AllFirmOrders=8u,
 417         AllOrdersOfInstrument=9u,
 418         AllOrdersOfSegment=15u
 419 };
 420 
 421 enum class AppStatus : std::uint8_t {
 422         RecoveryServiceResumed=1u,
 423         RecoveryServiceNotAvailable=2u,
 424         PartitionSuspended=3u
 425 };
 426 
 427 enum class MassCancelResponse : std::uint8_t {
 428         Rejected=0u,
 429         Accepted=7u
 430 };
 431 
 432 enum class TargetBook : std::int8_t {
 433         LitOrderBook=0,
 434         DarkMidpointOrderBook=1 ///< Or Regular on JSE. 
 435 };
 436 
 437 enum class ExecInstruction : std::int8_t {
 438         Default=0,
 439         TurquoiseUncross=1,
 440         ContinuousOnly=2,
 441         ContinuousAndTurquoiseUncross=5
 442 };
 443 
 444 enum class PegPriceType : std::int8_t {
 445         MidPoint=0
 446 };
 447 
 448 enum class OrderBook : std::int8_t {
 449         Regular=1
 450 };
 451 
 452 enum class ExecutionInstruction : std::int8_t {
 453         DoNotExcludeHiddenOrders=0,
 454         ExcludeHiddenOrders=1,
 455         IncludeInEODVolumeAuctionUncross=2
 456 };
 457 
 458 enum class Status : std::uint8_t {
 459         AllMessagesTransmitted=0u,
 460         MessageLimitReached=1u,
 461         ServiceUnavailable=2u
 462 };
 463 
 464 enum class CrossType : std::uint8_t {
 465         InternalCross=5
 466 };
 467 
 468 enum class IsMarketOpsRequest : std::uint8_t {
 469         No=0u,
 470         Yes=1u
 471 };
 472 
 473 } } } }
 474 
 475 #endif

/* [<][>][^][v][top][bottom][index][help] */