34 class trades_handler {
48 explicit trades_handler(std::ostream& out)
61 time_point recvts,
long msgcnt, std::size_t msgoffset,
72 template <
typename message_type>
73 void handle_message(time_point,
long, std::size_t, message_type
const&) {
85 time_point now()
const {
86 return std::chrono::steady_clock::now();
95 int main(
int argc,
char* argv[])
try {
97 cfg.load_overrides(argc, argv, std::string(
"itch5trades.yaml"),
"JB_ROOT");
100 boost::iostreams::filtering_istream in;
103 boost::iostreams::filtering_ostream out;
106 trades_handler handler(out);
111 std::cerr << u.what() << std::endl;
113 }
catch (std::exception
const& ex) {
114 std::cerr <<
"Standard exception raised: " << ex.what() << std::endl;
117 std::cerr <<
"Unknown exception raised" << std::endl;
125 desc(
"input-file").help(
"An input file with ITCH-5.0 messages."),
129 .help(
"The name of the file where to store the inside data." 130 " Files ending in .gz are automatically compressed."),
132 , log(desc(
"log",
"logging"),
this) {
135 void config::validate()
const {
136 if (input_file() ==
"") {
138 "Missing input-file setting." 139 " You must specify an input file.",
142 if (output_file() ==
"") {
144 "Missing output-file setting." 145 " You must specify an output file.",
151 void trades_handler::handle_message(
159 void trades_handler::handle_unknown(
161 char msgtype = *
static_cast<char const*
>(msg.
buf());
162 JB_LOG(error) <<
"Unknown message type '" << msgtype <<
"'(" << int(msgtype)
163 <<
") in msgcnt=" << msg.
count()
164 <<
", msgoffset=" << msg.
offset();
clock_type::time_point time_point
A convenience alias for clock_type::time_point.
Base class for all configuration objects.
virtual void validate() const
Validate the settings.
void open_output_file(boost::iostreams::filtering_ostream &out, std::string const &filename)
Open a file for writing.
void process_iostream(std::istream &in, message_handler &handler)
Process an iostream of ITCH-5.0 messages.
std::uint64_t match_number
std::chrono::steady_clock clock_type
A convenience alias for clock_type.
void init(config const &cfg)
Initialize the logging functions using the configuration provided.
#define config_object_constructors(NAME)
Helper class to easily define configuration attributes.
std::uint64_t order_reference_number
Represent an 'Trade (non-Cross)' message in the ITCH-5.0 protocol.
std::chrono::nanoseconds ts
A simple class to communicate the result of parsing the options.
void open_input_file(boost::iostreams::filtering_istream &in, std::string const &filename)
Open a file for reading.
buy_sell_indicator_t buy_sell_indicator
int main(int argc, char *argv[])
jb::itch5::timestamp timestamp
The message timestamp, in nanoseconds since midnight.
int as_int() const
Return the integer value.
std::uint32_t count() const
std::uint64_t offset() const