Skip to main content

AmendOrderRequest

Struct AmendOrderRequest 

Source
pub struct AmendOrderRequest<'a> {
Show 16 fields pub category: Category, pub symbol: Cow<'a, str>, pub order_id: Option<Cow<'a, str>>, pub order_link_id: Option<Cow<'a, str>>, pub order_iv: Option<f64>, pub trigger_price: Option<f64>, pub qty: f64, pub price: Option<f64>, pub tpsl_mode: Option<Cow<'a, str>>, pub take_profit: Option<f64>, pub stop_loss: Option<f64>, pub tp_trigger_by: Option<Cow<'a, str>>, pub sl_trigger_by: Option<Cow<'a, str>>, pub trigger_by: Option<Cow<'a, str>>, pub tp_limit_price: Option<f64>, pub sl_limit_price: Option<f64>,
}
Expand description

Represents a request to amend an existing order on Bybit.

This struct defines parameters for modifying an order’s attributes, such as price, quantity, or TP/SL. In perpetual futures, amending orders is essential for adapting to market movements (e.g., tightening stop-losses). Bots must ensure the order_id or order_link_id is valid and that changes comply with Bybit’s constraints (e.g., minimum quantity, price tick size) to avoid rejections.

Fields§

§category: Category

The category of the trading product (e.g., Spot, Linear).

Specifies the market for the order being amended. Bots must match this to the original order’s category to avoid errors. In perpetual futures, Linear is typical for USDT-margined contracts.

§symbol: Cow<'a, str>

The trading pair symbol, e.g., “BTCUSDT”.

Identifies the asset pair of the order. Must match the original order’s symbol. Bots should validate symbol consistency to prevent API errors in perpetual futures trading.

§order_id: Option<Cow<'a, str>>

The unique identifier of the order to amend.

Provided by Bybit when the order was created. Bots must include either order_id or order_link_id to identify the order. In perpetual futures, accurate order identification is critical for amending the correct position.

§order_link_id: Option<Cow<'a, str>>

The user-defined identifier of the order to amend.

Allows bots to reference orders using their custom ID. Useful for tracking multiple orders in perpetual futures strategies. Either order_id or order_link_id must be provided.

§order_iv: Option<f64>

The implied volatility for options orders (optional).

Used for options trading, not perpetual futures. Bots can ignore this unless amending options orders, where accurate volatility is needed for pricing.

§trigger_price: Option<f64>

The new trigger price for conditional orders.

Updates the price at which a conditional order (e.g., stop-loss) activates. In perpetual futures, bots use this to adjust risk management dynamically based on market conditions. Ensure the price aligns with symbol constraints.

§qty: f64

The new quantity of the order.

Updates the order size. In perpetual futures, bots must ensure the new quantity is valid (e.g., within position limits, sufficient margin) to avoid rejections. Over-sizing can increase liquidation risk.

§price: Option<f64>

The new price for limit orders.

Updates the target price for a limit order. Bots should validate the price against the symbol’s tick size and market conditions to ensure execution feasibility in volatile perpetual futures markets.

§tpsl_mode: Option<Cow<'a, str>>

The new take-profit/stop-loss mode (e.g., “Full”, “Partial”).

Updates whether TP/SL applies to the entire position or a portion. Bots should adjust this based on exit strategy; “Full” simplifies risk management, while “Partial” suits scaling out in perpetual futures.

§take_profit: Option<f64>

The new take-profit price.

Updates the price to lock in profits. Bots should set this based on updated market analysis, ensuring it’s realistic given volatility in perpetual futures.

§stop_loss: Option<f64>

The new stop-loss price.

Updates the price to limit losses. Critical for risk management in perpetual futures, bots should adjust SL dynamically to protect against adverse price movements while avoiding premature exits.

§tp_trigger_by: Option<Cow<'a, str>>

The new trigger price type for take-profit.

Updates the price metric (e.g., “MarkPrice”) for TP triggering. Bots should choose a reliable metric to ensure consistent execution in perpetual futures markets.

§sl_trigger_by: Option<Cow<'a, str>>

The new trigger price type for stop-loss.

Updates the price metric for SL triggering. Similar to tp_trigger_by, bots should select a stable trigger type to protect against manipulation in perpetual futures.

§trigger_by: Option<Cow<'a, str>>

The new trigger price type for conditional orders.

Updates the price metric for triggering conditional orders. Bots should ensure consistency with the order’s strategy and market conditions in perpetual futures.

§tp_limit_price: Option<f64>

The new limit price for take-profit orders.

Updates the exact price for limit-based TP orders. Bots must balance precision with execution likelihood in volatile perpetual futures markets.

§sl_limit_price: Option<f64>

The new limit price for stop-loss orders.

Updates the exact price for limit-based SL orders. Bots should ensure the price is achievable to effectively limit losses in perpetual futures.

Implementations§

Source§

impl<'a> AmendOrderRequest<'a>

Source

pub fn default() -> Self

Creates a default AmendOrderRequest with predefined values.

Initializes an amendment request with common defaults. Bots should modify necessary fields before submission to align with the target order’s attributes.

Source

pub fn custom( category: Category, symbol: &'a str, order_id: Option<&'a str>, order_link_id: Option<&'a str>, order_iv: Option<f64>, trigger_price: Option<f64>, qty: f64, price: Option<f64>, tpsl_mode: Option<&'a str>, take_profit: Option<f64>, stop_loss: Option<f64>, tp_trigger_by: Option<&'a str>, sl_trigger_by: Option<&'a str>, trigger_by: Option<&'a str>, tp_limit_price: Option<f64>, sl_limit_price: Option<f64>, ) -> Self

Creates a custom AmendOrderRequest with specified parameters.

Allows bots to tailor an amendment request fully. Ensure all parameters are valid and consistent with the original order to avoid API errors in perpetual futures trading.

Trait Implementations§

Source§

impl<'a> Clone for AmendOrderRequest<'a>

Source§

fn clone(&self) -> AmendOrderRequest<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Default for AmendOrderRequest<'a>

Source§

fn default() -> AmendOrderRequest<'a>

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

impl<'a> Serialize for AmendOrderRequest<'a>

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§

§

impl<'a> Freeze for AmendOrderRequest<'a>

§

impl<'a> RefUnwindSafe for AmendOrderRequest<'a>

§

impl<'a> Send for AmendOrderRequest<'a>

§

impl<'a> Sync for AmendOrderRequest<'a>

§

impl<'a> Unpin for AmendOrderRequest<'a>

§

impl<'a> UnsafeUnpin for AmendOrderRequest<'a>

§

impl<'a> UnwindSafe for AmendOrderRequest<'a>

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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