OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
QuoteRequest.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 <algorithm>
22#include <array>
23#include <cassert>
24#include <cstddef>
25#include <string>
26#include <type_traits>
27#include <utility>
28
29#include <OnixS/CME/MDH/ABI.h>
35#include <OnixS/CME/MDH/Watch.h>
36
38
41
43namespace details
44{
45 template <typename Holder>
47
49 {
50 public:
51 enum : std::size_t { Capacity = 20 };
52
54 : size_((std::min)(symbol.size(), static_cast<std::size_t>(Capacity)))
55 {
56 assert(symbol.size() <= Capacity && "The string is truncated.");
57
58 if (size_ != 0)
59 std::copy_n(symbol.data(), size_, value_.data());
60 }
61
62 operator Messaging::StrRef() const noexcept
63 {
64 return Messaging::StrRef(value_.data(), size_);
65 }
66
67 private:
68 std::array<Messaging::Char, Capacity> value_{};
69 std::size_t size_;
70 };
71
73 enum class QuoteRequestInitializationTag {};
75
77 {
78 template <typename Holder>
79 static auto apply(
80 Holder& message, Messaging::StrRef quoteRequestId, EventFlags::Bits eventIndicator,
81 Messaging::Timestamp transactTime) noexcept -> EnableQuoteRequest<Holder>
82 {
83 message->reset();
84 message->setQuoteReqId(quoteRequestId);
85 message->setMatchEventIndicator(Messaging::MatchEventIndicator(eventIndicator));
86 message->setTransactTime(transactTime);
87
88 return message;
89 }
90 };
91
92 template <typename Holder>
95 Messaging::Int8 quoteType, Messaging::Int32 orderQuantity, Messaging::Int8 side)
96 {
97 auto entry = appendGroupEntry(message->relatedSym(), [&message](
98 typename decltype(message->relatedSym())::Size size) { return message->relatedSym(size); });
99
100 entry.setSecurityId(securityId);
101 entry.setSymbol(symbol);
102 entry.setQuoteType(quoteType);
103 entry.setOrderQty(orderQuantity);
104 entry.setSide(side);
105
106 return entry;
107 }
108}
109
117template <typename Holder, details::QuoteRequestInitializationTag...>
118auto initialize(
119 Holder& message, Messaging::StrRef quoteRequestId,
120 EventFlags::Bits eventIndicator = EventFlags::None,
122{
124 message, quoteRequestId, eventIndicator, transactTime);
125}
126
136template <typename Holder, details::QuoteRequestInitializationTag...>
138auto initialize(
139 Messaging::StrRef quoteRequestId, EventFlags::Bits eventIndicator = EventFlags::None,
140 Messaging::Timestamp transactTime = UtcWatch::now()) -> decltype(
143 quoteRequestId, eventIndicator, transactTime))
144{
147 quoteRequestId, eventIndicator, transactTime);
148}
149
151template <typename Holder, typename String, details::QuoteRequestInitializationTag...>
152auto initialize(
153 String&& quoteRequestId, EventFlags::Bits eventIndicator = EventFlags::None,
154 Messaging::Timestamp transactTime = UtcWatch::now()) -> typename std::enable_if<
155 std::is_same<typename std::decay<String>::type, std::string>::value &&
156 !std::is_lvalue_reference<String>::value>::type = delete;
157
168template <typename Holder>
169auto addQuoteEntry(
171 Messaging::Int8 quoteType, Messaging::Int32 orderQuantity, Messaging::Int8 side)
173{
174 details::appendQuoteEntry(message, securityId, symbol, quoteType, orderQuantity, side);
175 return message;
176}
177
179namespace details
180{
182 {
183 template <typename Holder, typename... Arguments>
184 static auto apply(Holder& message, Arguments&&... arguments) -> decltype(
185 addQuoteEntry(message, std::forward<Arguments>(arguments)...),
186 appendQuoteEntry(message, std::forward<Arguments>(arguments)...))
187 {
188 return appendQuoteEntry(message, std::forward<Arguments>(arguments)...);
189 }
190 };
191}
192
211
213
233#define ONIXS_CMEMDH_QUOTE_ENTRY(...) \
234 ONIXS_CME_MDH_TESTING_NAMESPACE::details::deferMessageOperation([&]() { \
235 return ONIXS_CME_MDH_TESTING_NAMESPACE::quoteEntry(__VA_ARGS__); \
236 })
#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.
QuoteSymbol(Messaging::StrRef symbol) noexcept
static Messaging::Timestamp now() noexcept
Returns current UTC time.
Definition Watch.h:66
std::int8_t Int8
int8.
Definition Integral.h:30
std::int32_t Int32
int32.
Definition Integral.h:34
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
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::QuoteRequest39::RelatedSymEntry appendQuoteEntry(Holder &message, SecurityId securityId, Messaging::StrRef symbol, Messaging::Int8 quoteType, Messaging::Int32 orderQuantity, Messaging::Int8 side)
typename std::enable_if< IsMutableMessageHolder< ExpectedHolder, Holder >::value, Holder & >::type EnableMutableMessageHolder
MessageOperation< Operation, typename std::decay< Arguments >::type... > makeMessageOperation(Arguments &&... arguments)
EnableMutableMessageHolder< QuoteRequest, Holder > EnableQuoteRequest
Group::Entry appendGroupEntry(Group group, Resize resize)
auto quoteEntry(SecurityId securityId, Messaging::StrRef symbol, Messaging::Int8 quoteType, Messaging::Int32 orderQuantity, Messaging::Int8 side) -> decltype(details::makeMessageOperation< details::QuoteEntryOperation >(securityId, details::QuoteSymbol(symbol), quoteType, orderQuantity, side))
Creates a pipeline operation that appends a quote-request entry.
MessageHolder< Messaging::QuoteRequest39 > QuoteRequest
Owns storage for a quote-request test message.
SecurityId securityId(const Messaging::FIX::MultiContainer &message)
Definition Accessors.h:43
Messaging::StrRef symbol(const Messaging::FIX::MultiContainer &message)
Definition Accessors.h:68
Messaging::Int32 SecurityId
Identifies a security in CME MDP 3.0 market data.
Definition Domain.h:31
Messaging::MatchEventIndicator::Bits Bits
Protocol storage type for combined event flags.
Definition EventFlags.h:30
@ None
No event flags are set.
Definition EventFlags.h:36
static auto apply(Holder &message, Arguments &&... arguments) -> decltype(addQuoteEntry(message, std::forward< Arguments >(arguments)...), appendQuoteEntry(message, std::forward< Arguments >(arguments)...))
static auto apply(Holder &message, Messaging::StrRef quoteRequestId, EventFlags::Bits eventIndicator, Messaging::Timestamp transactTime) noexcept -> EnableQuoteRequest< Holder >