OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Samples Namespace Reference

Namespaces

namespace  Default
namespace  details

Classes

struct  AppConfiguration
class  ArgCarriage
class  BenchmarkConfiguration
class  Book
class  BusSessionGatewayListener
class  ConfigurationBase
class  ConnectivityConfiguration
struct  CrossOrder
class  GatewayEmulatorThread
class  GatewayListener
class  Helper
struct  IdGenerator
class  InputLogFileConfiguration
class  Listener
class  LogonConfiguration
class  MainThreadAffinityConfiguration
struct  MessagePrinter
class  MySessionStorage
class  NetworkInterfaceConfiguration
class  OptionArgConverter
class  OptionArgConverter< const Char * >
class  OptionArgConverter< std::string >
class  Options
struct  Order
class  ReceivingThreadAffinityConfiguration
class  SessionSettings
class  Settings
class  SettingsConfiguration
struct  SignalHelper
class  StorageConfiguration
class  StorageConfigurationBase
class  TradingClient

Typedefs

typedef std::string Option
typedef std::string OptionArg
typedef std::vector< OptionArgOptionArgs
using OrderPtr = std::shared_ptr<Order>
using CrossOrderPtr = std::shared_ptr<CrossOrder>
using NewOrderCrossRequestMsg = MessageHolder<NewOrderCrossRequest, getMaxMessageSize<NewOrderCrossRequest>(NewOrderCrossRequestMaxEntriesCount)>
using NewOrderRequestMsg = MessageHolder<NewOrderRequest>
using SecurityDefinitionRequestMsg = MessageHolder<SecurityDefinitionRequest>
using CancelRequestMsg = MessageHolder<CancelRequest>
using CancelReplaceRequestMsg = MessageHolder<CancelReplaceRequest>
using OrderMassCancelRequestMsg = MessageHolder<OrderMassCancelRequest>
using QuoteRequestMsg = MessageHolder<QuoteRequest>
using QuoteCancelRequestMsg = MessageHolder<QuoteCancelRequest, getMaxMessageSize<QuoteCancelRequest>(QuoteCancelRequestMaxEntriesCount)>
using MassQuoteRequestMsg = MessageHolder<MassQuoteRequest, getMaxMessageSize<MassQuoteRequest>(MassQuoteRequestMaxEntriesCount)>
template<class T>
using hasTransactTime = typename details::hasTransactTimeImpl<cleanType<T>>
template<class T>
using hasExecId = typename details::hasExecIdImpl<cleanType<T>>
template<class T>
using hasExecType = typename details::hasExecTypeImpl<cleanType<T>>
template<class T>
using hasLeavesQty = typename details::hasLeavesQtyImpl<cleanType<T>>
template<typename T>
using OptionalRef = std::optional<std::shared_ptr<T>>

Functions

