Crates.io | minifix |
lib.rs | minifix |
version | 0.3.0 |
created_at | 2021-05-11 19:56:41.28157+00 |
updated_at | 2025-09-24 16:43:17.969059+00 |
description | A bare essentials library for Financial Information Exchange (FIX) |
homepage | https://github.com/cryptopatrick/minifix |
repository | https://github.com/cryptopatrick/minifix |
max_upload_size | |
id | 396264 |
size | 14,685,916 |
What is miniFIX • Features • How To Use • Documentation • License
minifix
is a high-performance, memory-safe Rust library for parsing, manipulating, and generating FIX (Financial Information Exchange) protocol messages. Designed for speed, safety, and ease of use in financial trading systems, it provides zero-copy parsing, type-safe field access, and comprehensive support for FIX protocol versions 4.0 through 4.4. miniFIX is a derivation of the FerrumFIX crate. Our goal is to create a slimmed-down-bare-essentials version of the original crate.
Please note that a lot of the code in miniFIX is drawn from FerrumFIX, and published in accordance with the MIT license (see LICENSE).
miniFIX is organized into several focused crates:
use minifix::prelude::*;
// Parse a FIX message
let message = b"8=FIX.4.2|9=49|35=D|49=SENDER|56=TARGET|34=1|52=20230101-12:00:00|55=AAPL|54=1|38=100|10=123|";
let mut decoder = Decoder::new(Dictionary::fix42());
decoder.config_mut().separator = b'|'; // For display (normally SOH)
let msg = decoder.decode(message)?;
println!("Symbol: {:?}", msg.get::<&[u8]>(fix42::SYMBOL)?); // "AAPL"
// Type-safe field access
let seq_num: u32 = msg.get(fix42::MSG_SEQ_NUM)?; // Integer field
let symbol: &[u8] = msg.get(fix42::SYMBOL)?; // String field
let side: fix42::Side = msg.get(fix42::SIDE)?; // Enumeration field
// Encode a new message
let mut encoder = Encoder::new();
let mut buffer = Vec::new();
let mut new_msg = encoder.start_message(b"FIX.4.3", &mut buffer, b"D");
new_msg.set(fix43::CL_ORD_ID, "ORDER-12345");
new_msg.set(fix43::SYMBOL, "AAPL");
new_msg.set(fix43::SIDE, fix43::Side::Buy);
new_msg.set(fix43::ORDER_QTY, 100);
let (encoded, _) = new_msg.done();
println!("Encoded: {}", String::from_utf8_lossy(encoded));
Add to your Cargo.toml
:
[dependencies]
minifix = "0.1"
Or install with cargo:
cargo add minifix
Enable optional features as needed:
minifix = { version = "0.1", features = [
"fix44", # FIX 4.4 support (includes 4.0-4.3)
"utils-chrono", # chrono integration for date/time fields
"utils-tokio", # async/Tokio support
"json-encoding" # JSON encoding support
]}
use minifix::prelude::*;
use minifix::tagvalue::{Decoder, Encoder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse a FIX message
let message = b"8=FIX.4.2|9=73|35=D|49=SENDER|56=TARGET|34=1|52=20230101-12:00:00|11=ORDER1|55=AAPL|54=1|38=100|40=2|44=150.50|59=0|10=123|";
let mut decoder = Decoder::new(Dictionary::fix42());
decoder.config_mut().separator = b'|';
let msg = decoder.decode(message)?;
// Access fields with type safety
println!("Order ID: {:?}", msg.get::<&[u8]>(fix42::CL_ORD_ID)?);
println!("Symbol: {:?}", msg.get::<&[u8]>(fix42::SYMBOL)?);
println!("Side: {:?}", msg.get::<fix42::Side>(fix42::SIDE)?);
// Encode a new message
let mut encoder = Encoder::new();
let mut buffer = Vec::new();
let mut new_msg = encoder.start_message(b"FIX.4.2", &mut buffer, b"8");
new_msg.set(fix42::ORDER_ID, "EXEC-001");
new_msg.set(fix42::SYMBOL, "AAPL");
new_msg.set(fix42::SIDE, fix42::Side::Buy);
let (encoded, _) = new_msg.done();
println!("Encoded: {}", String::from_utf8_lossy(encoded));
Ok(())
}
Comprehensive documentation is available at docs.rs/minifix, including:
API reference for all public types and functions
Tutorial on FIX message parsing and encoding
Examples of different message patterns and use cases
Best practices for financial application development
Keybase Verification:
https://keybase.io/cryptopatrick/sigs/8epNh5h2FtIX1UNNmf8YQ-k33M8J-Md4LnAN
Leave a ⭐ if you think this project is cool.
This project is licensed under MIT. See LICENSE for details.