Files
foxhunt/crates/common
jgrusewski 265bd2441c fix(ml,ci): zero-dim guards on all 10 models, eliminate warnings, unblock CI parallelism
- Add dimension validation in DQN, PPO, Mamba2, TGGN, TLOB, Liquid,
  KAN, xLSTM, Diffusion constructors (fail-fast on zero-dim inputs
  that would cause CUDA_ERROR_INVALID_VALUE at runtime)
- Add num_unknown_features > 0 guard to TFT (temporal input required)
- Fix 12 dead-code/unused warnings in test compilation
- Remove opt-level=3 and codegen-units=1 from target rustflags
  (was forcing O3 + single-thread codegen on dev/test builds)
- Remove hardcoded jobs=16 cap (cargo now auto-detects CPU count)
- Switch linker to clang+lld (2-5x faster linking)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:38:43 +01:00
..

Common Crate

Overview

The common crate provides a foundational set of shared types and utilities essential for building high-frequency trading applications within the Foxhunt ecosystem. It encapsulates core data structures, error handling patterns, and common helpers used across various components.

Features

  • Market Data & Order Types: Defines standardized structs for market data (e.g., Tick, OrderBook) and various order types (e.g., LimitOrder, MarketOrder).
  • High-Precision Time Utilities: Offers utilities for working with nanosecond-resolution timestamps and duration calculations critical for HFT.
  • Robust Error Handling: Implements a custom FoxhuntError enum and Result type for consistent and traceable error management across the system.
  • Data Validation Helpers: Provides functions for validating common HFT parameters such as prices, quantities, and instrument IDs.
  • Serialization/Deserialization: Includes helpers and derive macros for efficient data serialization (e.g., using serde) for inter-process communication or persistence.
  • Instrument & Asset Definitions: Standardized types for defining trading instruments, assets, and exchanges.

Usage

use common::types::{Order, OrderSide, Price, Quantity, InstrumentId};
use common::errors::FoxhuntError;

fn create_limit_order(instrument: InstrumentId, price: Price, quantity: Quantity) -> Result<Order, FoxhuntError> {
    if price.value() <= 0.0 || quantity.value() <= 0.0 {
        return Err(FoxhuntError::ValidationError("Price and quantity must be positive".to_string()));
    }
    Ok(Order::new_limit(instrument, OrderSide::Buy, price, quantity))
}

let instrument = InstrumentId::new("BTCUSD".to_string());
let order = create_limit_order(instrument, Price::new(60000.0), Quantity::new(0.5));
println!("{:?}", order);

Testing

cargo test --package common

Documentation

Comprehensive API documentation is available at docs.rs/common.