pub enum TradeError {
InvalidTrade {
reason: String,
},
InvalidTradeStatus {
reason: String,
},
ArithmeticOverflow {
operation: &'static str,
reason: String,
},
}Expand description
Represents errors that can occur during trade-related operations.
This enum encapsulates various error conditions that may arise during trade execution, validation, or parameter processing. It provides detailed context about what went wrong during trading operations.
TradeError is particularly useful for diagnosing problems in trade execution and validation.
Variants§
InvalidTrade
Error indicating that a trade is invalid.
This variant is used when a trade doesn’t meet the requirements for valid trading operations.
InvalidTradeStatus
Error indicating that a trade status is invalid.
This variant is used when a trade status doesn’t meet the requirements for valid trading operations.
ArithmeticOverflow
Error indicating that a monetary figure of a trade (its cost, income or net) left the representable range.
The premium, the contract size, the fee and the quantity are public
Positive fields, so their product can overflow even though each
value is valid on its own.
Implementations§
Source§impl TradeError
Helper methods for creating trading-related errors
impl TradeError
Helper methods for creating trading-related errors
This implementation provides a set of convenience helper methods for creating different types of trading errors. These methods create properly structured error instances with clear, descriptive information about what went wrong.
§Methods
These helper methods simplify error creation throughout the codebase and ensure that errors have consistent formatting and information.
Sourcepub fn invalid_trade(reason: &str) -> Self
pub fn invalid_trade(reason: &str) -> Self
Sourcepub fn invalid_trade_status(reason: &str) -> Self
pub fn invalid_trade_status(reason: &str) -> Self
Trait Implementations§
Source§impl Debug for TradeError
impl Debug for TradeError
Source§impl Display for TradeError
impl Display for TradeError
Source§impl Error for TradeError
impl Error for TradeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()