Skip to main content

rust_okx/ws/request/
trade.rs

1//! Standard trade WebSocket request models.
2
3use serde::Serialize;
4
5/// MMP mass-cancel request body (`mass-cancel`).
6///
7/// Only `OPTION` in Portfolio Margin mode is supported by OKX.
8///
9/// OKX docs: <https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-mass-cancel-order>
10#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
11#[serde(rename_all = "camelCase")]
12#[non_exhaustive]
13pub struct MassCancelRequest {
14    /// Instrument type. OKX currently requires `OPTION`.
15    pub inst_type: String,
16    /// Instrument family, e.g. `BTC-USD`.
17    pub inst_family: String,
18    /// Lock interval in milliseconds, range `0..=10000`.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub lock_interval: Option<String>,
21}
22
23impl MassCancelRequest {
24    /// Create an option MMP mass-cancel request.
25    pub fn option(inst_family: impl Into<String>) -> Self {
26        Self {
27            inst_type: "OPTION".to_owned(),
28            inst_family: inst_family.into(),
29            lock_interval: None,
30        }
31    }
32
33    /// Set the post-cancel lock interval in milliseconds.
34    pub fn lock_interval(mut self, lock_interval: impl Into<String>) -> Self {
35        self.lock_interval = Some(lock_interval.into());
36        self
37    }
38}