Skip to main content

GridTradeRule

Struct GridTradeRule 

Source
pub struct GridTradeRule {
Show 22 fields pub submitted_base_price: Option<Decimal>, pub upper_limit_price: Option<Decimal>, pub lower_limit_price: Option<Decimal>, pub trigger_price_type: Option<TriggerPriceType>, pub trigger_spread_up: Option<Decimal>, pub trigger_spread_down: Option<Decimal>, pub trigger_percent_up: Option<Decimal>, pub trigger_percent_down: Option<Decimal>, pub multiple_trigger: Option<bool>, pub time_in_force: Option<GridTimeInForce>, pub upper_limit_quantity: Option<Decimal>, pub lower_limit_quantity: Option<Decimal>, pub expire_time: Option<i64>, pub upper_limit_event: Option<GridLimitEvent>, pub lower_limit_event: Option<GridLimitEvent>, pub trigger_sell_depth: Option<i32>, pub trigger_buy_depth: Option<i32>, pub trigger_quantity: Option<Decimal>, pub support_shortsell: Option<bool>, pub rth: Option<i32>, pub grid_order_type_up: Option<String>, pub grid_order_type_down: Option<String>,
}
Expand description

Grid trading rule — parameters for submit / replace.

Mirrors the GridTradingRule message in the gridtrading proto. Prices and quantities are decimals serialized as strings; enum-like fields are raw integers whose code tables are documented inline.

Fields§

§submitted_base_price: Option<Decimal>

Base price the grid is anchored to

§upper_limit_price: Option<Decimal>

Upper price bound

§lower_limit_price: Option<Decimal>

Lower price bound

§trigger_price_type: Option<TriggerPriceType>

Trigger price type (only 1 / 2 allowed)

§trigger_spread_up: Option<Decimal>

Upward trigger spread (absolute)

§trigger_spread_down: Option<Decimal>

Downward trigger spread (absolute)

§trigger_percent_up: Option<Decimal>

Upward trigger percent

§trigger_percent_down: Option<Decimal>

Downward trigger percent

§multiple_trigger: Option<bool>

Whether a single grid level may trigger multiple times

§time_in_force: Option<GridTimeInForce>

Time in force (0 = Day, 1 = GTC, 6 = GTD)

§upper_limit_quantity: Option<Decimal>

Quantity handled when the upper bound is reached

§lower_limit_quantity: Option<Decimal>

Quantity handled when the lower bound is reached

§expire_time: Option<i64>

Expiry time (unix seconds), used with GTD

§upper_limit_event: Option<GridLimitEvent>

Action when the upper bound is reached (only 1 / 2 allowed)

§lower_limit_event: Option<GridLimitEvent>

Action when the lower bound is reached (only 1 / 2 allowed)

§trigger_sell_depth: Option<i32>

Sell-side order-book depth (-5..5, 0 = use grid_order_type_up)

§trigger_buy_depth: Option<i32>

Buy-side order-book depth (-5..5, 0 = use grid_order_type_down)

§trigger_quantity: Option<Decimal>

Quantity per trigger

§support_shortsell: Option<bool>

Whether short selling is allowed

§rth: Option<i32>

Regular trading hours flag (0 / 1 / 2)

§grid_order_type_up: Option<String>

Sell-side order type when depth is 0 (GMO / GLO / GTG)

§grid_order_type_down: Option<String>

Buy-side order type when depth is 0 (GMO / GLO / GTG)

Implementations§

Source§

impl GridTradeRule

Source

pub fn new( base_price: Decimal, upper_price: Decimal, lower_price: Decimal, trigger: GridTrigger, quantity: Decimal, upper_quantity: Decimal, lower_quantity: Decimal, time_in_force: GridTimeInForce, ) -> Self

Create a rule with the fields a valid grid order requires. The gateway still validates business rules, but this makes the minimum field set visible in the type signature instead of leaving all fields optional.

Source

pub fn limit_events(self, upper: GridLimitEvent, lower: GridLimitEvent) -> Self

Set the actions taken at the upper / lower bounds.

Source

pub fn depths(self, sell: i32, buy: i32) -> Self

Set the sell / buy order-book depths (0 = use the order type).

Source

pub fn order_types(self, up: impl Into<String>, down: impl Into<String>) -> Self

Set the sell / buy order types (GMO / GLO / GTG).

Source

pub fn multiple_trigger(self, value: bool) -> Self

Allow a single grid level to trigger multiple times.

Source

pub fn support_shortsell(self, value: bool) -> Self

Allow short selling.

Source

pub fn rth(self, value: i32) -> Self

Set the regular-trading-hours flag (0 / 1 / 2).

Source

pub fn expire_time(self, unix_seconds: i64) -> Self

Set the expiry time (unix seconds), used with a GTD time-in-force.

Trait Implementations§

Source§

impl Clone for GridTradeRule

Source§

fn clone(&self) -> GridTradeRule

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 GridTradeRule

Source§

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

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

impl Default for GridTradeRule

Source§

fn default() -> GridTradeRule

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

impl<'de> Deserialize<'de> for GridTradeRule

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 Serialize for GridTradeRule

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

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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