pub struct StrategyRequest {
pub strategy_type: StrategyType,
pub positions: Vec<Position>,
}Expand description
A request structure for creating and analyzing options trading strategies.
This structure encapsulates all necessary information to construct and evaluate a specific options trading strategy. It contains the strategy type (such as Bull Call Spread, Iron Condor, etc.) and the collection of financial positions that make up the strategy.
StrategyRequest is typically used as an input to strategy analysis services
or functions that construct, validate, and evaluate option strategies based
on their positions.
Fields§
§strategy_type: StrategyTypeThe type of options trading strategy to construct or analyze. This determines the expected structure and validation rules for the provided positions.
positions: Vec<Position>A collection of financial positions that make up the strategy. These positions typically include various options contracts (calls and puts) with different strike prices and expiration dates, arranged according to the selected strategy type.
Implementations§
Source§impl StrategyRequest
Request handler for options trading strategies.
impl StrategyRequest
Request handler for options trading strategies.
This implementation provides functionality to create new strategy requests and instantiate concrete strategy objects based on the specified strategy type and positions.
Sourcepub fn new(strategy_type: StrategyType, positions: Vec<Position>) -> Self
pub fn new(strategy_type: StrategyType, positions: Vec<Position>) -> Self
Creates a new strategy request with the specified strategy type and positions.
§Parameters
strategy_type- The type of options trading strategy to construct.positions- A collection of financial positions that make up the strategy.
§Returns
A new StrategyRequest instance containing the provided strategy type and positions.
Sourcepub fn get_strategy(&self) -> Result<Box<dyn Strategable>, StrategyError>
pub fn get_strategy(&self) -> Result<Box<dyn Strategable>, StrategyError>
Creates and returns a concrete strategy instance based on the strategy type and positions specified in this request.
This method acts as a factory that constructs the appropriate strategy object
by delegating to the corresponding strategy implementation’s get_strategy method.
§Returns
Ok(Box<dyn Strategable>)- A boxed trait object implementing theStrategabletrait if the strategy creation was successful.Err(StrategyError)- An error indicating why the strategy could not be created. ReturnsStrategyError::NotImplementedfor strategies that are not yet implemented.
§Errors
This method can return errors from the underlying strategy constructors or
StrategyError::NotImplemented for strategies that are defined but not yet implemented.
Trait Implementations§
Source§impl Clone for StrategyRequest
impl Clone for StrategyRequest
Source§fn clone(&self) -> StrategyRequest
fn clone(&self) -> StrategyRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for StrategyRequest
impl ComposeSchema for StrategyRequest
Source§impl<'de> Deserialize<'de> for StrategyRequest
impl<'de> Deserialize<'de> for StrategyRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for StrategyRequest
impl PartialEq for StrategyRequest
Source§impl Serialize for StrategyRequest
impl Serialize for StrategyRequest
impl StructuralPartialEq for StrategyRequest
Auto Trait Implementations§
impl Freeze for StrategyRequest
impl RefUnwindSafe for StrategyRequest
impl Send for StrategyRequest
impl Sync for StrategyRequest
impl Unpin for StrategyRequest
impl UnsafeUnpin for StrategyRequest
impl UnwindSafe for StrategyRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.