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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use crate::http::{Credentials, Method, request::Request};
/// # Retrieve running auto order list
///
/// Retrieve running price-triggered orders (also called auto orders or conditional orders).
/// These orders are not placed in the order book until their trigger condition is met.
///
/// ## Status Values:
/// - "open": Waiting to trigger
/// - "cancelled": Manually cancelled
/// - "finish": Successfully executed
/// - "failed": Failed to execute
/// - "expired": Expired
///
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#retrieve-running-auto-order-list)
pub struct GetPriceOrders {
/// Order status filter
pub status: Option<String>,
/// Currency pair (market) filter
pub market: Option<String>,
/// Account type filter
pub account: Option<String>,
/// Maximum number of records to return
pub limit: Option<i32>,
/// Offset for pagination
pub offset: Option<i32>,
/// API credentials for authentication
pub credentials: Option<Credentials>,
}
impl GetPriceOrders {
/// Creates a new GetPriceOrders request
pub fn new() -> Self {
Self {
status: None,
market: None,
account: None,
limit: None,
offset: None,
credentials: None,
}
}
/// Filter by order status
/// - "open": Waiting to trigger
/// - "cancelled": Manually cancelled
/// - "finish": Successfully executed
/// - "failed": Failed to execute
/// - "expired": Expired
pub fn status(mut self, status: &str) -> Self {
self.status = Some(status.into());
self
}
/// Filter by currency pair (market)
pub fn market(mut self, market: &str) -> Self {
self.market = Some(market.into());
self
}
/// Filter by account type
/// - "normal": Normal spot trading account
/// - "margin": Margin trading account
/// - "unified": Unified trading account
pub fn account(mut self, account: &str) -> Self {
self.account = Some(account.into());
self
}
/// Maximum number of records to return (default: 100, max: 1000)
pub fn limit(mut self, limit: i32) -> Self {
self.limit = Some(limit);
self
}
/// Offset for pagination (default: 0)
pub fn offset(mut self, offset: i32) -> Self {
self.offset = Some(offset);
self
}
/// Sets the API credentials for authentication
pub fn credentials(mut self, creds: Credentials) -> Self {
self.credentials = Some(creds);
self
}
}
impl From<GetPriceOrders> for Request {
fn from(request: GetPriceOrders) -> Request {
let mut params = Vec::new();
if let Some(status) = request.status {
params.push(("status".into(), status));
}
if let Some(market) = request.market {
params.push(("market".into(), market));
}
if let Some(account) = request.account {
params.push(("account".into(), account));
}
if let Some(limit) = request.limit {
params.push(("limit".into(), limit.to_string()));
}
if let Some(offset) = request.offset {
params.push(("offset".into(), offset.to_string()));
}
Request {
method: Method::Get,
path: "/api/v4/spot/price_orders".into(),
params,
payload: "".to_string(),
x_gate_exp_time: None,
credentials: request.credentials,
sign: true,
}
}
}