🔧 PROGRESS: Import path fixes and type cleanup

- Fixed missing imports in backtesting and risk-data crates
- Corrected ConnectionStatus usage patterns
- Fixed ConfigManager constructor calls
- Resolved Interactive Brokers config conversions
- Added proper Decimal import patterns

NEXT: Aggressive duplicate type system elimination with parallel agents

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2025-09-26 16:16:16 +02:00
parent ea9d8f2c88
commit d92a9664eb
23 changed files with 202 additions and 642 deletions

View File

@@ -23,7 +23,7 @@ use tracing::{debug, error};
use crate::simd::SimdMarketDataOps;
use crate::types::prelude::*;
use crate::trading::data_interface::QuoteEvent;
use crate::types::QuoteEvent;
/// Feature extraction errors
#[derive(Error, Debug)]

View File

@@ -11,24 +11,8 @@ use std::fmt::Debug;
use tokio::sync::broadcast;
use serde::{Deserialize, Serialize};
/// Quote event structure - local definition to avoid cyclic dependencies
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuoteEvent {
/// Symbol
pub symbol: String,
/// Bid price
pub bid: Option<Decimal>,
/// Ask price
pub ask: Option<Decimal>,
/// Bid size
pub bid_size: Option<Decimal>,
/// Ask size
pub ask_size: Option<Decimal>,
/// Exchange
pub exchange: Option<String>,
/// Timestamp
pub timestamp: chrono::DateTime<chrono::Utc>,
}
// Use canonical QuoteEvent from crate::types::basic
use crate::types::basic::QuoteEvent;
// TradeEvent functionality removed - no longer available without data crate dependency

View File

@@ -292,26 +292,7 @@ pub use crate::types::prelude::OrderStatus;
// TimeInForce ELIMINATED - Use canonical from types::prelude
pub use crate::types::prelude::TimeInForce;
impl fmt::Display for OrderStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
OrderStatus::Created => write!(f, "CREATED"),
OrderStatus::Submitted => write!(f, "SUBMITTED"),
OrderStatus::PartiallyFilled => write!(f, "PARTIALLY_FILLED"),
OrderStatus::Filled => write!(f, "FILLED"),
OrderStatus::Rejected => write!(f, "REJECTED"),
OrderStatus::Cancelled => write!(f, "CANCELLED"),
OrderStatus::New => write!(f, "NEW"),
OrderStatus::Expired => write!(f, "EXPIRED"),
OrderStatus::Pending => write!(f, "PENDING"),
OrderStatus::Working => write!(f, "WORKING"),
OrderStatus::Unknown => write!(f, "UNKNOWN"),
OrderStatus::Suspended => write!(f, "SUSPENDED"),
OrderStatus::PendingCancel => write!(f, "PENDING_CANCEL"),
OrderStatus::PendingReplace => write!(f, "PENDING_REPLACE"),
}
}
}
// Display implementation removed - use canonical from types::basic::OrderStatus
// Default implementation ELIMINATED - Use canonical from types::basic

View File

