1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::http::{Credentials, Method, request::Request};
/// # Cancel a price-triggered order
///
/// Cancel a specific price-triggered order (auto order/conditional order) by order ID.
/// Only orders in "open" status (waiting to trigger) can be cancelled.
///
/// ## Important Notes:
/// - Only orders in "open" status can be cancelled
/// - Orders that have already triggered and are executing cannot be cancelled
/// - Completed, failed, expired orders cannot be cancelled
/// - This action cannot be undone
///
/// ## Response:
/// Returns the cancelled order details with updated status
///
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-a-price-triggered-order)
pub struct CancelPriceOrder {
/// Price-triggered order ID to cancel
pub order_id: String,
/// Request expiration time in milliseconds
pub x_gate_exp_time: Option<u128>,
/// API credentials for authentication
pub credentials: Option<Credentials>,
}
impl CancelPriceOrder {
/// Create a new cancel price order request
pub fn new(order_id: &str) -> Self {
Self {
order_id: order_id.to_owned(),
x_gate_exp_time: None,
credentials: None,
}
}
/// Specify the expiration time (milliseconds);
/// If the GATE receives the request time greater than the expiration time, the request will be rejected
pub fn x_gate_exp_time(mut self, x_gate_exp_time: u128) -> Self {
self.x_gate_exp_time = Some(x_gate_exp_time);
self
}
/// Set API credentials for authentication
pub fn credentials(mut self, creds: Credentials) -> Self {
self.credentials = Some(creds);
self
}
}
impl From<CancelPriceOrder> for Request {
fn from(request: CancelPriceOrder) -> Request {
let params = Vec::new();
Request {
method: Method::Delete,
path: format!("/api/v4/spot/price_orders/{}", request.order_id).into(),
params,
payload: "".to_string(),
x_gate_exp_time: request.x_gate_exp_time,
credentials: request.credentials,
sign: true,
}
}
}