refactor: remove trading_engine dep from ml and risk crates

Re-export HardwareTimestamp through data crate instead of ml/risk
depending directly on trading_engine. Reduces coupling between
the ML pipeline and the trading engine.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-05 23:19:38 +01:00
parent 7b60fd5f86
commit cc4e0c5a2d
8 changed files with 8 additions and 14 deletions

2
Cargo.lock generated
View File

@@ -6300,7 +6300,6 @@ dependencies = [
"toml",
"tracing",
"tracing-subscriber",
"trading_engine",
"urlencoding",
"uuid",
]
@@ -8603,7 +8602,6 @@ dependencies = [
"tokio-test",
"tracing",
"tracing-subscriber",
"trading_engine",
"uuid",
]

View File

@@ -224,6 +224,8 @@ pub mod validation; // Data validation and quality control
use tracing::{error, info, warn};
// === External Re-exports ===
// Re-export HardwareTimestamp so downstream crates (ml) don't need a direct trading_engine dep
pub use trading_engine::timing::HardwareTimestamp;
// Commonly used external types
use tokio::sync::broadcast;
// Import configuration and event types that are actually used

View File

@@ -68,7 +68,6 @@ reqwest.workspace = true
colored = "2.1" # Terminal color output for evaluation reports
# Internal workspace crates
trading_engine.workspace = true
config.workspace = true
common.workspace = true
risk = { path = "../risk" }

View File

@@ -658,7 +658,7 @@ impl DbnSequenceLoader {
let volume = Decimal::from(ohlcv.volume);
// Create HardwareTimestamp from ts_event (nanoseconds since Unix epoch)
use trading_engine::timing::HardwareTimestamp;
use data::HardwareTimestamp;
let timestamp = HardwareTimestamp::from_nanos(ohlcv.hd.ts_event);
messages.push(ProcessedMessage::Ohlcv {
@@ -680,7 +680,7 @@ impl DbnSequenceLoader {
let price = common::Price::from_f64(price_f64.abs())?;
let size = Decimal::from(trade.size);
use trading_engine::timing::HardwareTimestamp;
use data::HardwareTimestamp;
let timestamp = HardwareTimestamp::from_nanos(trade.hd.ts_event);
// Determine side from trade action/flags (c_char is i8)
@@ -713,7 +713,7 @@ impl DbnSequenceLoader {
let price = common::Price::from_f64(price_f64.abs())?;
let size = Decimal::from(mbp.size);
use trading_engine::timing::HardwareTimestamp;
use data::HardwareTimestamp;
let timestamp = HardwareTimestamp::from_nanos(mbp.hd.ts_event);
// Determine bid/ask from side field (c_char is i8)
@@ -818,7 +818,7 @@ impl DbnSequenceLoader {
close: common::Price::from_f64(bar.close)
.unwrap_or_default(),
volume: Decimal::from_f64(bar.volume).unwrap_or(Decimal::ZERO),
timestamp: trading_engine::timing::HardwareTimestamp::from_nanos(
timestamp: data::HardwareTimestamp::from_nanos(
bar.timestamp.timestamp_nanos_opt().unwrap_or(0) as u64,
),
})

View File

@@ -255,7 +255,7 @@ impl DBNTickAdapter {
let volume = Decimal::from(ohlcv.volume);
// Create HardwareTimestamp from ts_event (nanoseconds since Unix epoch)
use trading_engine::timing::HardwareTimestamp;
use data::HardwareTimestamp;
let timestamp = HardwareTimestamp::from_nanos(ohlcv.hd.ts_event);
messages.push(ProcessedMessage::Ohlcv {

View File

@@ -420,7 +420,7 @@ impl StreamingDbnLoader {
let close = common::Price::from_f64(close_f64.abs())?;
let volume = Decimal::from(ohlcv.volume);
use trading_engine::timing::HardwareTimestamp;
use data::HardwareTimestamp;
let timestamp = HardwareTimestamp::from_nanos(ohlcv.hd.ts_event);
messages.push(ProcessedMessage::Ohlcv {

View File

@@ -162,7 +162,6 @@ use num as _;
use num_traits as _;
use semver as _;
use tempfile as _;
use trading_engine as _;
// Direct type imports - no compatibility aliases
use rust_decimal::Decimal;
@@ -368,9 +367,6 @@ pub enum HealthStatus {
Unhealthy,
}
// Import specific types from trading_engine that we need
// (removed wildcard prelude to avoid conflicts)
// Using Decimal for financial types
/// Market data snapshot for ML model input

View File

@@ -14,7 +14,6 @@ categories.workspace = true
[dependencies]
# Core workspace dependencies
trading_engine = { workspace = true }
config = { workspace = true }
common = { path = "../common" }