pub struct OrderBuilder<'a, C> { /* private fields */ }
Expand description
Builder for creating orders with a fluent interface
All validation is deferred to the build() method to ensure no silent failures occur during order construction.
Implementations§
Source§impl<'a, C> OrderBuilder<'a, C>
impl<'a, C> OrderBuilder<'a, C>
Sourcepub fn stop(self, stop_price: impl Into<f64>) -> Self
pub fn stop(self, stop_price: impl Into<f64>) -> Self
Create a stop order at the specified stop price
Sourcepub fn stop_limit(
self,
stop_price: impl Into<f64>,
limit_price: impl Into<f64>,
) -> Self
pub fn stop_limit( self, stop_price: impl Into<f64>, limit_price: impl Into<f64>, ) -> Self
Create a stop-limit order
Sourcepub fn trailing_stop(
self,
trailing_percent: f64,
stop_price: impl Into<f64>,
) -> Self
pub fn trailing_stop( self, trailing_percent: f64, stop_price: impl Into<f64>, ) -> Self
Create a trailing stop order
Sourcepub fn order_type(self, order_type: OrderType) -> Self
pub fn order_type(self, order_type: OrderType) -> Self
Set a custom order type
Sourcepub fn trailing_stop_limit(
self,
trailing_percent: f64,
stop_price: impl Into<f64>,
limit_offset: f64,
) -> Self
pub fn trailing_stop_limit( self, trailing_percent: f64, stop_price: impl Into<f64>, limit_offset: f64, ) -> Self
Create a trailing stop limit order
Sourcepub fn market_if_touched(self, trigger_price: impl Into<f64>) -> Self
pub fn market_if_touched(self, trigger_price: impl Into<f64>) -> Self
Market if Touched - triggers market order when price is touched
Sourcepub fn limit_if_touched(
self,
trigger_price: impl Into<f64>,
limit_price: impl Into<f64>,
) -> Self
pub fn limit_if_touched( self, trigger_price: impl Into<f64>, limit_price: impl Into<f64>, ) -> Self
Limit if Touched - triggers limit order when price is touched
Sourcepub fn market_to_limit(self) -> Self
pub fn market_to_limit(self) -> Self
Market to Limit - starts as market order, remainder becomes limit
Sourcepub fn discretionary(
self,
limit_price: impl Into<f64>,
discretionary_amt: f64,
) -> Self
pub fn discretionary( self, limit_price: impl Into<f64>, discretionary_amt: f64, ) -> Self
Discretionary order - limit order with hidden discretionary amount
Sourcepub fn sweep_to_fill(self, limit_price: impl Into<f64>) -> Self
pub fn sweep_to_fill(self, limit_price: impl Into<f64>) -> Self
Sweep to Fill - prioritizes speed of execution over price
Sourcepub fn block(self, limit_price: impl Into<f64>) -> Self
pub fn block(self, limit_price: impl Into<f64>) -> Self
Block order - for large volume option orders (min 50 contracts)
Sourcepub fn midprice(self, price_cap: impl Into<f64>) -> Self
pub fn midprice(self, price_cap: impl Into<f64>) -> Self
Midprice order - fills at midpoint between bid/ask or better
Sourcepub fn relative(self, offset: f64, price_cap: Option<f64>) -> Self
pub fn relative(self, offset: f64, price_cap: Option<f64>) -> Self
Relative/Pegged-to-Primary - seeks more aggressive price than NBBO
Sourcepub fn passive_relative(self, offset: f64) -> Self
pub fn passive_relative(self, offset: f64) -> Self
Passive Relative - seeks less aggressive price than NBBO
Sourcepub fn at_auction(self, price: impl Into<f64>) -> Self
pub fn at_auction(self, price: impl Into<f64>) -> Self
At Auction - for pre-market opening period execution
Sourcepub fn time_in_force(self, tif: TimeInForce) -> Self
pub fn time_in_force(self, tif: TimeInForce) -> Self
Set time in force for the order
Sourcepub fn good_till_cancel(self) -> Self
pub fn good_till_cancel(self) -> Self
Good till cancelled order
Sourcepub fn good_till_date(self, date: impl Into<String>) -> Self
pub fn good_till_date(self, date: impl Into<String>) -> Self
Good till specific date
Sourcepub fn fill_or_kill(self) -> Self
pub fn fill_or_kill(self) -> Self
Fill or kill order
Sourcepub fn immediate_or_cancel(self) -> Self
pub fn immediate_or_cancel(self) -> Self
Immediate or cancel order
Sourcepub fn outside_rth(self) -> Self
pub fn outside_rth(self) -> Self
Allow order execution outside regular trading hours
Sourcepub fn regular_hours_only(self) -> Self
pub fn regular_hours_only(self) -> Self
Restrict order to regular trading hours only
Sourcepub fn trading_hours(self, hours: TradingHours) -> Self
pub fn trading_hours(self, hours: TradingHours) -> Self
Set trading hours preference
Hide order from market depth (only works for NASDAQ-routed orders)
Sourcepub fn do_not_transmit(self) -> Self
pub fn do_not_transmit(self) -> Self
Do not transmit order immediately
Sourcepub fn bracket(self) -> BracketOrderBuilder<'a, C>
pub fn bracket(self) -> BracketOrderBuilder<'a, C>
Create bracket orders with take profit and stop loss
Sourcepub fn algo_param(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn algo_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add algorithm parameter
Sourcepub fn volatility(self, volatility: f64) -> Self
pub fn volatility(self, volatility: f64) -> Self
Set volatility for volatility orders
Sourcepub fn all_or_none(self) -> Self
pub fn all_or_none(self) -> Self
Mark order as all or none
Sourcepub fn good_after_time(self, time: impl Into<String>) -> Self
pub fn good_after_time(self, time: impl Into<String>) -> Self
Set good after time
Sourcepub fn good_till_time(self, time: impl Into<String>) -> Self
pub fn good_till_time(self, time: impl Into<String>) -> Self
Set good till time (stored in good_till_date field)
Sourcepub fn min_trade_qty(self, qty: i32) -> Self
pub fn min_trade_qty(self, qty: i32) -> Self
Set minimum trade quantity for pegged orders
Sourcepub fn min_compete_size(self, size: i32) -> Self
pub fn min_compete_size(self, size: i32) -> Self
Set minimum compete size for pegged orders
Sourcepub fn compete_against_best_offset(self, offset: f64) -> Self
pub fn compete_against_best_offset(self, offset: f64) -> Self
Set compete against best offset for pegged orders
Sourcepub fn mid_offset_at_whole(self, offset: f64) -> Self
pub fn mid_offset_at_whole(self, offset: f64) -> Self
Set mid offset at whole for pegged orders
Sourcepub fn mid_offset_at_half(self, offset: f64) -> Self
pub fn mid_offset_at_half(self, offset: f64) -> Self
Set mid offset at half for pegged orders
Sourcepub fn build(self) -> Result<Order, ValidationError>
pub fn build(self) -> Result<Order, ValidationError>
Build the Order struct with full validation
Source§impl<'a> OrderBuilder<'a, Client>
impl<'a> OrderBuilder<'a, Client>
Sourcepub fn submit(self) -> Result<OrderId, Error>
pub fn submit(self) -> Result<OrderId, Error>
Submit the order synchronously Returns the order ID assigned to the submitted order
Sourcepub fn build_order(self) -> Result<Order, Error>
pub fn build_order(self) -> Result<Order, Error>
Build the order and return it without submitting Useful for batch operations or custom submission logic
Sourcepub fn analyze(self) -> Result<OrderState, Error>
pub fn analyze(self) -> Result<OrderState, Error>
Analyze order for margin/commission (what-if)
Source§impl<'a> OrderBuilder<'a, Client>
impl<'a> OrderBuilder<'a, Client>
Sourcepub async fn submit(self) -> Result<OrderId, Error>
pub async fn submit(self) -> Result<OrderId, Error>
Submit the order asynchronously Returns the order ID assigned to the submitted order
Sourcepub fn build_order(self) -> Result<Order, Error>
pub fn build_order(self) -> Result<Order, Error>
Build the order and return it without submitting Useful for batch operations or custom submission logic
Sourcepub async fn analyze(self) -> Result<OrderState, Error>
pub async fn analyze(self) -> Result<OrderState, Error>
Analyze order for margin/commission (what-if)