Files
foxhunt/common
jgrusewski fd1b60bbf5 refactor: unify ModelType into common/model_types.rs
Consolidate 4 separate ModelType enum definitions (ml 15 variants,
model_loader 7, campaign 2, job_spawner 4) into a single canonical
definition in common/src/model_types.rs with the union of all variants
and all methods (file_extension, as_str, to_db_string, weight, from_str,
Display).

- ml/src/lib.rs: replace 15-variant enum with re-export
- model_loader/src/lib.rs: replace 7-variant enum with re-export,
  update PascalCase names (Dqn->DQN, Tft->TFT, etc)
- ml/hyperopt/campaign.rs: replace 2-variant enum with re-export
- services/ml_training_service/job_spawner.rs: replace 4-variant enum
  with re-export, MAMBA2->MAMBA
- Remove orphan impl ToString in ml/observability/metrics.rs (Display
  now provided by canonical type)
- Update backtesting_service and model_loader tests for new names

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 23:39:26 +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.