#[non_exhaustive]pub struct RithmicBracketOrder {Show 35 fields
pub action: OrderSide,
pub duration: TimeInForce,
pub exchange: String,
pub localid: String,
pub price_type: OrderType,
pub price: Option<f64>,
pub trigger_price: Option<f64>,
pub quantity: i32,
pub symbol: String,
pub bracket_type: Option<BracketType>,
pub target_quantity: Vec<i32>,
pub target_ticks: Vec<i32>,
pub stop_quantity: Vec<i32>,
pub stop_ticks: Vec<i32>,
pub if_touched: Option<RithmicIfTouchedTrigger>,
pub break_even_ticks: Option<i32>,
pub break_even_trigger_ticks: Option<i32>,
pub trailing_stop_trigger_ticks: Option<i32>,
pub trailing_stop_by_last_trade_price: Option<bool>,
pub target_market_order_if_touched: Option<bool>,
pub stop_market_on_reject: Option<bool>,
pub target_market_at_ssboe: Option<i32>,
pub target_market_at_usecs: Option<i32>,
pub stop_market_at_ssboe: Option<i32>,
pub stop_market_at_usecs: Option<i32>,
pub target_market_order_after_secs: Option<i32>,
pub release_at_ssboe: Option<i32>,
pub release_at_usecs: Option<i32>,
pub cancel_at_ssboe: Option<i32>,
pub cancel_at_usecs: Option<i32>,
pub cancel_after_secs: Option<i32>,
pub trade_route: Option<String>,
pub manual_or_auto: ManualOrAutoEntry,
pub window_name: Option<String>,
pub operation_type: Option<BracketOperationType>,
}Expand description
Entry order with linked profit target and stop loss orders.
Supports multiple target and stop legs, triggered entry, break-even, trailing stops, and timed release/cancel.
§Example: one target, one stop
use rithmic_rs::{OrderSide, OrderType, RithmicBracketOrder};
let order = RithmicBracketOrder::new()
.symbol("ESH6")
.exchange("CME")
.quantity(1)
.action(OrderSide::Buy)
.price_type(OrderType::Limit)
.price(5000.0)
.target(20)
.stop(10)
.localid("my-order-1")
.build()?;§Example: staggered targets
use rithmic_rs::{OrderSide, OrderType, RithmicBracketOrder};
let order = RithmicBracketOrder::new()
.symbol("ESM6")
.exchange("CME")
.quantity(3)
.action(OrderSide::Buy)
.price_type(OrderType::StopLimit)
.price(5000.25)
.trigger_price(4999.75)
.targets([(2, 16), (1, 24)])
.stops([(3, 8)])
.break_even_ticks(2)
.build()?;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.action: OrderSideBuy or Sell.
duration: TimeInForceOrder duration.
exchange: StringExchange code (e.g., “CME”).
localid: StringYour identifier for tracking this order.
price_type: OrderTypeOrder type.
price: Option<f64>Entry price. A market entry does not need one.
trigger_price: Option<f64>Trigger price. Only a stop or if-touched entry needs one.
quantity: i32Entry order size (number of contracts).
For a coherent bracket, this should equal the sum of
target_quantity across all target legs. The crate does not validate
this invariant.
symbol: StringTrading symbol (e.g., “ESH6”).
bracket_type: Option<BracketType>Rithmic bracket shape. None means “derive it from the legs supplied”;
Self::build resolves it from the target and stop legs, and leaves it
unset when there are none.
target_quantity: Vec<i32>Exit target quantities, one value per target leg.
target_ticks: Vec<i32>Exit target distances in ticks.
stop_quantity: Vec<i32>Exit stop quantities.
stop_ticks: Vec<i32>Exit stop distances in ticks.
if_touched: Option<RithmicIfTouchedTrigger>Optional if-touched trigger settings.
break_even_ticks: Option<i32>Move stop to break-even by this many ticks.
break_even_trigger_ticks: Option<i32>Trigger break-even once the position reaches this many ticks.
trailing_stop_trigger_ticks: Option<i32>Enable a trailing stop after this many ticks.
trailing_stop_by_last_trade_price: Option<bool>Use last trade instead of bid/offer for trailing stop tracking.
target_market_order_if_touched: Option<bool>Convert target to MIT once touched.
stop_market_on_reject: Option<bool>Convert stop to market if the current stop order is rejected.
target_market_at_ssboe: Option<i32>Convert target to market at this second-since-beginning-of-epoch value.
target_market_at_usecs: Option<i32>Microsecond component for target_market_at_ssboe.
stop_market_at_ssboe: Option<i32>Convert stop to market at this second-since-beginning-of-epoch value.
stop_market_at_usecs: Option<i32>Microsecond component for stop_market_at_ssboe.
target_market_order_after_secs: Option<i32>Convert target to market after this many seconds.
release_at_ssboe: Option<i32>Release order at this second-since-beginning-of-epoch value.
release_at_usecs: Option<i32>Microsecond component for release_at_ssboe.
cancel_at_ssboe: Option<i32>Cancel order at this second-since-beginning-of-epoch value.
cancel_at_usecs: Option<i32>Microsecond component for cancel_at_ssboe.
cancel_after_secs: Option<i32>Cancel order after this many seconds.
trade_route: Option<String>Route to send on. None uses the route the server published for exchange.
manual_or_auto: ManualOrAutoEntryWhether the order was placed by a human or automatically.
window_name: Option<String>Originating window name reported to Rithmic.
operation_type: Option<BracketOperationType>The order_operation_type sent to Rithmic. None leaves the choice
to the server.
Implementations§
Source§impl RithmicBracketOrder
The exit-leg setters come in singular and plural. Singular sets one leg
sized to the entry quantity; plural takes explicit (quantity, ticks)
pairs.
impl RithmicBracketOrder
The exit-leg setters come in singular and plural. Singular sets one leg
sized to the entry quantity; plural takes explicit (quantity, ticks)
pairs.
use rithmic_rs::RithmicBracketOrder;
let sized = RithmicBracketOrder::new().quantity(2).target(8).stop(4);
let explicit = RithmicBracketOrder::new()
.targets([(1, 8), (1, 16)])
.stops([(2, 4)]);Sourcepub fn quantity(self, quantity: i32) -> Self
pub fn quantity(self, quantity: i32) -> Self
Number of contracts on the entry.
Set this before Self::target or Self::stop, which size their
leg to whatever the quantity is when they are called.
Sourcepub fn price_type(self, price_type: OrderType) -> Self
pub fn price_type(self, price_type: OrderType) -> Self
Market, limit, stop, or if-touched entry.
Sourcepub fn duration(self, duration: TimeInForce) -> Self
pub fn duration(self, duration: TimeInForce) -> Self
How long the entry stays working.
Sourcepub fn localid(self, localid: impl Into<String>) -> Self
pub fn localid(self, localid: impl Into<String>) -> Self
Your identifier for tracking this order.
Sourcepub fn trigger_price(self, trigger_price: f64) -> Self
pub fn trigger_price(self, trigger_price: f64) -> Self
Trigger price for stop and if-touched entry types.
Sourcepub fn bracket_type(self, bracket_type: BracketType) -> Self
pub fn bracket_type(self, bracket_type: BracketType) -> Self
Bracket shape, overriding what build() would derive from the legs.
Sourcepub fn target(self, ticks: i32) -> Self
pub fn target(self, ticks: i32) -> Self
One target leg at this tick distance, sized to the entry quantity.
Reads Self::quantity as it stands right now, so set the quantity
first — otherwise the leg is sized to 0 and Self::build rejects it.
Sourcepub fn stop(self, ticks: i32) -> Self
pub fn stop(self, ticks: i32) -> Self
One stop leg at this tick distance, sized to the entry quantity.
Reads Self::quantity as it stands right now, so set the quantity
first — otherwise the leg is sized to 0 and Self::build rejects it.
Sourcepub fn targets(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self
pub fn targets(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self
Target legs as (quantity, ticks) pairs, replacing any already set.
Sourcepub fn stops(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self
pub fn stops(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self
Stop legs as (quantity, ticks) pairs, replacing any already set.
Sourcepub fn if_touched(self, if_touched: RithmicIfTouchedTrigger) -> Self
pub fn if_touched(self, if_touched: RithmicIfTouchedTrigger) -> Self
Conditional trigger that releases the entry once touched.
Sourcepub fn break_even_ticks(self, ticks: i32) -> Self
pub fn break_even_ticks(self, ticks: i32) -> Self
Move the stop to break-even by this many ticks.
Sourcepub fn break_even_trigger_ticks(self, ticks: i32) -> Self
pub fn break_even_trigger_ticks(self, ticks: i32) -> Self
Trigger break-even once the position reaches this many ticks.
Sourcepub fn trailing_stop_trigger_ticks(self, ticks: i32) -> Self
pub fn trailing_stop_trigger_ticks(self, ticks: i32) -> Self
Enable a trailing stop after this many ticks.
Sourcepub fn trailing_stop_by_last_trade_price(
self,
by_last_trade_price: bool,
) -> Self
pub fn trailing_stop_by_last_trade_price( self, by_last_trade_price: bool, ) -> Self
Track the trailing stop against the last trade instead of bid/offer.
Sourcepub fn target_market_order_if_touched(self, market_if_touched: bool) -> Self
pub fn target_market_order_if_touched(self, market_if_touched: bool) -> Self
Convert the target to market-if-touched once touched.
Sourcepub fn stop_market_on_reject(self, market_on_reject: bool) -> Self
pub fn stop_market_on_reject(self, market_on_reject: bool) -> Self
Convert the stop to market if the resting stop order is rejected.
Sourcepub fn target_market_at_ssboe(self, ssboe: i32) -> Self
pub fn target_market_at_ssboe(self, ssboe: i32) -> Self
Convert the target to market at this second-since-beginning-of-epoch value.
Sourcepub fn target_market_at_usecs(self, usecs: i32) -> Self
pub fn target_market_at_usecs(self, usecs: i32) -> Self
Microsecond component of the target’s market-conversion time.
Sourcepub fn target_market_at(self, ssboe: i32, usecs: i32) -> Self
pub fn target_market_at(self, ssboe: i32, usecs: i32) -> Self
Set both halves of the target’s market-conversion time.
Sourcepub fn stop_market_at_ssboe(self, ssboe: i32) -> Self
pub fn stop_market_at_ssboe(self, ssboe: i32) -> Self
Convert the stop to market at this second-since-beginning-of-epoch value.
Sourcepub fn stop_market_at_usecs(self, usecs: i32) -> Self
pub fn stop_market_at_usecs(self, usecs: i32) -> Self
Microsecond component of the stop’s market-conversion time.
Sourcepub fn stop_market_at(self, ssboe: i32, usecs: i32) -> Self
pub fn stop_market_at(self, ssboe: i32, usecs: i32) -> Self
Set both halves of the stop’s market-conversion time.
Sourcepub fn target_market_order_after_secs(self, secs: i32) -> Self
pub fn target_market_order_after_secs(self, secs: i32) -> Self
Convert the target to market after this many seconds.
Sourcepub fn release_at_ssboe(self, ssboe: i32) -> Self
pub fn release_at_ssboe(self, ssboe: i32) -> Self
Release the order at this second-since-beginning-of-epoch value.
Sourcepub fn release_at_usecs(self, usecs: i32) -> Self
pub fn release_at_usecs(self, usecs: i32) -> Self
Microsecond component of the release time.
Sourcepub fn release_at(self, ssboe: i32, usecs: i32) -> Self
pub fn release_at(self, ssboe: i32, usecs: i32) -> Self
Set both halves of the release time.
Sourcepub fn cancel_at_ssboe(self, ssboe: i32) -> Self
pub fn cancel_at_ssboe(self, ssboe: i32) -> Self
Cancel the order at this second-since-beginning-of-epoch value.
Sourcepub fn cancel_at_usecs(self, usecs: i32) -> Self
pub fn cancel_at_usecs(self, usecs: i32) -> Self
Microsecond component of the cancel time.
Sourcepub fn cancel_after_secs(self, secs: i32) -> Self
pub fn cancel_after_secs(self, secs: i32) -> Self
Cancel the order after this many seconds.
Sourcepub fn trade_route(self, trade_route: impl Into<String>) -> Self
pub fn trade_route(self, trade_route: impl Into<String>) -> Self
Route to send on, overriding the route published for the exchange.
Sourcepub fn manual_or_auto(self, manual_or_auto: ManualOrAutoEntry) -> Self
pub fn manual_or_auto(self, manual_or_auto: ManualOrAutoEntry) -> Self
Whether this was done by a human or automatically.
Sourcepub fn window_name(self, window_name: impl Into<String>) -> Self
pub fn window_name(self, window_name: impl Into<String>) -> Self
Window name to report this order under.
Sourcepub fn operation_type(self, operation_type: BracketOperationType) -> Self
pub fn operation_type(self, operation_type: BracketOperationType) -> Self
The order_operation_type sent to Rithmic.
Sourcepub fn validate(&self) -> Result<(), RithmicError>
pub fn validate(&self) -> Result<(), RithmicError>
Check the entry carries the prices its Self::price_type requires:
Limit, StopLimit and LimitIfTouched need Self::price;
StopMarket, StopLimit, MarketIfTouched and LimitIfTouched need
Self::trigger_price. Market needs neither.
Also check the exit legs hold together: each side’s quantities and tick
distances pair up one to one, every leg’s quantity is positive, and a
Self::bracket_type set by hand names the sides the legs actually
form. Tick distances themselves are not judged — Rithmic is the
authority on what it accepts.
Sourcepub fn build(self) -> Result<Self, RithmicError>
pub fn build(self) -> Result<Self, RithmicError>
Validate and return the order, deriving an unset Self::bracket_type
from the exit legs supplied.
Trait Implementations§
Source§impl Clone for RithmicBracketOrder
impl Clone for RithmicBracketOrder
Source§fn clone(&self) -> RithmicBracketOrder
fn clone(&self) -> RithmicBracketOrder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more