ITCH 5.0 Market Data Handler 1.0.0
NASDAQ ITCH 5.0 Market Data Feed Handler
Loading...
Searching...
No Matches
Getting Started

Overview

The ITCH Market Data Handler is a high-performance C++ library for processing NASDAQ market data feeds. This guide will help you get started with using the library in your applications.

Prerequisites

Before using the ITCH Market Data Handler, ensure you have:

  • C++20 compatible compiler (MSVC 2019+, GCC 10+, or Clang 11+)
  • Network connectivity to NASDAQ market data feeds
  • Basic understanding of NASDAQ ITCH protocol

Quick Start Example

Here's a minimal example to get you started with ITCH 5.0:

1. Basic ITCH Session

#include <iostream>
int main() {
// Create session settings
settings.host = "your.feed.host";
settings.port = 12345;
// Create and start session
// Connect to the feed
session.start();
// Process messages
session.run();
return 0;
}
ITCH 5.0 Market Data Session.
Definition Session.h:110
ITCH 5.0 Market Data Session implementation.
Combined settings for ITCH 5.0 session.
Definition Session.h:59

2. Handling Market Data

int main() {
auto session = std::make_shared<b2bits::nasdaq::itch50::Session>(settings);
auto handlers = std::make_shared<b2bits::nasdaq::itch50::SessionHandlers>();
handlers->on_add_order([](auto* s, auto* i, auto sn, auto* msg) {
std::cout << "AddOrder: qty=" << msg->get_quantity()
<< " price=" << msg->get_price() << std::endl;
})
.on_order_replace([](auto* s, auto* i, auto sn, auto* msg, auto* order) {
std::cout << "OrderReplace: " << msg->get_original_order_reference_number()
<< " -> " << msg->get_new_order_reference_number() << std::endl;
})
.on_trade([](auto* s, auto* i, auto sn, auto* msg) {
std::cout << "Trade: qty=" << msg->get_executed_quantity()
<< " price=" << msg->get_trade_price() << std::endl;
})
.on_book_update([](auto* s, auto* i, auto ts, auto& update) {
std::cout << "Book: " << (char)update.side_
<< " L" << update.index_ + 1
<< " " << update.qty_ << "@" << update.price_ << std::endl;
})
.on_session_event([](auto* s, auto evt) {
std::cout << "Event: " << static_cast<int>(evt) << std::endl;
});
// Attach handlers to session
session->attach_listener([handlers](auto&&... args) {
(*handlers)(std::forward<decltype(args)>(args)...);
});
session->start();
session->run(); // Blocking call
return 0;
}

Protocol Support

The library supports multiple NASDAQ protocols:

ITCH 5.0

MoldUDP64

SoupBinTCP

  • Purpose: TCP-based session protocol
  • Use Case: Reliable unicast connections
  • Example: See b2bits::nasdaq::soupbintcp::Session

Configuration

Session Settings

Configure your session with appropriate settings:

// Network settings
settings.host = "your.feed.host";
settings.port = 12345;
// Buffer settings
settings.receiveBufferSize = 1024 * 1024; // 1MB
// Timeout settings
settings.connectTimeout = 5000; // 5 seconds
settings.readTimeout = 10000; // 10 seconds

Performance Tuning

For optimal performance:

  1. Use appropriate buffer sizes based on message rates
  2. Enable compiler optimizations (-O3 or /O2)
  3. Consider CPU affinity for real-time processing
  4. Monitor memory usage with message caching

Threading Model

The library uses:

  • Single-threaded message processing by default
  • Event-driven architecture for callbacks
  • Thread-safe components where indicated

Error Handling

Handle errors gracefully:

try {
session.start();
session.run();
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}

Next Steps

Support

For additional help:

  • Review the class documentation
  • Consult the NASDAQ protocol specifications

Ready to dive deeper? Explore the complete API reference in the Classes and Namespaces sections.