🚨 ARCHITECTURAL DISASTER: THREE Competing Type Sources Discovered

## Critical Investigation Results

**DISASTER CONFIRMED**: Agents discovered THREE type sources instead of ONE:
1. foxhunt-common-types/ (SHOULD NOT EXIST - still active!)
2. trading_engine/src/types/ (massive duplication)
3. common/src/types.rs (depends on competing crate)

## Evidence of Violations
- foxhunt-common-types still in workspace members (line 86)
- common/Cargo.toml depends on foxhunt-common-types (line 48)
- 48+ duplicate type definitions across OrderSide, OrderStatus, OrderType
- Compilation failures due to competing imports

## Immediate Action Required
- Choose ONE canonical source
- DELETE foxhunt-common-types completely
- Consolidate ALL types to single source
- Fix THREE-WAY import chaos

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2025-09-26 15:33:34 +02:00
parent f58d14ccc3
commit ea9d8f2c88
87 changed files with 2192 additions and 817 deletions

View File

@@ -220,9 +220,8 @@ pub use crate::utils::{
// === External Re-exports ===
// Commonly used external types
use tokio::sync::broadcast;
pub use trading_engine::prelude::Side;
pub use trading_engine::types::events::OrderEvent;
pub use trading_engine::types::OrderType;
// Import canonical types from trading_engine prelude per TYPE_GOVERNANCE.md
use common::prelude::*;
// Import shared configuration from foxhunt-config-crate
use config::{DataModuleConfig, DataModuleSettings};

View File

@@ -17,22 +17,8 @@ use tokio::sync::{mpsc, RwLock};
use tokio::time::{Duration, Instant};
use tracing::{debug, error, info, warn};
/// Market data event optimized for Parquet storage
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MarketDataEvent {
pub timestamp_ns: u64,
pub symbol: String,
pub venue: String,
pub event_type: String, // "trade", "quote", "orderbook", "status"
pub price: Option<f64>,
pub quantity: Option<f64>,
pub bid_price: Option<f64>,
pub ask_price: Option<f64>,
pub bid_size: Option<f64>,
pub ask_size: Option<f64>,
pub sequence: u64,
pub latency_ns: Option<u64>,
}
// Import the renamed Parquet-specific market data event
use trading_engine::types::metrics::ParquetMarketDataEvent as MarketDataEvent;
/// Parquet writer configuration
#[derive(Debug, Clone)]

View File

@@ -777,8 +777,8 @@ impl BenzingaMLExtractor {
// Market session (simplified for US markets)
let hour_int = hour as u8;
let market_session = match hour_int {
4..=9 => 1.0, // Pre-market
9..=16 => 2.0, // Regular session
4..=8 => 1.0, // Pre-market
9..=15 => 2.0, // Regular session
16..=20 => 3.0, // After-hours
_ => 0.0, // Closed
};

View File

@@ -28,7 +28,7 @@
//! ```rust,no_run
//! use data::providers::benzinga::{ProductionBenzingaProvider, ProductionBenzingaConfig};
//! use data::providers::traits::RealTimeProvider;
//! use core::types::Symbol;
//! use trading_engine::types::Symbol;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = ProductionBenzingaConfig {
@@ -107,7 +107,7 @@
//! use data::providers::benzinga::{BenzingaMLExtractor, BenzingaMLConfig};
//! use data::providers::common::MarketDataEvent;
//! use chrono::Utc;
//! use core::types::Symbol;
//! use trading_engine::types::Symbol;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = BenzingaMLConfig {
@@ -144,7 +144,7 @@
//! ```rust,no_run
//! use data::providers::benzinga::{BenzingaHFTIntegration, BenzingaIntegrationConfig, TradingSignal, TradingSignalType};
//! use config::ConfigManager;
//! use core::types::Symbol;
//! use trading_engine::types::Symbol;
//! use std::sync::Arc;
//!
//! # async fn example() -> anyhow::Result<()> {
@@ -425,7 +425,7 @@ mod tests {
#[tokio::test]
async fn test_hft_integration_creation() {
use core::types::Symbol;
use trading_engine::types::Symbol;
let config = BenzingaStreamingConfig {
api_key: "test-key".to_string(),

View File

@@ -11,10 +11,11 @@
use crate::error::{DataError, Result};
use crate::providers::common::{
AnalystRatingEvent, ConnectionState, ConnectionStatusEvent, ErrorCategory, ErrorEvent,
AnalystRatingEvent, ConnectionState, ConnectionStatusEvent, ErrorCategory,
MarketDataEvent, NewsEvent, OptionsContract, OptionsSentiment, OptionsType, RatingAction,
SentimentEvent, SentimentPeriod, UnusualOptionsEvent, UnusualOptionsType,
};
use trading_engine::types::ErrorEvent;
use crate::providers::traits::{
ConnectionState as TraitConnectionState, ConnectionStatus, RealTimeProvider,
};
@@ -1068,7 +1069,7 @@ impl RealTimeProvider for ProductionBenzingaProvider {
*status = ConnectionStatus::disconnected();
}
self.connected.store(false, Ordering::Relaxed);
self.connection_status.write().await.is_connected = false;
info!("Disconnected from Benzinga WebSocket stream");
Ok(())
}
@@ -1099,13 +1100,9 @@ impl RealTimeProvider for ProductionBenzingaProvider {
websocket.send(Message::Text(message)).await
.map_err(|e| DataError::Subscription {
message: format!("Failed to send subscription: {}", e),
symbols: Some(symbols.iter().map(|s| s.to_string()).collect()),
})?;
} else {
return Err(DataError::Connection {
message: "Not connected to WebSocket".to_string(),
url: None,
});
return Err(DataError::Connection("Not connected to WebSocket".to_string()));
}
// Update subscribed symbols
@@ -1138,7 +1135,6 @@ impl RealTimeProvider for ProductionBenzingaProvider {
websocket.send(Message::Text(message)).await
.map_err(|e| DataError::Subscription {
message: format!("Failed to send unsubscription: {}", e),
symbols: Some(symbols.iter().map(|s| s.to_string()).collect()),
})?;
}

View File

@@ -18,7 +18,7 @@
//! ```rust,no_run
//! use data::providers::benzinga::streaming::BenzingaStreamingProvider;
//! use data::providers::traits::RealTimeProvider;
//! use core::types::Symbol;
//! use trading_engine::types::Symbol;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = BenzingaStreamingConfig {
@@ -48,7 +48,8 @@ use crate::providers::common::{
use crate::providers::traits::{
ConnectionState as TraitConnectionState, ConnectionStatus, RealTimeProvider,
};
use crate::providers::common::{MarketDataEvent, ErrorEvent};
use crate::providers::common::MarketDataEvent;
use trading_engine::types::ErrorEvent;
use crate::types::ConnectionEvent;
use async_trait::async_trait;
use chrono::{DateTime, Utc};

View File

@@ -134,7 +134,7 @@ pub struct BarEvent {
pub close: Decimal,
/// Volume
pub volume: Decimal,
pub volume: Volume,
/// Timestamp
pub timestamp: DateTime<Utc>,
@@ -162,7 +162,7 @@ pub struct AggregateEvent {
pub close: Decimal,
/// Volume
pub volume: Decimal,
pub volume: Volume,
/// Volume weighted average price
pub vwap: Option<Decimal>,

View File

@@ -35,7 +35,7 @@ use std::error::Error as StdError;
///
/// ```no_run
/// # use async_trait::async_trait;
/// # use core::types::Symbol;
/// # use trading_engine::types::Symbol;
/// # use tokio_stream::Stream;
/// # struct MyProvider;
/// # impl MyProvider {
@@ -149,7 +149,7 @@ pub trait RealTimeProvider: Send + Sync {
///
/// ```no_run
/// # use chrono::{DateTime, Utc};
/// # use core::types::Symbol;
/// # use trading_engine::types::Symbol;
/// # struct MyHistoricalProvider;
/// # impl MyHistoricalProvider {
/// # async fn fetch(&self, symbol: &Symbol, schema: HistoricalSchema, range: TimeRange) -> Result<Vec<String>, Box<dyn std::error::Error>> { Ok(vec![]) }

View File

@@ -76,24 +76,8 @@ pub struct QuoteEvent {
pub timestamp: chrono::DateTime<chrono::Utc>,
}
/// Trade event structure
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TradeEvent {
/// Symbol
pub symbol: String,
/// Trade price
pub price: Decimal,
/// Trade size
pub size: Decimal,
/// Trade ID
pub trade_id: Option<String>,
/// Exchange
pub exchange: Option<String>,
/// Trade conditions
pub conditions: Vec<String>,
/// Timestamp
pub timestamp: chrono::DateTime<chrono::Utc>,
}
// TradeEvent removed - use canonical version from trading_engine::types::TradeEvent
pub use trading_engine::types::TradeEvent;
/// Quote data structure (legacy compatibility)
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -145,7 +129,7 @@ pub struct Aggregate {
/// Close price
pub close: Decimal,
/// Volume
pub volume: Decimal,
pub volume: Volume,
/// Volume weighted average price
pub vwap: Option<Decimal>,
/// Start timestamp
@@ -410,9 +394,8 @@ mod tests {
assert_eq!(quote.symbol(), "AAPL");
}
#[test]
fn test_order_status_display() {
// OrderStatus tests removed - use canonical types from core::types::prelude
#[test]
fn test_order_status_display() {
// OrderStatus tests removed - use canonical types from core::types::prelude
}
}
}
}

View File

@@ -794,7 +794,7 @@ impl UnifiedFeatureExtractor {
.iter()
.filter_map(|bar| {
if let MarketDataEvent::Bar(bar_event) = bar {
Some(bar_event.volume.to_f64().unwrap_or(0.0))
Some(bar_event.volume.value().to_f64().unwrap_or(0.0))
} else {
None
}