bybit/models/cancel_order_request.rs
1use crate::prelude::*;
2
3/// Represents a request to cancel an order on Bybit.
4///
5/// This struct defines parameters to cancel an existing order, identified by `order_id`
6/// or `order_link_id`. In perpetual futures, canceling orders is common to adjust
7/// strategies or avoid unwanted executions. Bots must ensure accurate identification
8/// and handle API responses to confirm cancellation, as untracked orders can lead to
9/// unintended positions.
10#[derive(Clone, Serialize)]
11pub struct CancelOrderRequest<'a> {
12 /// The category of the trading product (e.g., Spot, Linear).
13 ///
14 /// Specifies the market of the order to cancel. Must match the original order’s
15 /// category to avoid errors. In perpetual futures, `Linear` is typical.
16 pub category: Category,
17
18 /// The trading pair symbol, e.g., "BTCUSDT".
19 ///
20 /// Identifies the asset pair of the order. Must match the original order’s symbol.
21 /// Bots should validate symbol consistency to ensure correct cancellation.
22 pub symbol: Cow<'a, str>,
23
24 /// The unique identifier of the order to cancel.
25 ///
26 /// Provided by Bybit when the order was created. Either `order_id` or
27 /// `order_link_id` must be provided to identify the order for cancellation.
28 pub order_id: Option<Cow<'a, str>>,
29
30 /// The user-defined identifier of the order to cancel.
31 ///
32 /// Allows bots to reference orders using their custom ID. Useful for tracking
33 /// cancellations in complex perpetual futures strategies.
34 pub order_link_id: Option<Cow<'a, str>>,
35
36 /// A filter to specify the order type (e.g., "tpslOrder").
37 ///
38 /// Used to target specific order types for cancellation, such as TP/SL orders.
39 /// Bots should set this correctly to cancel the intended orders in perpetual futures.
40 pub order_filter: Option<Cow<'a, str>>,
41}