pub enum PositionValidationErrorKind {
InvalidSize {
size: f64,
reason: String,
},
InvalidPrice {
price: f64,
reason: String,
},
IncompatibleSide {
position_side: Side,
reason: String,
},
IncompatibleStyle {
style: OptionStyle,
reason: String,
},
InvalidPosition {
reason: String,
},
}Expand description
Errors related to position validation
This enum represents errors that can occur during position validation checks. These errors typically happen when attempting to create or modify a position with invalid or incompatible parameters.
§Variants
-
InvalidSize- The position size is invalid (e.g., zero, negative, or too large). -
InvalidPrice- The position price is invalid (e.g., negative or unrealistic). -
IncompatibleSide- The position side (long/short) is incompatible with the strategy. -
IncompatibleStyle- The option style is incompatible with the strategy. -
InvalidPosition- The position is invalid for other specific reasons.
§Usage
Used when validating positions to ensure they meet all requirements before being added to a strategy or executed in a trading system.
Variants§
InvalidSize
Position size is invalid
Occurs when the specified position size violates size constraints.
InvalidPrice
Position price is invalid
Occurs when the specified price violates price constraints or is unrealistic.
IncompatibleSide
Position type is incompatible with strategy
Occurs when the position side (long/short) conflicts with strategy requirements.
Fields
IncompatibleStyle
Option style is incompatible with strategy
Occurs when the option style (American/European) conflicts with strategy requirements.
Fields
style: OptionStyleThe incompatible option style
InvalidPosition
Position is invalid for other reasons
A general error for positions that fail validation for reasons not covered by other variants.
Trait Implementations§
Source§impl Debug for PositionValidationErrorKind
impl Debug for PositionValidationErrorKind
Source§impl Error for PositionValidationErrorKind
impl Error for PositionValidationErrorKind
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()