JayBeams  0.1
Another project to have fun coding.
array_based_order_book.cpp
Go to the documentation of this file.
2 
3 #include <sstream>
4 
5 namespace jb {
6 namespace itch5 {
7 
8 namespace defaults {
9 #ifndef JB_ITCH5_DEFAULTS_array_based_book_max_size
10 #define JB_ITCH5_DEFAULTS_array_based_book_max_size 8192
11 #endif // JB_ITCH5_DEFAULTS_array_based_book_max_size
12 
14 } // namespace defaults
15 
17  : max_size(
18  desc("max-size")
19  .help("Configure the max size of a array based order book."
20  " Only used when enable-array-based is set"),
21  this, defaults::max_size) {
22 }
23 
24 /// Validate the configuration
26  if (max_size() <= 0) {
27  std::ostringstream os;
28  os << "max-size option must be > 0, value=" << max_size();
29  throw jb::usage(os.str(), 1);
30  }
31 }
32 
33 namespace detail {
35  char const* operation, int qty, price4_t px) {
36  std::ostringstream os;
37  os << "array_based_book_side::" << operation << " - parameters out of range:"
38  << " px=" << px << " should be in [" << price4_t(0) << ","
39  << max_price_field_value<price4_t>() << "), qty=" << qty
40  << " should be >= 0";
41  throw jb::feed_error(os.str());
42 }
43 
45  std::string const& msg, std::size_t tk_begin_top, std::size_t tk_inside,
46  price4_t px, int book_qty, int qty) {
47  std::ostringstream os;
48  os << msg << " tk_begin_top=" << tk_begin_top << ", tk_inside=" << tk_inside
49  << ", px=" << px << ", book_qty=" << book_qty << ", qty=" << qty;
50  throw jb::feed_error(os.str());
51 }
52 } // namespace detail
53 } // namespace itch5
54 } // namespace jb
Define defaults for program parameters.
void raise_invalid_reduce(std::string const &msg, std::size_t tk_begin_top, std::size_t tk_inside, price4_t px, int book_qty, int qty)
Raise an exception describing a invalid reduce operation.
Communicate feed error exceptions.
Definition: feed_error.hpp:11
void raise_invalid_operation_parameters(char const *operation, int qty, price4_t px)
Raise the right exception when we detect invalid parameters for add_order() or reduce_order() ...
#define JB_ITCH5_DEFAULTS_array_based_book_max_size
jb::config_attribute< config, int > max_size
A simple class to communicate the result of parsing the options.
Definition: usage.hpp:11
void validate() const override
Validate the configuration.
price_field< std::uint32_t, 10000 > price4_t
Convenience definition for Price(4) fields.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7