pub enum TradingError {
Show 17 variants
MarketData {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Strategy {
strategy_id: String,
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Execution {
message: String,
order_id: Option<String>,
source: Option<Box<dyn Error + Send + Sync>>,
},
RiskLimit {
message: String,
violation_type: RiskViolationType,
},
Config {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Portfolio {
message: String,
},
Network {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Validation {
message: String,
},
NotFound {
resource_type: String,
resource_id: String,
},
Timeout {
operation: String,
timeout_ms: u64,
},
Auth {
message: String,
},
Database {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Serialization {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Internal {
message: String,
},
InvalidState {
message: String,
},
NotImplemented {
feature: String,
},
Other(Error),
}Expand description
Main error type for the Neural Trading system
This error type covers all possible error conditions across the entire system. Each variant provides specific context about what went wrong.
Variants§
MarketData
Error occurred during market data operations
Strategy
Error occurred in strategy execution
Execution
Error occurred during order execution
RiskLimit
Risk limit has been exceeded
Config
Configuration error
Portfolio
Portfolio management error
Network
Network/API error
Validation
Data validation error
NotFound
Resource not found
Timeout
Operation timeout
Auth
Authentication/authorization error
Database
Database error
Serialization
Serialization/deserialization error
Internal
Internal system error
InvalidState
Invalid state error
NotImplemented
Not implemented yet
Other(Error)
Generic error from anyhow
Implementations§
Source§impl TradingError
impl TradingError
Sourcepub fn market_data(message: impl Into<String>) -> Self
pub fn market_data(message: impl Into<String>) -> Self
Create a market data error
Sourcepub fn market_data_with_source(
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn market_data_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create a market data error with source
Sourcepub fn strategy(
strategy_id: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn strategy( strategy_id: impl Into<String>, message: impl Into<String>, ) -> Self
Create a strategy error
Sourcepub fn strategy_with_source(
strategy_id: impl Into<String>,
message: impl Into<String>,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn strategy_with_source( strategy_id: impl Into<String>, message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self
Create a strategy error with source
Sourcepub fn execution_with_order(
message: impl Into<String>,
order_id: impl Into<String>,
) -> Self
pub fn execution_with_order( message: impl Into<String>, order_id: impl Into<String>, ) -> Self
Create an execution error with order ID
Sourcepub fn risk_limit(
message: impl Into<String>,
violation_type: RiskViolationType,
) -> Self
pub fn risk_limit( message: impl Into<String>, violation_type: RiskViolationType, ) -> Self
Create a risk limit error
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a validation error
Sourcepub fn not_found(
resource_type: impl Into<String>,
resource_id: impl Into<String>,
) -> Self
pub fn not_found( resource_type: impl Into<String>, resource_id: impl Into<String>, ) -> Self
Create a not found error
Sourcepub fn invalid_state(message: impl Into<String>) -> Self
pub fn invalid_state(message: impl Into<String>) -> Self
Create an invalid state error
Sourcepub fn not_implemented(feature: impl Into<String>) -> Self
pub fn not_implemented(feature: impl Into<String>) -> Self
Create a not implemented error