@@ -1435,7 +1435,9 @@ impl Default for Symbol {
}
}
/// Order type specifying execution behavior - CANONICAL DEFINITION
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum OrderType {
Market,
Limit,
@@ -1446,12 +1448,6 @@ pub enum OrderType {
Hidden,
}
impl Default for OrderType {
fn default() -> Self {
Self::Market
}
}
impl fmt::Display for OrderType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@@ -1466,31 +1462,15 @@ impl fmt::Display for OrderType {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Side {
Buy,
Sell,
}
impl fmt::Display for Side {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Buy => write!(f, "BUY"),
Self::Sell => write!(f, "SELL"),
}
}
}
// CANONICAL OrderStatus - NO DUPLICATES
// OrderStatus import FIXED - OrderStatus is defined in this file (line 662)
impl Default for Side {
impl Default for OrderType {
fn default() -> Self {
Self::Buy
Self::Market
}
}
/// Order status throughout its lifecycle - CANONICAL DEFINITION
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum OrderStatus {
Created,
Submitted,
@@ -1508,12 +1488,58 @@ pub enum OrderStatus {
PendingReplace,
}
impl fmt::Display for OrderStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Created => write!(f, "CREATED"),
Self::Submitted => write!(f, "SUBMITTED"),
Self::PartiallyFilled => write!(f, "PARTIALLY_FILLED"),
Self::Filled => write!(f, "FILLED"),
Self::Rejected => write!(f, "REJECTED"),
Self::Cancelled => write!(f, "CANCELLED"),
Self::New => write!(f, "NEW"),
Self::Expired => write!(f, "EXPIRED"),
Self::Pending => write!(f, "PENDING"),
Self::Working => write!(f, "WORKING"),
Self::Unknown => write!(f, "UNKNOWN"),
Self::Suspended => write!(f, "SUSPENDED"),
Self::PendingCancel => write!(f, "PENDING_CANCEL"),
Self::PendingReplace => write!(f, "PENDING_REPLACE"),
}
}
}
impl Default for OrderStatus {
fn default() -> Self {
Self::Created
}
}
/// Order side - whether the order is a buy or sell - CANONICAL DEFINITION
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum OrderSide {
Buy,
Sell,
}
impl fmt::Display for OrderSide {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Buy => write!(f, "BUY"),
Self::Sell => write!(f, "SELL"),
}
}
}
impl Default for OrderSide {
fn default() -> Self {
Self::Buy
}
}
/// Alias for backward compatibility
pub use OrderSide as Side;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TimeInForce {
Day,
@@ -3546,7 +3572,58 @@ impl ExecutionReport {
}
}
// QuoteEvent implementation moved to trading::data_interface
/// Quote event structure - CANONICAL DEFINITION
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct QuoteEvent {
/// Symbol
pub symbol: String,
/// Bid price
pub bid: Option<Decimal>,
/// Ask price
pub ask: Option<Decimal>,
/// Bid size
pub bid_size: Option<Decimal>,
/// Ask size
pub ask_size: Option<Decimal>,
/// Exchange
pub exchange: Option<String>,
/// Timestamp
pub timestamp: DateTime<Utc>,
}
impl QuoteEvent {
/// Create a new quote event
#[must_use]
pub fn new(symbol: String, timestamp: DateTime<Utc>) -> Self {
Self {
symbol,
bid: None,
ask: None,
bid_size: None,
ask_size: None,
exchange: None,
timestamp,
}
}
/// Get the spread (ask - bid)
#[must_use]
pub fn spread(&self) -> Option<Decimal> {
match (self.bid, self.ask) {
(Some(bid), Some(ask)) => Some(ask - bid),
_ => None,
}
}
/// Get the mid price
#[must_use]
pub fn mid_price(&self) -> Option<Decimal> {
match (self.bid, self.ask) {
(Some(bid), Some(ask)) => Some((bid + ask) / Decimal::from(2)),
_ => None,
}
}
}
// TradeEvent removed - no longer available without data crate dependency

View File

@@ -243,7 +243,7 @@ pub use basic::MarketRegime::{self, Bear, Bull, Crisis, Custom, Normal, Sideways
// Re-export new data compatibility types explicitly
pub use basic::{ConnectionEvent, ConnectionStatus, ErrorEvent, TradeEvent};
// QuoteEvent removed - use data::types::QuoteEvent instead
// QuoteEvent now available from basic::QuoteEvent (canonical definition)
// Re-export event types
pub use events::SystemStatus;

View File

@@ -309,7 +309,8 @@ pub use crate::types::basic::{
// Infrastructure monitoring and management
MonitoringConfig,
NodeId,
Side as OrderSide,
OrderSide,
Side,
OrderType,
// Performance and scaling
PerformanceProfile,
@@ -323,7 +324,6 @@ pub use crate::types::basic::{
ScalingConfig,
ServiceId,
ServiceLevelObjectives,
Side,
// Slippage models for backtesting
SlippageModel,
Symbol,