std::pair< std::unique_ptr< GatewayEmulatorThread< BusSessionGatewayListener > >, std::unique_ptr< GatewayEmulatorThread< GatewayListener > > > createEmulator (const SessionSettings &settings, const ConnectivityConfiguration &cfg, bool tcpDirect=false)
template<typename T>
fromStr (const std::string &s)
std::shared_ptr< void > setPriorityAndPolicy (Session *session=nullptr)
void printBenchmarkSettings (std::ostream &o, size_t numberOfMessages, size_t intervalBetweenSending, size_t warmupInterval, SessionStorageType::Enum storageType)
std::unique_ptr< SessioncreateSession (SessionType::Enum sessionType, SessionSettings settings, SessionListener *listener, SessionStorageType::Enum storageType)
std::unique_ptr< SessioncreateSession (SessionReactor &stack, SessionType::Enum sessionType, SessionSettings settings, SessionListener *listener, SessionStorageType::Enum storageType)
std::unique_ptr< SessioncreateSession (ServiceFactory &factory, SessionType::Enum sessionType, SessionSettings settings, SessionListener *listener, SessionStorageType::Enum storageType)
template<typename T, typename Stack>
std::future< T > wait (Stack &stack, std::promise< T > &promise, std::chrono::seconds timeout=std::chrono::seconds{30})
template<typename T>
std::future< T > wait (std::promise< T > &promise, std::chrono::seconds timeout=std::chrono::seconds{30})
BgwCredentials receiveBgwCredentials (SessionSettings settings, std::string host, Port port)
void throwBadOption (const Char *arg)
void throwDuplicatedOption (const Char *option)
void throwOptionArgConversionFailed (const Char *option)
template<typename T>
bool fromStr (T &result, const std::string &s)
bool fromStr (SessionStorageType::Enum &result, const std::string &s)
template<typename Value>
void convertOptionArg (Value &value, const Char *option, const std::string &str)
void throwBadOptionArgQty (const Char *option, size_t argQty, size_t minQty, size_t maxQty)
void throwReqiredOptionArgMissing (const Char *option)
template<typename Value, typename Iterator>
bool args (const Options &options, const Char *option, Iterator target, size_t minQty=0, size_t maxQty=static_cast< size_t >(-1))
template<typename Value>
Value argOrDefault (const Options &options, const Char *option, const Value &defaultValue=Value())
template<typename Value, size_t Length>
const Value * argOrDefault (const Options &options, const Char *option, Value(&defaultValue)[Length])
template<typename Value>
Value requiredArg (const Options &options, const Char *option)
SessionSettings fillSettings (const LogonConfiguration &logonCfg, const ConnectivityConfiguration &connCfg, const SettingsConfiguration &settingsCfg)
void fillSettings (SessionSettings &settings, const StorageConfigurationBase &cfg)
template<typename Config>
void fillStorageSettings (SessionSettings &settings, const Config &cfg, typename std::enable_if< std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type=nullptr)
template<typename Config>
void fillStorageSettings (SessionSettings &, const Config &, typename std::enable_if<!std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type=nullptr)
template<typename Config>
void fillBenchmarkSettings (SessionSettings &settings, const Config &, typename std::enable_if< std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type=nullptr)
template<typename Config>
void fillBenchmarkSettings (SessionSettings &settings, const Config &, typename std::enable_if<!std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type=nullptr)
template<typename AppCfg>
SessionSettings fillSettings (const AppCfg &cfg)
template<typename ... T>
void ignoreUnusedVariableWarning (T &&...) noexcept
std::string toStr (Order::PriceOptional value)
auto print (OrderPtr order)
bool activeOrder (const Order &order) noexcept
template<typename MsgType>
Timestamp getTransactTime (MsgType &&msg, typename std::enable_if< hasTransactTime< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
Timestamp getTransactTime (MsgType &&msg, typename std::enable_if<!hasTransactTime< MsgType >::value &&hasExecId< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
Timestamp getTransactTime (MsgType &&, typename std::enable_if<!hasTransactTime< MsgType >::value &&!hasExecId< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
ExecTypeEnum getOrdStatus (MsgType &&msg, ExecTypeEnum, typename std::enable_if< hasExecType< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
ExecTypeEnum getOrdStatus (MsgType &&, ExecTypeEnum defaultValue, typename std::enable_if<!hasExecType< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
void setOrdStatus (Order &order, MsgType &&msg, ExecTypeEnum defaultValue)
template<typename MsgType>
void setLeavesQty (Order &order, MsgType &&msg, typename std::enable_if< hasLeavesQty< MsgType >::value, void * >::type=nullptr)
template<typename MsgType>
void setLeavesQty (Order &, MsgType &&, typename std::enable_if<!hasLeavesQty< MsgType >::value, void * >::type=nullptr)
Decimal9 toPriceMantissa (Decimal value)
template<typename T>
parseUserInput (const std::string &userInput, typename std::enable_if< std::is_integral< T >::value, void * >::type=nullptr)
template<typename T>
parseUserInput (const std::string &userInput, typename std::enable_if< isScopedEnum< T >::value, void * >::type=nullptr)
template<typename T>
Decimal parseUserInput (const std::string &userInput, typename std::enable_if< std::is_floating_point< T >::value, void * >::type=nullptr)
template<typename T>
parseUserInput (const std::string &userInput, typename std::enable_if< std::is_same< T, std::string >::value, void * >::type=nullptr)
template<typename T>
auto toValueNamePair (T v, typename std::enable_if< isScopedEnum< T >::value, void * >::type=nullptr)
template<typename It>
auto join (It first, It last, char delim, typename std::enable_if< isScopedEnum< typename It::value_type >::value, void * >::type=nullptr)

Variables

constexpr size_t NewOrderCrossRequestMaxEntriesCount = 2
constexpr size_t QuoteCancelRequestMaxEntriesCount = 1
constexpr size_t MassQuoteRequestMaxEntriesCount = 2

Typedef Documentation

◆ CancelReplaceRequestMsg

◆ CancelRequestMsg

Definition at line 38 of file TradingClient.h.

◆ CrossOrderPtr

using CrossOrderPtr = std::shared_ptr<CrossOrder>

Definition at line 104 of file Order.h.

◆ hasExecId

template<class T>
using hasExecId = typename details::hasExecIdImpl<cleanType<T>>

Definition at line 87 of file Utils.h.

◆ hasExecType

template<class T>
using hasExecType = typename details::hasExecTypeImpl<cleanType<T>>

Definition at line 88 of file Utils.h.

◆ hasLeavesQty

template<class T>
using hasLeavesQty = typename details::hasLeavesQtyImpl<cleanType<T>>

Definition at line 89 of file Utils.h.

◆ hasTransactTime

template<class T>
using hasTransactTime = typename details::hasTransactTimeImpl<cleanType<T>>

Definition at line 86 of file Utils.h.

◆ MassQuoteRequestMsg

◆ NewOrderCrossRequestMsg

◆ NewOrderRequestMsg

Definition at line 36 of file TradingClient.h.

◆ Option

typedef std::string Option

Definition at line 33 of file Options.h.

◆ OptionalRef

template<typename T>
using OptionalRef = std::optional<std::shared_ptr<T>>

Manages an optional contained reference.

Definition at line 224 of file Utils.h.

◆ OptionArg

typedef std::string OptionArg

Definition at line 34 of file Options.h.

◆ OptionArgs

typedef std::vector<OptionArg> OptionArgs

Definition at line 35 of file Options.h.

◆ OrderMassCancelRequestMsg

◆ OrderPtr

using OrderPtr = std::shared_ptr<Order>

Definition at line 75 of file Order.h.

◆ QuoteCancelRequestMsg

◆ QuoteRequestMsg

Definition at line 41 of file TradingClient.h.

◆ SecurityDefinitionRequestMsg

Function Documentation

◆ activeOrder()

bool activeOrder ( const Order & order)
noexcept

Definition at line 1053 of file TradingClient.cpp.

1054{
1055 return order.orderStatus_ == ExecTypeEnum::New || order.orderStatus_ == ExecTypeEnum::PartialFill || order.orderStatus_ == ExecTypeEnum::Replaced;
1056}
ExecTypeEnum orderStatus_
Definition Order.h:70

◆ argOrDefault() [1/2]

template<typename Value>
Value argOrDefault ( const Options & options,
const Char * option,
const Value & defaultValue = Value() )
inline

Definition at line 375 of file Options.h.

376{
377 Value value = defaultValue;
378
379 args<Value>(options, option, &value, 1, 1);
380
381 return value;
382}
bool args(const Options &options, const Char *option, Iterator target, size_t minQty=0, size_t maxQty=static_cast< size_t >(-1))
Definition Options.h:345

◆ argOrDefault() [2/2]

template<typename Value, size_t Length>
const Value * argOrDefault ( const Options & options,
const Char * option,
Value(&) defaultValue[Length] )
inline

Definition at line 385 of file Options.h.

386{
387 return argOrDefault<const Value*>(options, option, static_cast<const Value*>(defaultValue));
388}
Value argOrDefault(const Options &options, const Char *option, const Value &defaultValue=Value())
Definition Options.h:375

◆ args()

template<typename Value, typename Iterator>
bool args ( const Options & options,
const Char * option,
Iterator target,
size_t minQty = 0,
size_t maxQty = static_cast<size_t>(-1) )
inline

Definition at line 345 of file Options.h.

352{
353 if (const OptionArgs* args = options.args(option))
354 {
355 const size_t argQty = args->size();
356
357 if (minQty <= argQty && maxQty >= argQty)
358 {
359 const OptionArgConverter<Value> converter(option);
360
361 std::transform(args->begin(), args->end(), target, converter);
362
363 return true;
364 }
365 else
366 {
367 throwBadOptionArgQty(option, argQty, minQty, maxQty);
368 }
369 }
370
371 return false;
372}
const OptionArgs * args(const char *option) const
Definition Options.h:160
std::vector< OptionArg > OptionArgs
Definition Options.h:35
void throwBadOptionArgQty(const Char *option, size_t argQty, size_t minQty, size_t maxQty)
Definition Options.h:298

◆ convertOptionArg()

template<typename Value>
void convertOptionArg ( Value & value,
const Char * option,
const std::string & str )
inline

Definition at line 291 of file Options.h.

292{
293 const OptionArgConverter<Value> converter(option);
294
295 value = converter(str);
296}

◆ createEmulator()

std::pair< std::unique_ptr< GatewayEmulatorThread< BusSessionGatewayListener > >, std::unique_ptr< GatewayEmulatorThread< GatewayListener > > > createEmulator ( const SessionSettings & settings,
const ConnectivityConfiguration & cfg,
bool tcpDirect = false )
inline

Definition at line 157 of file Emulator.h.

158{
159 if(cfg.useEmulator())
160 {
161#if !defined (_WIN32)
162 if(tcpDirect)
163 throw std::runtime_error("Emulator is not supported for TCPDirect.");
164#endif
165
166 std::clog << "!Emulator is used!" << std::endl;
167
168 auto bgwSessionGatewayListener = std::make_unique<GatewayListener>();
169 auto bgwSessionEmulatorThread = std::make_unique<GatewayEmulatorThread<GatewayListener>>(settings.licenseStores(), "127.0.0.1", 0, std::move(bgwSessionGatewayListener));
170
171 auto busSessionGatewayListener = std::make_unique<BusSessionGatewayListener>(bgwSessionEmulatorThread->gateway().host(), bgwSessionEmulatorThread->gateway().port());
172 auto busSessionEmulatorThread = std::make_unique<GatewayEmulatorThread<BusSessionGatewayListener>>(settings.licenseStores(), "127.0.0.1", cfg.port(), std::move(busSessionGatewayListener));
173
174 return std::make_pair(std::move(busSessionEmulatorThread), std::move(bgwSessionEmulatorThread));
175 }
176
177 return {};
178}
const LicenseStores & licenseStores() const noexcept

◆ createSession() [1/3]

std::unique_ptr< Session > createSession ( ServiceFactory & factory,
SessionType::Enum sessionType,
SessionSettings settings,
SessionListener * listener,
SessionStorageType::Enum storageType )
inline

Definition at line 205 of file Helpers.h.

206{
207 return std::unique_ptr<Session>{new Session(factory, sessionType, settings, listener, storageType, nullptr, {})};
208}

◆ createSession() [2/3]

std::unique_ptr< Session > createSession ( SessionReactor & stack,
SessionType::Enum sessionType,
SessionSettings settings,
SessionListener * listener,
SessionStorageType::Enum storageType )
inline

Definition at line 199 of file Helpers.h.

200{
201 return std::unique_ptr<Session>{new Session(stack, sessionType, settings, listener, storageType, nullptr, {})};
202}

◆ createSession() [3/3]

std::unique_ptr< Session > createSession ( SessionType::Enum sessionType,
SessionSettings settings,
SessionListener * listener,
SessionStorageType::Enum storageType )
inline

Definition at line 193 of file Helpers.h.

194{
195 return std::unique_ptr<Session>{new Session(sessionType, settings, listener, storageType, nullptr, {})};
196}

◆ fillBenchmarkSettings() [1/2]

template<typename Config>
void fillBenchmarkSettings ( SessionSettings & settings,
const Config & ,
typename std::enable_if< std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type = nullptr )

Definition at line 83 of file Settings.h.

84{
85 if(settings.useTLS())
86 {
87 std::cerr << "Please disable TLS for benchmarking." << std::endl;
88 exit(1);
89 }
90
91 settings.logLevel(LogLevel::Error);
93}
LogLevel::Enum logLevel() const noexcept
The default value is LogLevel::Info.
LogSettings::Enum loggerOptions() const noexcept
@ Error
A serious error that prevents normal execution.
Definition LogSettings.h:33
@ TraceToFile
Trace to the log file.
Definition LogSettings.h:65

◆ fillBenchmarkSettings() [2/2]

template<typename Config>
void fillBenchmarkSettings ( SessionSettings & settings,
const Config & ,
typename std::enable_if<!std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type = nullptr )

Definition at line 96 of file Settings.h.

97{
98 settings.logLevel(LogLevel::Debug);
99}
@ Debug
Detailed diagnostic information useful during development and testing.
Definition LogSettings.h:45

◆ fillSettings() [1/3]

template<typename AppCfg>
SessionSettings fillSettings ( const AppCfg & cfg)

Definition at line 102 of file Settings.h.

103{
104 auto settings = fillSettings(cfg, cfg, cfg);
105 fillStorageSettings(settings, cfg);
106 fillBenchmarkSettings(settings, cfg);
107 return settings;
108}
void fillStorageSettings(SessionSettings &settings, const Config &cfg, typename std::enable_if< std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type=nullptr)
Definition Settings.h:73
void fillBenchmarkSettings(SessionSettings &settings, const Config &, typename std::enable_if< std::is_base_of< BenchmarkConfiguration, Config >::value, void * >::type=nullptr)
Definition Settings.h:83
SessionSettings fillSettings(const LogonConfiguration &logonCfg, const ConnectivityConfiguration &connCfg, const SettingsConfiguration &settingsCfg)
Definition Settings.h:32

◆ fillSettings() [2/3]

SessionSettings fillSettings ( const LogonConfiguration & logonCfg,
const ConnectivityConfiguration & connCfg,
const SettingsConfiguration & settingsCfg )
inline

Definition at line 32 of file Settings.h.

34{
35 SessionSettings settings;
36
37 const auto settingsFilename = settingsCfg.settingsFile();
38
39 if (ONIXS_ICEBOE_NAMESPACE::Filesystem::exist(settingsFilename))
40 {
41 settings.load(settingsFilename);
42 }
43 else
44 {
45 settings
46 .licenseStore("../../license")
47 .userId(logonCfg.userId())
48 .clientId(logonCfg.clientId())
49 .rawData(logonCfg.password());
50 }
51
52 if(connCfg.useEmulator())
53 settings.keepAliveInterval(5).reconnectAttempts(0);
54
55 settings.useTLS(connCfg.useTLS());
56
57 if(settings.useTLS())
58 std::cerr << "TLS connection is selected." << std::endl;
59
60 return settings;
61}
const std::string & userId() const noexcept
unsigned short keepAliveInterval() const noexcept
SessionSettings & load(const std::string &configFile)
Loads the settings from the given configuration file.
SessionSettings & licenseStore(const std::string &value)
Sets the path to the folder that contains license file(s).
std::string password() const
Definition Options.h:543
std::string userId() const
Definition Options.h:538
std::string settingsFile() const
Definition Options.h:489

◆ fillSettings() [3/3]

void fillSettings ( SessionSettings & settings,
const StorageConfigurationBase & cfg )
inline

Definition at line 64 of file Settings.h.

65{
66 const auto storageType = cfg.storage();
67
68 if(storageType == SessionStorageType::AsyncFileBased)
70}
const CpuIndexes & asyncFileBasedStorageThreadAffinity() const noexcept
OnixS::ICE::BOE::CpuIndex storageAffinity() const
Definition Options.h:583
OnixS::ICE::BOE::SessionStorageType::Enum storage() const
Definition Options.h:578
@ AsyncFileBased
Asynchronous File-Based Session Storage.

◆ fillStorageSettings() [1/2]

template<typename Config>
void fillStorageSettings ( SessionSettings & ,
const Config & ,
typename std::enable_if<!std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type = nullptr )

Definition at line 79 of file Settings.h.

79{}

◆ fillStorageSettings() [2/2]

template<typename Config>
void fillStorageSettings ( SessionSettings & settings,
const Config & cfg,
typename std::enable_if< std::is_base_of< StorageConfigurationBase, Config >::value, void * >::type = nullptr )

Definition at line 73 of file Settings.h.

74{
75 fillSettings(settings, cfg);
76}

◆ fromStr() [1/3]

template<typename T>
T fromStr ( const std::string & s)

Definition at line 142 of file Helpers.h.

143{
144 std::istringstream ss(s);
145 T result = T();
146 ss >> result;
147 return result;
148}

◆ fromStr() [2/3]

bool fromStr ( SessionStorageType::Enum & result,
const std::string & s )
inline

Definition at line 230 of file Options.h.

231{
232 try
233 {
234 result = SessionStorageType::parse(s);
235 return true;
236 }
237 catch(...)
238 {
239 return false;
240 }
241}
static Enum parse(const std::string &)

◆ fromStr() [3/3]

template<typename T>
bool fromStr ( T & result,
const std::string & s )

Definition at line 224 of file Options.h.

225{
226 return Messaging::fromStr(result, s.data(), s.size());
227}
bool fromStr(Decimal &, const Char *, size_t) noexcept
Deserializes a decimal number from the given text presentation.

◆ getOrdStatus() [1/2]

template<typename MsgType>
ExecTypeEnum getOrdStatus ( MsgType && ,
ExecTypeEnum defaultValue,
typename std::enable_if<!hasExecType< MsgType >::value, void * >::type = nullptr )

Definition at line 116 of file Utils.h.

117{
118 return defaultValue;
119}

◆ getOrdStatus() [2/2]

template<typename MsgType>
ExecTypeEnum getOrdStatus ( MsgType && msg,
ExecTypeEnum ,
typename std::enable_if< hasExecType< MsgType >::value, void * >::type = nullptr )

Definition at line 110 of file Utils.h.

111{
112 return msg.execType();
113}

◆ getTransactTime() [1/3]

template<typename MsgType>
Timestamp getTransactTime ( MsgType && ,
typename std::enable_if<!hasTransactTime< MsgType >::value &&!hasExecId< MsgType >::value, void * >::type = nullptr )

Definition at line 104 of file Utils.h.

105{
106 return Timestamp{};
107}
The time point without the time-zone information.
Definition Time.h:470

◆ getTransactTime() [2/3]

template<typename MsgType>
Timestamp getTransactTime ( MsgType && msg,
typename std::enable_if< hasTransactTime< MsgType >::value, void * >::type = nullptr )

Definition at line 92 of file Utils.h.

93{
94 return msg.transactTime();
95}

◆ getTransactTime() [3/3]

template<typename MsgType>
Timestamp getTransactTime ( MsgType && msg,
typename std::enable_if<!hasTransactTime< MsgType >::value &&hasExecId< MsgType >::value, void * >::type = nullptr )

Definition at line 98 of file Utils.h.

99{
100 return msg.execId().transactTime();
101}

◆ ignoreUnusedVariableWarning()

template<typename ... T>
void ignoreUnusedVariableWarning ( T && ...)
noexcept

Definition at line 23 of file Tools.h.

23{}

◆ join()

template<typename It>
auto join ( It first,
It last,
char delim,
typename std::enable_if< isScopedEnum< typename It::value_type >::value, void * >::type = nullptr )
inline

Definition at line 208 of file Utils.h.

209{
210 if (first == last)
211 return std::string{};
212
213 std::ostringstream oss;
214 oss << toValueNamePair(*first);
215 ++first;
216 for (; first != last; ++first)
217 oss << delim << toValueNamePair(*first);
218
219 return oss.str();
220}
auto toValueNamePair(T v, typename std::enable_if< isScopedEnum< T >::value, void * >::type=nullptr)
Definition Utils.h:202

◆ parseUserInput() [1/4]

template<typename T>
T parseUserInput ( const std::string & userInput,
typename std::enable_if< isScopedEnum< T >::value, void * >::type = nullptr )

Definition at line 157 of file Utils.h.

158{
159 std::istringstream ss{userInput};
160 ss >> std::ws;
161
162 using Wide =
163 typename std::conditional<
164 std::is_same<typename underlyingType<T>::type, char>::value,
165 char,
166 typename std::conditional<std::is_signed<T>::value,
167 long long,
168 unsigned long long>::type>::type;
169
170 Wide converted{};
171
172 if (!(ss >> converted))
173 throw std::invalid_argument("Invalid user input: '" + userInput + "'");
174
175 const auto enumerated = static_cast<T>(static_cast<typename underlyingType<T>::type>(converted));
176
177 if(ONIXS_ICEBOE_MESSAGING_NAMESPACE::toStr(enumerated).find("UNKNOWN_VALUE") != std::string::npos)
178 throw std::invalid_argument("Invalid user input: '" + userInput + "'");
179
180 return enumerated;
181}

◆ parseUserInput() [2/4]

template<typename T>
Decimal parseUserInput ( const std::string & userInput,
typename std::enable_if< std::is_floating_point< T >::value, void * >::type = nullptr )

Definition at line 184 of file Utils.h.

185{
186 Decimal value;
187
188 if(fromStr(value, userInput))
189 return value;
190
191 throw std::invalid_argument("Invalid user input: '" + userInput + "'");
192}
FloatingPointDecimal< Int64, Int32 > Decimal
Universal decimal type.
T fromStr(const std::string &s)
Definition Helpers.h:142

◆ parseUserInput() [3/4]

template<typename T>
T parseUserInput ( const std::string & userInput,
typename std::enable_if< std::is_integral< T >::value, void * >::type = nullptr )

Definition at line 142 of file Utils.h.

143{
144 std::istringstream ss{userInput};
145 ss >> std::ws;
146
147 using Wide = typename std::conditional<std::is_signed<T>::value, long long, unsigned long long>::type;
148 Wide converted{};
149
150 if (!(ss >> converted))
151 throw std::invalid_argument("Invalid user input: '" + userInput + "'");
152
153 return static_cast<T>(converted);
154}

◆ parseUserInput() [4/4]

template<typename T>
T parseUserInput ( const std::string & userInput,
typename std::enable_if< std::is_same< T, std::string >::value, void * >::type = nullptr )

Definition at line 195 of file Utils.h.

196{
197 return userInput;
198}

◆ print()

auto print ( OrderPtr order)
inline

Definition at line 77 of file Order.h.

78{
79 return order ? order->toString() : toStr(nullOpt);
80}
std::string toStr(Order::PriceOptional value)
Definition Order.cpp:34
std::string toString() const
Human-readable presentation of the most interesting fields stored in the order.
Definition Order.cpp:39

◆ printBenchmarkSettings()

void printBenchmarkSettings ( std::ostream & o,
size_t numberOfMessages,
size_t intervalBetweenSending,
size_t warmupInterval,
SessionStorageType::Enum storageType )
inline

Definition at line 182 of file Helpers.h.

184{
185 o << "\n\n\n****" << std::endl;
186
187 o << std::endl << "Benchmark Parameters: numberOfMessages=" << numberOfMessages << "; intervalBetweenSending(μSec)=" << intervalBetweenSending
188 << "; warmupInterval(μSec)=" << warmupInterval
189 << "; StorageType=" << SessionStorageType::toString(storageType) << '.' << std::endl;
190}
static const char * toString(SessionStorageType::Enum)

◆ receiveBgwCredentials()

BgwCredentials receiveBgwCredentials ( SessionSettings settings,
std::string host,
Port port )
inline

Definition at line 264 of file Listener.h.

265{
267
268 Listener listener;
269
270 // Create an instance of a `BUS` session.
271 BusSession busSession(settings, &listener);
272
273 // Connect.
274 busSession.connect(host, port);
275
276 const auto bgwCredentialsFuture = busSession.getBgwCredentialsAsync(settings.userId());
277
278 const auto bgwCredentials = bgwCredentialsFuture.get();
279
280 // Disconnect.
281 busSession.disconnect();
282
283 return bgwCredentials;
284}
ThreadingModel::Enum threadingModel() const noexcept
@ Dedicated
Each session has a sender thread and a receiving thread.

◆ requiredArg()

template<typename Value>
Value requiredArg ( const Options & options,
const Char * option )
inline

Definition at line 391 of file Options.h.

392{
393 const OptionArgs* args = options.args(option);
394
395 if (nullptr == args || 1 != args->size())
396 {
398 }
399
400 const OptionArgConverter<Value> converter(option);
401
402 return converter((*args)[0]);
403}
void throwReqiredOptionArgMissing(const Char *option)
Definition Options.h:329

◆ setLeavesQty() [1/2]

template<typename MsgType>
void setLeavesQty ( Order & ,
MsgType && ,
typename std::enable_if<!hasLeavesQty< MsgType >::value, void * >::type = nullptr )

Definition at line 134 of file Utils.h.

134{}

◆ setLeavesQty() [2/2]

template<typename MsgType>
void setLeavesQty ( Order & order,
MsgType && msg,
typename std::enable_if< hasLeavesQty< MsgType >::value, void * >::type = nullptr )

Definition at line 128 of file Utils.h.

129{
130 order.leavesQty_ = msg.leavesQty();
131}
Qty leavesQty_
Definition Order.h:61

◆ setOrdStatus()

template<typename MsgType>
void setOrdStatus ( Order & order,
MsgType && msg,
ExecTypeEnum defaultValue )

Definition at line 122 of file Utils.h.

123{
124 order.orderStatus_ = getOrdStatus(msg, defaultValue);
125}
ExecTypeEnum getOrdStatus(MsgType &&msg, ExecTypeEnum, typename std::enable_if< hasExecType< MsgType >::value, void * >::type=nullptr)
Definition Utils.h:110

◆ setPriorityAndPolicy()

std::shared_ptr< void > setPriorityAndPolicy ( Session * session = nullptr)
inline

Definition at line 150 of file Helpers.h.

151{
152#ifdef _WIN32
153 ONIXS_ICEBOE_NAMESPACE::Threading::ThisThread::priority(THREAD_PRIORITY_ABOVE_NORMAL);
154
155 if(session)
156 session->receivingThreadPriority(THREAD_PRIORITY_ABOVE_NORMAL);
157#else
158 const int policy = SCHED_RR;
159 try
160 {
162
163 if(session)
164 session->receivingThreadPolicy(policy);
165 }
166 catch (const std::exception&)
167 {
168 std::cerr << "\nWARNING: Cannot change the scheduling policy to " << policy <<
169 ", it requires root permissions, so you either have to be root or run it with sudo." << std::endl;
170 }
171#endif
172
173 return std::shared_ptr<void>{nullptr, [](void*)
174 {
175#ifndef _WIN32
176 ONIXS_ICEBOE_NAMESPACE::Threading::ThisThread::policy(SCHED_OTHER);
177#endif
178 }};
179}
int receivingThreadPolicy() const
int receivingThreadPriority() const
static void policy(int policy)
Sets the scheduling policy for the current thread.

◆ throwBadOption()

void throwBadOption ( const Char * arg)
inline

Definition at line 74 of file Options.h.

75{
76 assert(arg);
77
78 std::string issue;
79
80 issue += "The given argument [";
81 issue += arg;
82 issue += "] does not represent an option which must begin with the '--' prefix. ";
83
84 throw std::runtime_error(issue);
85}

◆ throwBadOptionArgQty()

void throwBadOptionArgQty ( const Char * option,
size_t argQty,
size_t minQty,
size_t maxQty )
inline

Definition at line 298 of file Options.h.

299{
300 assert(nullptr != option);
301
302 std::string issue;
303
304 issue += "Number of arguments for the option [";
305
306 issue += option;
307
308 issue += "] does not meet the requirements. "
309 "It must be not less than ";
310
311 toStr(issue, minQty);
312
313 if (maxQty != static_cast<size_t>(-1))
314 {
315 issue += " and not greater than ";
316
317 toStr(issue, maxQty);
318 }
319
320 issue += ". Meanwhile, the actual number is ";
321
322 toStr(issue, argQty);
323
324 issue += ". ";
325
326 throw std::runtime_error(issue);
327}

◆ throwDuplicatedOption()

void throwDuplicatedOption ( const Char * option)
inline

Definition at line 87 of file Options.h.

88{
89 std::string issue;
90
91 issue += "The given option [";
92 issue += option;
93 issue += "] is defined twice in the argument list. ";
94
95 throw std::runtime_error(issue);
96}

◆ throwOptionArgConversionFailed()

void throwOptionArgConversionFailed ( const Char * option)
inline

Definition at line 209 of file Options.h.

210{
211 assert(nullptr != option);
212
213 std::string issue;
214
215 issue += "Value for the option [";
216 issue += option;
217 issue += "] is not recognized. Run application help for information on valid values for the option. ";
218
219 throw std::runtime_error(issue);
220}

◆ throwReqiredOptionArgMissing()

void throwReqiredOptionArgMissing ( const Char * option)
inline

Definition at line 329 of file Options.h.

330{
331 assert(nullptr != option);
332
333 std::string issue;
334
335 issue += "The required option [";
336
337 issue += option;
338
339 issue += "] or its argument is missing. ";
340
341 throw std::runtime_error(issue);
342}

◆ toPriceMantissa()

Decimal9 toPriceMantissa ( Decimal value)
inline

Definition at line 136 of file Utils.h.

137{
138 return quantize(value, -9).mantissa();
139}
bool quantize(const Decimal &operand, Int32 exponent, Decimal &quantized)
Quantize so its exponent is the same as that of provided value.

◆ toStr()

std::string toStr ( Order::PriceOptional value)

Definition at line 34 of file Order.cpp.

35{
36 return (value != nullOpt) ? toStr(Decimal{*value, -9}) : toStr(nullOpt);
37}

◆ toValueNamePair()

template<typename T>
auto toValueNamePair ( T v,
typename std::enable_if< isScopedEnum< T >::value, void * >::type = nullptr )

Definition at line 202 of file Utils.h.

203{
204 return toStr(toUnderlying(v)) + "-" + toStr(v);
205}

◆ wait() [1/2]

template<typename T, typename Stack>
std::future< T > wait ( Stack & stack,
std::promise< T > & promise,
std::chrono::seconds timeout = std::chrono::seconds{30} )

Definition at line 227 of file Listener.h.

227 {30})
228{
229 auto future = promise.get_future();
230
231 const auto deadline = std::chrono::steady_clock::now() + timeout;
232 std::uint32_t spins = 0;
233
234 for (;;)
235 {
236 stack.dispatchEvents();
237
238 if (future.wait_for(std::chrono::nanoseconds{0}) == std::future_status::ready)
239 return future;
240
241 if ((++spins & 0xFFu) == 0) // every 256 iterations
242 {
243 if (std::chrono::steady_clock::now() >= deadline)
244 {
245 promise.set_exception(std::make_exception_ptr(std::runtime_error("Operation timed out.")));
246 return future;
247 }
248 }
249 }
250}

◆ wait() [2/2]

template<typename T>
std::future< T > wait ( std::promise< T > & promise,
std::chrono::seconds timeout = std::chrono::seconds{30} )

Definition at line 253 of file Listener.h.

253 {30})
254{
255 auto future = promise.get_future();
256
257 if(future.wait_for(timeout) != std::future_status::ready)
258 promise.set_exception(std::make_exception_ptr(std::runtime_error("Operation timed out.")));
259
260 return future;
261}

Variable Documentation

◆ MassQuoteRequestMaxEntriesCount

size_t MassQuoteRequestMaxEntriesCount = 2
constexpr

Definition at line 33 of file TradingClient.h.

◆ NewOrderCrossRequestMaxEntriesCount

size_t NewOrderCrossRequestMaxEntriesCount = 2
constexpr

Definition at line 31 of file TradingClient.h.

◆ QuoteCancelRequestMaxEntriesCount

size_t QuoteCancelRequestMaxEntriesCount = 1
constexpr

Definition at line 32 of file TradingClient.h.