Introduction#

OUCH 5.0 Client Library is a production-ready C++ client library for the Nasdaq OUCH 5.0 protocol, built on top of SoupBinTCP for reliable message transport.

What is OUCH 5.0?#

OUCH (Order Entry Protocol) is a low-level, high-performance order entry protocol for sending, replacing, canceling, and receiving updates on orders. It is designed for proprietary trading systems requiring maximal throughput and minimal latency.

OUCH 5.0 is the latest version of the protocol, featuring:

  • TagValue Appendages: Variable-length messages with optional fields

  • UserRefNum: Strictly increasing 4-byte reference numbers

  • Price Format: UInt64 on wire (8 bytes), 4 implied decimals

  • Timestamps: Nanoseconds since midnight

Overview#

This library provides a complete implementation of the OUCH 5.0 protocol specification, including:

  • Session Management: Connection handling, login/logout, state management

  • Message Types: All OUCH 5.0 egress (Client → Exchange) and ingress (Exchange → Client) message types

  • TagValue Support: Variable-length message appendages with optional fields

  • UserRefNum Management: Strictly increasing reference number generation with persistence

  • Message Buffering: Optional egress message buffering for retransmission

  • Timestamp Handling: Type-safe OUCH 5.0 timestamp utilities (nanoseconds since midnight)

  • Price Type: Type-safe price handling with 4 implied decimals

  • Error Handling: Comprehensive error handling and recovery

Architecture#

Components#

  • Session (Session.h): Main session class for OUCH 5.0 communication

  • Messages (Messages.h): All OUCH 5.0 message type definitions

  • TagValue (TagValue.h): TagValue appendage infrastructure for variable-length messages

  • UserRefNumGenerator (UserRefNumGenerator.h): Strictly increasing reference number management

  • OutboundMessageBuffer (OutboundMessageBuffer.h): Optional message buffering for retransmission

  • TimestampUtil (TimestampUtil.h): OUCH 5.0 timestamp utilities (nanoseconds since midnight)

  • Price (Types.h): Type-safe price handling with 4 implied decimals

  • MessageView (MessageView.h): Lightweight message wrapper for manual parsing

Namespace#

All OUCH 5.0 code is in the b2bits::nasdaq::ouch5 namespace.

Next Steps#