OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
IncrementalRefreshBook.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4// and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable OnixS Software
7// Services Agreement (the Agreement) and Customer end user license agreements granting
8// a non-assignable, non-transferable and non-exclusive license to use the software
9// for it's own data processing purposes under the terms defined in the Agreement.
10//
11// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12// of this source code or associated reference material to any other location for further reproduction
13// or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14//
15// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16// the terms of the Agreement is a violation of copyright law.
17//
18
19#pragma once
20
21#include <type_traits>
22#include <utility>
23
24#include <OnixS/CME/MDH/ABI.h>
27#include <OnixS/CME/MDH/Order.h>
31#include <OnixS/CME/MDH/Watch.h>
32
34
37
39namespace details
40{
41 template <typename Holder>
43
45 enum class IncrementalRefreshBookInitializationTag {};
47
48 template <Messaging::UpdateAction::Enum Action> struct IsDeleteMdEntryAction : std::integral_constant<bool,
49 Action == Messaging::UpdateAction::Delete ||
50 Action == Messaging::UpdateAction::DeleteThru ||
51 Action == Messaging::UpdateAction::DeleteFrom>
52 {};
53
54 template <Messaging::UpdateAction::Enum Action> struct IsValueMdEntryAction : std::integral_constant<bool,
55 Action == Messaging::UpdateAction::New ||
56 Action == Messaging::UpdateAction::Change ||
57 Action == Messaging::UpdateAction::Overlay>
58 {};
59
60 template <Messaging::UpdateAction::Enum Action, typename Holder>
61 using EnableDeleteMdEntry = typename std::enable_if<
63
64 template <Messaging::UpdateAction::Enum Action, typename Holder>
65 using EnableValueMdEntry = typename std::enable_if<
67
68 template <Messaging::OrderUpdateAction::Enum Action> struct IsOrderIdEntryAction : std::integral_constant<bool,
69 Action == Messaging::OrderUpdateAction::New ||
70 Action == Messaging::OrderUpdateAction::Update ||
71 Action == Messaging::OrderUpdateAction::Delete>
72 {};
73
74 template <Messaging::OrderUpdateAction::Enum Action, typename Holder>
75 using EnableOrderIdEntry = typename std::enable_if<
77
78 template <Messaging::UpdateAction::Enum Action, typename Holder>
80 Holder& message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType,
81 Messaging::UInt32 rptSeq, Messaging::UInt8 priceLevel)
82 {
83 auto entry = appendGroupEntry(message->entries(), [&message](
84 typename decltype(message->entries())::Size size) { return message->entries(size); });
85
86 entry.setUpdateAction(Action);
87 entry.setEntryType(entryType);
88 entry.setSecurityId(securityId);
89 entry.setRptSeq(rptSeq);
90 entry.setPriceLevel(priceLevel);
91
92 return entry;
93 }
94
95 template <Messaging::UpdateAction::Enum Action, typename Holder>
97 Holder& message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType,
98 Messaging::UInt32 rptSeq, Messaging::UInt8 priceLevel)
99 {
100 auto entry = appendMdEntryBase<Action>(message, securityId, entryType, rptSeq, priceLevel);
101
102 entry.entryPxNull();
103 entry.entrySizeNull();
104 entry.numberOfOrdersNull();
105
106 return entry;
107 }
108
109 template <Messaging::UpdateAction::Enum Action, typename Holder>
111 Holder& message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType,
113 Messaging::Int32 quantity, Messaging::Int32 numberOfOrders)
114 {
115 auto entry = appendMdEntryBase<Action>(message, securityId, entryType, rptSeq, priceLevel);
116
117 entry.setEntryPx(price);
118 entry.setEntrySize(quantity);
119 entry.setNumberOfOrders(numberOfOrders);
120
121 return entry;
122 }
123
124 template <Messaging::OrderUpdateAction::Enum Action, typename Holder>
126 Holder& message, OrderId orderId, OrderPriority orderPriority, DisplayQuantity quantity,
127 Messaging::UInt8 referenceId)
128 {
129 auto entry = appendGroupEntry(message->orderIdEntries(), [&message](
130 typename decltype(message->orderIdEntries())::Size size) { return message->orderIdEntries(size); });
131
132 entry.setOrderId(orderId);
133 entry.setOrderPriority(orderPriority);
134 entry.setDisplayQty(quantity);
135 entry.setReferenceId(referenceId);
136 entry.setOrderUpdateAction(Action);
137
138 return entry;
139 }
140}
141
148template <typename Holder, details::IncrementalRefreshBookInitializationTag...>
149auto initialize(Holder& message, EventFlags::Bits eventIndicator, Messaging::Timestamp transactTime = UtcWatch::now()) noexcept
150 -> details::EnableIncrementalRefreshBook<Holder>
151{
152 return details::initializeMessage<IncrementalRefreshBook>(message, eventIndicator, transactTime);
153}
154
160template <typename Holder, details::IncrementalRefreshBookInitializationTag...>
162auto initialize(EventFlags::Bits eventIndicator, Messaging::Timestamp transactTime = UtcWatch::now()) -> decltype(
164{
166}
167
178template <Messaging::UpdateAction::Enum Action, typename Holder>
179auto addEntry(
180 Holder& message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType,
181 Messaging::UInt32 rptSeq, Messaging::UInt8 priceLevel)
183{
184 details::appendMdEntry<Action>(message, securityId, entryType, rptSeq, priceLevel);
185 return message;
186}
187
201template <Messaging::UpdateAction::Enum Action, typename Holder>
202auto addEntry(
203 Holder& message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType, Messaging::UInt32 rptSeq,
204 Messaging::UInt8 priceLevel, Messaging::Decimal9 price, Messaging::Int32 quantity,
205 Messaging::Int32 numberOfOrders)
207{
209 message, securityId, entryType, rptSeq, priceLevel, price, quantity, numberOfOrders);
210 return message;
211}
212
223template <Messaging::OrderUpdateAction::Enum Action, typename Holder>
224auto addOrderIdEntry(
225 Holder& message, OrderId orderId, OrderPriority orderPriority, DisplayQuantity quantity,
227{
228 details::appendOrderIdEntry<Action>(message, orderId, orderPriority, quantity, referenceId);
229 return message;
230}
231
233namespace details
234{
235 template <Messaging::UpdateAction::Enum Action>
237 {
238 template <typename Holder, typename... Arguments>
239 static auto apply(Holder& message, Arguments&&... arguments) -> decltype(
240 addEntry<Action>(message, std::forward<Arguments>(arguments)...),
241 appendMdEntry<Action>(message, std::forward<Arguments>(arguments)...))
242 {
243 return appendMdEntry<Action>(message, std::forward<Arguments>(arguments)...);
244 }
245 };
246
247 template <Messaging::OrderUpdateAction::Enum Action>
249 {
250 template <typename Holder, typename... Arguments>
251 static auto apply(Holder& message, Arguments&&... arguments) -> decltype(
252 addOrderIdEntry<Action>(message, std::forward<Arguments>(arguments)...),
253 appendOrderIdEntry<Action>(message, std::forward<Arguments>(arguments)...))
254 {
255 return appendOrderIdEntry<Action>(message, std::forward<Arguments>(arguments)...);
256 }
257 };
258
259 template <>
261 {
262 template <Messaging::UpdateAction::Enum Action, typename Holder, typename... Arguments>
263 static auto apply(Holder& message, Arguments&&... arguments) -> typename std::enable_if<
266 message, std::forward<Arguments>(arguments)...))>::type
267 {
269 message, std::forward<Arguments>(arguments)...);
270 }
271 };
272}
273
281template <Messaging::OrderUpdateAction::Enum Action>
284 OrderId orderId, OrderPriority orderPriority, DisplayQuantity quantity,
285 Messaging::UInt8 referenceId) -> typename std::enable_if<
288 orderId, orderPriority, quantity, referenceId))>::type
289{
291 orderId, orderPriority, quantity, referenceId);
292}
293
295
316#define ONIXS_CMEMDH_ORDER_ID_ENTRY(Action, ...) \
317 ONIXS_CME_MDH_TESTING_NAMESPACE::details::deferMessageOperation([&]() { \
318 return ONIXS_CME_MDH_TESTING_NAMESPACE::orderIdEntry< \
319 ONIXS_CMEMDH_MESSAGING_NAMESPACE::OrderUpdateAction::Action>(__VA_ARGS__); \
320 })
#define ONIXS_CME_MDH_TESTING_NAMESPACE_END
Definition Bootstrap.h:84
#define ONIXS_CME_MDH_TESTING_NAMESPACE_BEGIN
Definition Bootstrap.h:83
#define ONIXS_CMEMDH_NODISCARD
Definition Compiler.h:165
The time point without the time-zone information.
Definition Time.h:450
Owns fixed-capacity storage for a prefixed CME message.
static Messaging::Timestamp now() noexcept
Returns current UTC time.
Definition Watch.h:66
FixedPointDecimal< Int64, IntegralConstant< Int8, -9 > > Decimal9
Decimal with constant exponent -9.
Definition Composites.h:37
std::uint32_t UInt32
uInt32.
Definition Integral.h:35
std::int32_t Int32
int32.
Definition Integral.h:34
std::uint8_t UInt8
uInt8.
Definition Integral.h:31
auto makeInitializationRecipe(Arguments &&... arguments) -> typename std::enable_if< IsMutableMessageHolder< ExpectedHolder, Holder >::value, decltype(makeMessageRecipe< typename std::decay< Holder >::type >(makeMessageOperation< Operation >(std::forward< Arguments >(arguments)...)))>::type
Messaging::IncrementalRefreshBook46::Entry appendMdEntryBase(Holder &message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType, Messaging::UInt32 rptSeq, Messaging::UInt8 priceLevel)
typename std::enable_if< IsMutableMessageHolder< ExpectedHolder, Holder >::value, Holder & >::type EnableMutableMessageHolder
Messaging::IncrementalRefreshBook46::Entry appendMdEntry(Holder &message, SecurityId securityId, Messaging::EntryTypeBook::Enum entryType, Messaging::UInt32 rptSeq, Messaging::UInt8 priceLevel)
typename std::enable_if< IsValueMdEntryAction< Action >::value, EnableIncrementalRefreshBook< Holder > >::type EnableValueMdEntry
Messaging::IncrementalRefreshBook46::OrderIDEntry appendOrderIdEntry(Holder &message, OrderId orderId, OrderPriority orderPriority, DisplayQuantity quantity, Messaging::UInt8 referenceId)
MessageOperation< Operation, typename std::decay< Arguments >::type... > makeMessageOperation(Arguments &&... arguments)
typename std::enable_if< IsDeleteMdEntryAction< Action >::value, EnableIncrementalRefreshBook< Holder > >::type EnableDeleteMdEntry
auto initializeMessage(Holder &message, EventFlags::Bits eventIndicator, Messaging::Timestamp transactTime) noexcept -> EnableMutableMessageHolder< ExpectedHolder, Holder >
typename std::enable_if< IsOrderIdEntryAction< Action >::value, EnableIncrementalRefreshBook< Holder > >::type EnableOrderIdEntry
Group::Entry appendGroupEntry(Group group, Resize resize)
EnableMutableMessageHolder< IncrementalRefreshBook, Holder > EnableIncrementalRefreshBook
auto orderIdEntry(OrderId orderId, OrderPriority orderPriority, DisplayQuantity quantity, Messaging::UInt8 referenceId) -> typename std::enable_if< details::IsOrderIdEntryAction< Action >::value, decltype(details::makeMessageOperation< details::OrderIdEntryOperation< Action > >(orderId, orderPriority, quantity, referenceId))>::type
Creates a pipeline operation that appends an order-ID entry.
MessageHolder< Messaging::IncrementalRefreshBook46 > IncrementalRefreshBook
Owns storage for an incremental book refresh test message.
SecurityId securityId(const Messaging::FIX::MultiContainer &message)
Definition Accessors.h:43
Messaging::UInt64 OrderPriority
Represents an order's matching priority.
Definition Order.h:35
Messaging::Int32 SecurityId
Identifies a security in CME MDP 3.0 market data.
Definition Domain.h:31
Messaging::UInt64 OrderId
Identifies an order in a Market By Order book.
Definition Order.h:32
Messaging::Int32 DisplayQuantity
Represents the displayed quantity of an order.
Definition Order.h:38
Messaging::MatchEventIndicator::Bits Bits
Protocol storage type for combined event flags.
Definition EventFlags.h:30
static auto apply(Holder &message, Arguments &&... arguments) -> typename std::enable_if< IsDeleteMdEntryAction< Action >::value||IsValueMdEntryAction< Action >::value, decltype(MdEntryOperation< Action >::apply(message, std::forward< Arguments >(arguments)...))>::type
static auto apply(Holder &message, Arguments &&... arguments) -> decltype(addEntry< Action >(message, std::forward< Arguments >(arguments)...), appendMdEntry< Action >(message, std::forward< Arguments >(arguments)...))
static auto apply(Holder &message, Arguments &&... arguments) -> decltype(addOrderIdEntry< Action >(message, std::forward< Arguments >(arguments)...), appendOrderIdEntry< Action >(message, std::forward< Arguments >(arguments)...))