Skip to main content

RithmicBracketOrder

Struct RithmicBracketOrder 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§action: OrderSide

Buy or Sell.

§duration: TimeInForce

Order duration.

§exchange: String

Exchange code (e.g., “CME”).

§localid: String

Your identifier for tracking this order.

§price_type: OrderType

Order 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: i32

Entry 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: String

Trading 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: ManualOrAutoEntry

Whether 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.

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)]);
Source

pub fn new() -> Self

Start from the defaults.

Source

pub fn symbol(self, symbol: impl Into<String>) -> Self

Instrument symbol.

Source

pub fn exchange(self, exchange: impl Into<String>) -> Self

Exchange the instrument trades on.

Source

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.

Source

pub fn action(self, action: OrderSide) -> Self

Buy or sell on the entry.

Source

pub fn price_type(self, price_type: OrderType) -> Self

Market, limit, stop, or if-touched entry.

Source

pub fn duration(self, duration: TimeInForce) -> Self

How long the entry stays working.

Source

pub fn localid(self, localid: impl Into<String>) -> Self

Your identifier for tracking this order.

Source

pub fn price(self, price: f64) -> Self

Entry price.

Source

pub fn trigger_price(self, trigger_price: f64) -> Self

Trigger price for stop and if-touched entry types.

Source

pub fn bracket_type(self, bracket_type: BracketType) -> Self

Bracket shape, overriding what build() would derive from the legs.

Source

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.

Source

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.

Source

pub fn targets(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self

Target legs as (quantity, ticks) pairs, replacing any already set.

Source

pub fn stops(self, legs: impl IntoIterator<Item = (i32, i32)>) -> Self

Stop legs as (quantity, ticks) pairs, replacing any already set.

Source

pub fn if_touched(self, if_touched: RithmicIfTouchedTrigger) -> Self

Conditional trigger that releases the entry once touched.

Source

pub fn break_even_ticks(self, ticks: i32) -> Self

Move the stop to break-even by this many ticks.

Source

pub fn break_even_trigger_ticks(self, ticks: i32) -> Self

Trigger break-even once the position reaches this many ticks.

Source

pub fn trailing_stop_trigger_ticks(self, ticks: i32) -> Self

Enable a trailing stop after this many ticks.

Source

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.

Source

pub fn target_market_order_if_touched(self, market_if_touched: bool) -> Self

Convert the target to market-if-touched once touched.

Source

pub fn stop_market_on_reject(self, market_on_reject: bool) -> Self

Convert the stop to market if the resting stop order is rejected.

Source

pub fn target_market_at_ssboe(self, ssboe: i32) -> Self

Convert the target to market at this second-since-beginning-of-epoch value.

Source

pub fn target_market_at_usecs(self, usecs: i32) -> Self

Microsecond component of the target’s market-conversion time.

Source

pub fn target_market_at(self, ssboe: i32, usecs: i32) -> Self

Set both halves of the target’s market-conversion time.

Source

pub fn stop_market_at_ssboe(self, ssboe: i32) -> Self

Convert the stop to market at this second-since-beginning-of-epoch value.

Source

pub fn stop_market_at_usecs(self, usecs: i32) -> Self

Microsecond component of the stop’s market-conversion time.

Source

pub fn stop_market_at(self, ssboe: i32, usecs: i32) -> Self

Set both halves of the stop’s market-conversion time.

Source

pub fn target_market_order_after_secs(self, secs: i32) -> Self

Convert the target to market after this many seconds.

Source

pub fn release_at_ssboe(self, ssboe: i32) -> Self

Release the order at this second-since-beginning-of-epoch value.

Source

pub fn release_at_usecs(self, usecs: i32) -> Self

Microsecond component of the release time.

Source

pub fn release_at(self, ssboe: i32, usecs: i32) -> Self

Set both halves of the release time.

Source

pub fn cancel_at_ssboe(self, ssboe: i32) -> Self

Cancel the order at this second-since-beginning-of-epoch value.

Source

pub fn cancel_at_usecs(self, usecs: i32) -> Self

Microsecond component of the cancel time.

Source

pub fn cancel_at(self, ssboe: i32, usecs: i32) -> Self

Set both halves of the cancel time.

Source

pub fn cancel_after_secs(self, secs: i32) -> Self

Cancel the order after this many seconds.

Source

pub fn trade_route(self, trade_route: impl Into<String>) -> Self

Route to send on, overriding the route published for the exchange.

Source

pub fn manual_or_auto(self, manual_or_auto: ManualOrAutoEntry) -> Self

Whether this was done by a human or automatically.

Source

pub fn window_name(self, window_name: impl Into<String>) -> Self

Window name to report this order under.

Source

pub fn operation_type(self, operation_type: BracketOperationType) -> Self

The order_operation_type sent to Rithmic.

Source

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.

Source

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

Source§

fn clone(&self) -> RithmicBracketOrder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RithmicBracketOrder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RithmicBracketOrder

Source§

fn default() -> RithmicBracketOrder

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RithmicBracketOrder

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RithmicBracketOrder

Source§

fn eq(&self, other: &RithmicBracketOrder) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RithmicBracketOrder

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RithmicBracketOrder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more