Parser for ITCH 5.0, inspired by itchy
but oriented toward live message handling.
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.
- Add
litchto your Rust project (v2024or more recent):
cargo add litch- Create a UDP socket and connect to the TotalView-ITCH broadcast port.
When you receive data, parse it into anItchMessageenum.
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();- Use
matchto extract message contents. All messages havemetadataand abodywhich 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 */}
}- 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 history and current tasks are tracked in TODO.md.
Developer resources:
Contributions are welcome! Submit issues and pull requests to this repository.