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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
//! # Gate.io Spot Trading API
//!
//! This module provides a comprehensive interface to Gate.io's Spot trading API endpoints.
//! All functions return request builders that can be configured with additional parameters
//! before sending via the HTTP client.
//!
//! ## Categories
//!
//! ### Market Data (Public)
//! - [`get_currencies`] - List all supported currencies
//! - [`get_currency`] - Get specific currency details
//! - [`get_currency_pairs`] - List all trading pairs
//! - [`get_currency_pair`] - Get specific pair details
//! - [`get_ticker`] - Get ticker information
//! - [`get_orderbook`] - Get order book data
//! - [`get_market_trades`] - Get recent market trades
//! - [`get_candlesticks`] - Get historical price data
//! - [`get_server_time`] - Get server timestamp
//!
//! ### Account Management (Private)
//! - [`get_account`] - List spot account balances
//! - [`get_account_book`] - Query account transaction history
//! - [`get_fee`] - Get trading fee rates
//! - [`get_batch_user_fee`] - Get fee rates for multiple pairs
//!
//! ### Order Management (Private)
//! - [`create_order`] - Place a new order
//! - [`create_batch_orders`] - Place multiple orders
//! - [`get_orders`] - List order history
//! - [`get_order`] - Get specific order details
//! - [`get_open_orders`] - List active orders
//! - [`amend_order`] - Modify an existing order
//! - [`amend_batch_orders`] - Modify multiple orders
//! - [`cancel_order`] - Cancel a specific order
//! - [`cancel_batch_orders`] - Cancel multiple orders
//! - [`cancel_all_open_orders`] - Cancel all open orders
//! - [`countdown_cancel_all`] - Set auto-cancel timer
//!
//! ### Advanced Orders (Private)
//! - [`create_price_order`] - Create stop/trigger orders
//! - [`get_price_orders`] - List active trigger orders
//! - [`get_price_order`] - Get specific trigger order
//! - [`cancel_price_order`] - Cancel trigger order
//! - [`cancel_all_price_orders`] - Cancel all trigger orders
//! - [`create_cross_liquidate_orders`] - Cross-currency liquidation
//!
//! ### Trading History (Private)
//! - [`get_my_trades`] - Get personal trade history
//! - [`get_insurance_history`] - Get insurance fund data
//!
//! ## Example Usage
//!
//! ```rust,no_run
//! use gateio_rs::{
//! api::spot::{get_ticker, create_order},
//! http::Credentials,
//! ureq::GateHttpClient,
//! };
//!
//! // Public API - no authentication needed
//! let client = GateHttpClient::default();
//! let ticker_req = get_ticker().currency_pair("BTC_USDT");
//! let response = client.send(ticker_req)?;
//!
//! // Private API - requires authentication
//! let credentials = Credentials::new("api_key", "api_secret");
//! let client = GateHttpClient::default().credentials(credentials);
//! let order_req = create_order("BTC_USDT", "buy", "0.001").price("50000");
//! let response = client.send(order_req)?;
//! # Ok::<(), Box<dyn std::error::Error>>(()).expect("");
//! ```
//!
//! For detailed parameter documentation, see the [Gate.io API Documentation](https://www.gate.com/docs/developers/apiv4/#spot).
/// Amend multiple orders in batch
/// Amend a single order
/// Cancel all open orders
/// Cancel all price orders
/// Cancel multiple orders in batch
/// Cancel a single order
/// Cancel a price order
/// Set countdown timer to cancel all orders
/// Create multiple orders in batch
/// Create cross liquidate orders
/// Create a single order
/// Create a price order
/// Get account information
/// Get account transaction history
/// Get batch user fee rates
/// Get candlestick data
/// Get all supported currencies
/// Get single currency information
/// Get currency pair details
/// Get all currency pairs
/// Get trading fees
/// Get insurance fund history
/// Get market trade history
/// Get user's trade history
/// Get open orders
/// Get single order details
/// Get order book
/// Get order history
/// Get single price order
/// Get price order history
/// Get server time
/// Get ticker information
/// Order data structures
use GetAccount;
use GetAccountBook;
use GetBatchUserFee;
use GetCandlesticks;
use GetCurrencies;
use GetCurrency;
use GetCurrencyPair;
use GetCurrencyPairs;
use GetMarketTrades;
use GetOrderbook;
use GetTicker;
use AmendBatchOrders;
pub use OrderAmendment;
use AmendOrder;
use CancelAllOpenOrders;
use CancelAllPriceOrders;
use CancelBatchOrders;
pub use CancelOrderRequest;
use CancelOrder;
use CancelPriceOrder;
use CountdownCancelAll;
use CreateBatchOrders;
use CreateCrossLiquidateOrders;
pub use CrossLiquidateOrder;
use CreateOrder;
use CreatePriceOrder;
use GetFee;
use GetInsuranceHistory;
use GetMyTrades;
use GetOpenOrders;
use GetOrder;
use GetOrders;
use GetPriceOrder;
use GetPriceOrders;
use GetServerTime;
pub use Order;
/// List all currencies' details <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-all-currencies-details)
/// Get details of a specific currency <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-details-of-a-specific-currency)
/// List all currency pairs supported <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-all-currency-pairs-supported)
/// Get details of a specific currency pair <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-details-of-a-specifc-currency-pair)
/// Retrieve ticker information for currency pairs.
///
/// Returns 24hr trading statistics including price, volume, and changes.
/// Can be used to get data for a specific pair or all pairs at once.
///
/// # Parameters
/// - `currency_pair`: Optional. Specific trading pair (e.g., "BTC_USDT")
/// - `timezone`: Optional. Timezone for calculation ("utc0" to "utc12", "utc-12" to "utc-1")
///
/// # Examples
///
/// ```rust,no_run
/// use gateio_rs::{api::spot::get_ticker, ureq::GateHttpClient};
///
/// let client = GateHttpClient::default();
///
/// // Get ticker for specific pair
/// let request = get_ticker().currency_pair("BTC_USDT");
/// let response = client.send(request)?;
///
/// // Get all tickers
/// let request = get_ticker();
/// let response = client.send(request)?;
/// # Ok::<(), Box<dyn std::error::Error>>(()).expect("");
/// ```
///
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#retrieve-ticker-information)
/// Retrieve order book <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#retrieve-order-book)
/// Retrieve market trades
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#retrieve-market-trades)
/// Market candlesticks
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#market-candlesticks)
/// Query a batch of user trading fee rates
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#query-a-batch-of-user-trading-fee-rates)
/// List spot account balances and information.
///
/// Returns account balances for all currencies in the spot trading account.
/// Shows available balance, locked balance, and total balance for each currency.
///
/// # Authentication
/// This endpoint requires API key authentication.
///
/// # Optional Parameters (via builder methods)
/// - `currency`: Filter by specific currency (e.g., "BTC", "USDT")
///
/// # Examples
///
/// ```rust,no_run
/// use gateio_rs::{
/// api::spot::get_account,
/// http::Credentials,
/// ureq::GateHttpClient,
/// };
///
/// let credentials = Credentials::new("api_key", "api_secret");
/// let client = GateHttpClient::default().credentials(credentials);
///
/// // Get all account balances
/// let request = get_account();
/// let response = client.send(request)?;
///
/// // Get specific currency balance
/// let request = get_account().currency("BTC");
/// let response = client.send(request)?;
/// # Ok::<(), Box<dyn std::error::Error>>(()).expect("");
/// ```
///
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-spot-accounts)
/// Query account book <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#query-account-book)
/// List all open orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-all-open-orders)
/// Create a new trading order.
///
/// Places a buy or sell order on the specified trading pair. Supports various order types
/// including market, limit, and immediate-or-cancel orders.
///
/// # Parameters
/// - `currency_pair`: Trading pair (e.g., "BTC_USDT")
/// - `side`: Order side ("buy" or "sell")
/// - `amount`: Order amount in base currency
///
/// # Optional Parameters (via builder methods)
/// - `price`: Order price (required for limit orders)
/// - `order_type`: "limit", "market", "ioc", "poc", "fok" (default: "limit")
/// - `account`: Account type ("spot", "margin", "cross_margin", "unified")
/// - `time_in_force`: "gtc", "ioc", "poc", "fok" (default: "gtc")
/// - `text`: Custom order ID for identification
///
/// # Examples
///
/// ```rust,no_run
/// use gateio_rs::{
/// api::spot::create_order,
/// http::Credentials,
/// ureq::GateHttpClient,
/// };
///
/// let credentials = Credentials::new("api_key", "api_secret");
/// let client = GateHttpClient::default().credentials(credentials);
///
/// // Limit buy order
/// let request = create_order("BTC_USDT", "buy", "0.001")
/// .price("50000")
/// .order_type("limit")
/// .time_in_force("gtc");
/// let response = client.send(request)?;
///
/// // Market sell order
/// let request = create_order("BTC_USDT", "sell", "0.001")
/// .order_type("market");
/// let response = client.send(request)?;
/// # Ok::<(), Box<dyn std::error::Error>>(()).expect("");
/// ```
///
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#create-an-order)
/// List orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-orders)
/// Get a single order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-a-single-order)
/// Cancel a batch of orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-a-batch-of-orders-with-an-id-list)
/// List personal trading history <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#list-personal-trading-history)
/// Query user trading fee rates <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#query-user-trading-fee-rates)
/// Cancel a single order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-a-single-order)
/// Amend an order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#amend-an-order)
/// Create a batch of orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#create-a-batch-of-orders)
/// Create a price-triggered order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#create-a-price-triggered-order)
/// Retrieve running auto order list <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#retrieve-running-auto-order-list)
/// Cancel all price-triggered orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-all-price-triggered-orders)
/// Get a price-triggered order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-a-price-triggered-order)
/// Cancel a price-triggered order <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-a-price-triggered-order)
/// Get server current time <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-server-current-time)
/// Cancel all open orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#cancel-all-open-orders)
/// Countdown cancel orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#countdown-cancel-orders)
/// Amend multiple orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#batch-modification-of-orders)
/// Create cross liquidation orders <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#close-position-when-cross-currency-is-disabled)
/// Query insurance fund history <br/>
/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#query-spot-insurance-fund-historical-data)