litch 0.0.1

Simple parser for ITCH 5.0, oriented toward live messages.
Documentation

litch

Parser for ITCH 5.0, inspired by itchy but oriented toward live message handling.

WARNING: Work-in-progress

This crate should be presumed experimental and non-functional until integration testing has been completed. If you are willing and able to assist with integration testing, please leave a response under this issue.

Use

  1. Add litch to your Rust project (v2024 or more recent):
cargo add litch
  1. Create a UDP socket and connect to the TotalView-ITCH broadcast port. When you receive data, parse it into an ItchMessage enum.
use std::net::UdpSocket;
use litch::ItchMessage;

let socket = UdpSocket::bind(127.0.0.1:0).unwrap();
let mut buf = [0u8; 1024];

// TODO: Connect to TotalView-ITCH feed

let (len, _origin) = socket.recv_from(&mut buf).unwrap();
let msg = ItchMessage::parse(buf[..len]).unwrap();
  1. Use match to extract message contents. All messages have metadata and a body which contains variant-specific data.
use litch::msg::SystemEvent::*;
use ItchMessage::*;

match msg {
    SystemEvent { metadata, body } => {
        match body {
            BeginMessages => {/* Do something */},
            _ => {/* Do something else */}
        }
    },
    _ => {/* Do nothing */}
}
  1. The message metadata (ItchMetadata) can be accessed without matching.
let meta = msg.metadata();
let _time: NaiveTime = meta.timestamp;
let _locate: u16  = meta.stock_locate;
let _num: u16 = meta.tracking_number;

Development

Development history and current tasks are tracked in TODO.md.

Developer resources:

Contributions are welcome! Submit issues and pull requests to this repository.