pub struct BracketOrderRequestBuilder<ExchangeKey = ExchangeId, InstrumentKey = InstrumentNameExchange> { /* private fields */ }Expand description
Builder for creating BracketOrderRequest with a fluent API.
§Example
ⓘ
use rustrade_execution::order::bracket::BracketOrderRequestBuilder;
use rustrade_execution::order::id::{ClientOrderId, StrategyId};
use rustrade_instrument::{Side, exchange::ExchangeId, instrument::name::InstrumentNameExchange};
use rust_decimal_macros::dec;
let instrument = InstrumentNameExchange::from("AAPL");
let request = BracketOrderRequestBuilder::new(
ExchangeId::AlpacaBroker,
&instrument,
StrategyId::new("momentum"),
ClientOrderId::new("bracket-001"),
)
.side(Side::Buy)
.quantity(dec!(10))
.entry_price(dec!(150.00))
.take_profit_price(dec!(160.00))
.stop_loss_price(dec!(145.00))
.build();Implementations§
Source§impl<ExchangeKey, InstrumentKey> BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey, InstrumentKey> BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
Sourcepub fn new(
exchange: ExchangeKey,
instrument: InstrumentKey,
strategy: StrategyId,
cid: ClientOrderId,
) -> Self
pub fn new( exchange: ExchangeKey, instrument: InstrumentKey, strategy: StrategyId, cid: ClientOrderId, ) -> Self
Create a new builder with the given order key components.
Sourcepub fn entry_price(self, price: Decimal) -> Self
pub fn entry_price(self, price: Decimal) -> Self
Set the entry limit price.
Sourcepub fn take_profit_price(self, price: Decimal) -> Self
pub fn take_profit_price(self, price: Decimal) -> Self
Set the take-profit limit price.
Sourcepub fn stop_loss_price(self, price: Decimal) -> Self
pub fn stop_loss_price(self, price: Decimal) -> Self
Set the stop-loss trigger price.
Sourcepub fn stop_loss_limit_price(self, price: Decimal) -> Self
pub fn stop_loss_limit_price(self, price: Decimal) -> Self
Set the stop-loss limit price (creates stop-limit SL on supporting exchanges).
Sourcepub fn time_in_force(self, tif: TimeInForce) -> Self
pub fn time_in_force(self, tif: TimeInForce) -> Self
Set the time-in-force for all legs.
Sourcepub fn build(self) -> BracketOrderRequest<ExchangeKey, InstrumentKey>
pub fn build(self) -> BracketOrderRequest<ExchangeKey, InstrumentKey>
Build the bracket order request.
§Panics
Panics if any required field is missing: side, quantity, entry_price,
take_profit_price, or stop_loss_price.
Sourcepub fn try_build(
self,
) -> Option<BracketOrderRequest<ExchangeKey, InstrumentKey>>
pub fn try_build( self, ) -> Option<BracketOrderRequest<ExchangeKey, InstrumentKey>>
Try to build the bracket order request, returning None if any required field is missing.
Trait Implementations§
Source§impl<ExchangeKey: Clone, InstrumentKey: Clone> Clone for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey: Clone, InstrumentKey: Clone> Clone for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
Source§fn clone(&self) -> BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
fn clone(&self) -> BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<ExchangeKey, InstrumentKey> Freeze for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey, InstrumentKey> RefUnwindSafe for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>where
ExchangeKey: RefUnwindSafe,
InstrumentKey: RefUnwindSafe,
impl<ExchangeKey, InstrumentKey> Send for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey, InstrumentKey> Sync for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey, InstrumentKey> Unpin for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>
impl<ExchangeKey, InstrumentKey> UnsafeUnpin for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>where
ExchangeKey: UnsafeUnpin,
InstrumentKey: UnsafeUnpin,
impl<ExchangeKey, InstrumentKey> UnwindSafe for BracketOrderRequestBuilder<ExchangeKey, InstrumentKey>where
ExchangeKey: UnwindSafe,
InstrumentKey: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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