#[non_exhaustive]pub struct BracketOrderResult {
pub parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>,
pub take_profit: Option<Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>>,
pub stop_loss: Option<Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>>,
}Expand description
Result of bracket order placement.
Contains the parent order and optionally the child legs. The Option types
document API divergence between exchanges:
| Exchange | take_profit | stop_loss | Reason |
|---|---|---|---|
| IBKR | Some(...) | Some(...) | Returns all three orders immediately |
| Alpaca | None | None | Child legs created server-side; use fetch_open_orders |
§Invariants
- Either all orders are
Active(Open)or all areInactive(placement failed). Partial success is prevented by all-or-nothing error handling in implementations. - Child legs are either both
Some(exchange returns legs immediately, e.g. IBKR) or bothNone(exchange creates legs server-side, e.g. Alpaca). Asymmetric leg presence is not supported — no current exchange returns one leg but not the other, sowith_all_legsandparent_onlyare the only public constructors.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>Parent (entry) order.
take_profit: Option<Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>>Take-profit order (opposite side, limit).
None when the exchange creates legs server-side (Alpaca).
Some when the exchange returns legs immediately (IBKR).
stop_loss: Option<Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>>Stop-loss order (opposite side, stop or stop-limit).
None when the exchange creates legs server-side (Alpaca).
Some when the exchange returns legs immediately (IBKR).
Implementations§
Source§impl BracketOrderResult
impl BracketOrderResult
Sourcepub fn with_all_legs(
parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>,
take_profit: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>,
stop_loss: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>,
) -> Self
pub fn with_all_legs( parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>, take_profit: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>, stop_loss: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>, ) -> Self
Create a result with all three legs present.
Use for exchanges that return all orders immediately (e.g., IBKR).
Sourcepub fn parent_only(
parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>,
) -> Self
pub fn parent_only( parent: Order<ExchangeId, InstrumentNameExchange, UnindexedOrderState>, ) -> Self
Create a result with only the parent order.
Use for exchanges that create child legs server-side (e.g., Alpaca).
Sourcepub fn has_all_legs(&self) -> bool
pub fn has_all_legs(&self) -> bool
Returns true if all child legs are present.
Trait Implementations§
Source§impl Clone for BracketOrderResult
impl Clone for BracketOrderResult
Source§fn clone(&self) -> BracketOrderResult
fn clone(&self) -> BracketOrderResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BracketOrderResult
impl RefUnwindSafe for BracketOrderResult
impl Send for BracketOrderResult
impl Sync for BracketOrderResult
impl Unpin for BracketOrderResult
impl UnsafeUnpin for BracketOrderResult
impl UnwindSafe for BracketOrderResult
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,
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 more