TradingError

Enum TradingError 

Source
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

Fields

§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Strategy

Error occurred in strategy execution

Fields

§strategy_id: String
§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Execution

Error occurred during order execution

Fields

§message: String
§order_id: Option<String>
§source: Option<Box<dyn Error + Send + Sync>>
§

RiskLimit

Risk limit has been exceeded

Fields

§message: String
§violation_type: RiskViolationType
§

Config

Configuration error

Fields

§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Portfolio

Portfolio management error

Fields

§message: String
§

Network

Network/API error

Fields

§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Validation

Data validation error

Fields

§message: String
§

NotFound

Resource not found

Fields

§resource_type: String
§resource_id: String
§

Timeout

Operation timeout

Fields

§operation: String
§timeout_ms: u64
§

Auth

Authentication/authorization error

Fields

§message: String
§

Database

Database error

Fields

§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Serialization

Serialization/deserialization error

Fields

§message: String
§source: Option<Box<dyn Error + Send + Sync>>
§

Internal

Internal system error

Fields

§message: String
§

InvalidState

Invalid state error

Fields

§message: String
§

NotImplemented

Not implemented yet

Fields

§feature: String
§

Other(Error)

Generic error from anyhow

Implementations§

Source§

impl TradingError

Source

pub fn market_data(message: impl Into<String>) -> Self

Create a market data error

Source

pub fn market_data_with_source( message: impl Into<String>, source: impl Error + Send + Sync + 'static, ) -> Self

Create a market data error with source

Source

pub fn strategy( strategy_id: impl Into<String>, message: impl Into<String>, ) -> Self

Create a strategy error

Source

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

Source

pub fn execution(message: impl Into<String>) -> Self

Create an execution error

Source

pub fn execution_with_order( message: impl Into<String>, order_id: impl Into<String>, ) -> Self

Create an execution error with order ID

Source

pub fn risk_limit( message: impl Into<String>, violation_type: RiskViolationType, ) -> Self

Create a risk limit error

Source

pub fn config(message: impl Into<String>) -> Self

Create a configuration error

Source

pub fn validation(message: impl Into<String>) -> Self

Create a validation error

Source

pub fn not_found( resource_type: impl Into<String>, resource_id: impl Into<String>, ) -> Self

Create a not found error

Source

pub fn timeout(operation: impl Into<String>, timeout_ms: u64) -> Self

Create a timeout error

Source

pub fn internal(message: impl Into<String>) -> Self

Create an internal error

Source

pub fn invalid_state(message: impl Into<String>) -> Self

Create an invalid state error

Source

pub fn not_implemented(feature: impl Into<String>) -> Self

Create a not implemented error

Trait Implementations§

Source§

impl Debug for TradingError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TradingError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for TradingError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for TradingError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.