binance/spot/apis/
trading_api.rs

1/*
2 * Binance Spot API
3 *
4 * OpenAPI specification for Binance exchange - Spot API
5 *
6 * The version of the OpenAPI document: 0.1.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::spot::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`spot_create_order_cancel_replace_v3`]
18#[derive(Clone, Debug, Default)]
19pub struct SpotCreateOrderCancelReplaceV3Params {
20    pub cancel_replace_mode: String,
21    pub side: String,
22    pub symbol: String,
23    pub timestamp: i64,
24    pub r#type: String,
25    pub cancel_new_client_order_id: Option<String>,
26    pub cancel_order_id: Option<i64>,
27    pub cancel_orig_client_order_id: Option<String>,
28    pub cancel_restrictions: Option<String>,
29    pub iceberg_qty: Option<String>,
30    pub new_client_order_id: Option<String>,
31    pub new_order_resp_type: Option<String>,
32    pub order_rate_limit_exceeded_mode: Option<String>,
33    pub price: Option<String>,
34    pub quantity: Option<String>,
35    pub quote_order_qty: Option<String>,
36    pub recv_window: Option<i64>,
37    pub self_trade_prevention_mode: Option<String>,
38    pub stop_price: Option<String>,
39    pub strategy_id: Option<i64>,
40    pub strategy_type: Option<i32>,
41    pub time_in_force: Option<String>,
42    pub trailing_delta: Option<i64>
43}
44
45/// struct for passing parameters to the method [`spot_create_order_list_oco_v3`]
46#[derive(Clone, Debug, Default)]
47pub struct SpotCreateOrderListOcoV3Params {
48    pub above_type: String,
49    pub below_type: String,
50    pub quantity: String,
51    pub side: String,
52    pub symbol: String,
53    pub timestamp: i64,
54    pub above_client_order_id: Option<String>,
55    pub above_iceberg_qty: Option<i64>,
56    pub above_price: Option<String>,
57    pub above_stop_price: Option<String>,
58    pub above_strategy_id: Option<i64>,
59    pub above_strategy_type: Option<i32>,
60    pub above_time_in_force: Option<String>,
61    pub above_trailing_delta: Option<i64>,
62    pub below_client_order_id: Option<String>,
63    pub below_iceberg_qty: Option<i64>,
64    pub below_price: Option<String>,
65    pub below_stop_price: Option<String>,
66    pub below_strategy_id: Option<i64>,
67    pub below_strategy_type: Option<i32>,
68    pub below_time_in_force: Option<String>,
69    pub below_trailing_delta: Option<i64>,
70    pub list_client_order_id: Option<String>,
71    pub new_order_resp_type: Option<String>,
72    pub recv_window: Option<i64>,
73    pub self_trade_prevention_mode: Option<String>
74}
75
76/// struct for passing parameters to the method [`spot_create_order_list_oto_v3`]
77#[derive(Clone, Debug, Default)]
78pub struct SpotCreateOrderListOtoV3Params {
79    pub pending_quantity: String,
80    pub pending_side: String,
81    pub pending_type: String,
82    pub symbol: String,
83    pub timestamp: i64,
84    pub working_price: String,
85    pub working_quantity: String,
86    pub working_side: String,
87    pub working_type: String,
88    pub list_client_order_id: Option<String>,
89    pub new_order_resp_type: Option<String>,
90    pub pending_client_order_id: Option<String>,
91    pub pending_iceberg_qty: Option<String>,
92    pub pending_price: Option<String>,
93    pub pending_stop_price: Option<String>,
94    pub pending_strategy_id: Option<i64>,
95    pub pending_strategy_type: Option<i32>,
96    pub pending_time_in_force: Option<String>,
97    pub pending_trailing_delta: Option<String>,
98    pub recv_window: Option<i64>,
99    pub self_trade_prevention_mode: Option<String>,
100    pub working_client_order_id: Option<String>,
101    pub working_iceberg_qty: Option<String>,
102    pub working_strategy_id: Option<i64>,
103    pub working_strategy_type: Option<i32>,
104    pub working_time_in_force: Option<String>
105}
106
107/// struct for passing parameters to the method [`spot_create_order_list_otoco_v3`]
108#[derive(Clone, Debug, Default)]
109pub struct SpotCreateOrderListOtocoV3Params {
110    pub pending_above_type: String,
111    pub pending_quantity: String,
112    pub pending_side: String,
113    pub symbol: String,
114    pub timestamp: i64,
115    pub working_price: String,
116    pub working_quantity: String,
117    pub working_side: String,
118    pub working_type: String,
119    pub list_client_order_id: Option<String>,
120    pub new_order_resp_type: Option<String>,
121    pub pending_above_client_order_id: Option<String>,
122    pub pending_above_iceberg_qty: Option<String>,
123    pub pending_above_price: Option<String>,
124    pub pending_above_stop_price: Option<String>,
125    pub pending_above_strategy_id: Option<i64>,
126    pub pending_above_strategy_type: Option<i32>,
127    pub pending_above_time_in_force: Option<String>,
128    pub pending_above_trailing_delta: Option<String>,
129    pub pending_below_client_order_id: Option<String>,
130    pub pending_below_iceberg_qty: Option<String>,
131    pub pending_below_price: Option<String>,
132    pub pending_below_stop_price: Option<String>,
133    pub pending_below_strategy_id: Option<i64>,
134    pub pending_below_strategy_type: Option<i32>,
135    pub pending_below_time_in_force: Option<String>,
136    pub pending_below_trailing_delta: Option<String>,
137    pub pending_below_type: Option<String>,
138    pub recv_window: Option<i64>,
139    pub self_trade_prevention_mode: Option<String>,
140    pub working_client_order_id: Option<String>,
141    pub working_iceberg_qty: Option<String>,
142    pub working_strategy_id: Option<i64>,
143    pub working_strategy_type: Option<i32>,
144    pub working_time_in_force: Option<String>
145}
146
147/// struct for passing parameters to the method [`spot_create_order_oco_v3`]
148#[derive(Clone, Debug, Default)]
149pub struct SpotCreateOrderOcoV3Params {
150    pub price: String,
151    pub quantity: String,
152    pub side: String,
153    pub stop_price: String,
154    pub symbol: String,
155    pub timestamp: i64,
156    pub limit_client_order_id: Option<String>,
157    pub limit_iceberg_qty: Option<String>,
158    pub limit_strategy_id: Option<i64>,
159    pub limit_strategy_type: Option<i32>,
160    pub list_client_order_id: Option<String>,
161    pub new_order_resp_type: Option<String>,
162    pub recv_window: Option<i64>,
163    pub self_trade_prevention_mode: Option<String>,
164    pub stop_client_order_id: Option<String>,
165    pub stop_iceberg_qty: Option<String>,
166    pub stop_limit_price: Option<String>,
167    pub stop_limit_time_in_force: Option<String>,
168    pub stop_strategy_id: Option<i64>,
169    pub stop_strategy_type: Option<i32>,
170    pub trailing_delta: Option<i64>
171}
172
173/// struct for passing parameters to the method [`spot_create_order_test_v3`]
174#[derive(Clone, Debug, Default)]
175pub struct SpotCreateOrderTestV3Params {
176    pub side: String,
177    pub symbol: String,
178    pub timestamp: i64,
179    pub r#type: String,
180    pub compute_commission_rates: Option<bool>,
181    pub iceberg_qty: Option<String>,
182    pub new_client_order_id: Option<String>,
183    pub new_order_resp_type: Option<String>,
184    pub price: Option<String>,
185    pub quantity: Option<String>,
186    pub quote_order_qty: Option<String>,
187    pub recv_window: Option<i64>,
188    pub self_trade_prevention_mode: Option<String>,
189    pub stop_price: Option<String>,
190    pub strategy_id: Option<i64>,
191    pub strategy_type: Option<i32>,
192    pub time_in_force: Option<String>,
193    pub trailing_delta: Option<i64>
194}
195
196/// struct for passing parameters to the method [`spot_create_order_v3`]
197#[derive(Clone, Debug, Default)]
198pub struct SpotCreateOrderV3Params {
199    pub side: String,
200    pub symbol: String,
201    pub timestamp: i64,
202    pub r#type: String,
203    pub iceberg_qty: Option<String>,
204    pub new_client_order_id: Option<String>,
205    pub new_order_resp_type: Option<String>,
206    pub price: Option<String>,
207    pub quantity: Option<String>,
208    pub quote_order_qty: Option<String>,
209    pub recv_window: Option<i64>,
210    pub self_trade_prevention_mode: Option<String>,
211    pub stop_price: Option<String>,
212    pub strategy_id: Option<i64>,
213    pub strategy_type: Option<i32>,
214    pub time_in_force: Option<String>,
215    pub trailing_delta: Option<i64>
216}
217
218/// struct for passing parameters to the method [`spot_create_sor_order_test_v3`]
219#[derive(Clone, Debug, Default)]
220pub struct SpotCreateSorOrderTestV3Params {
221    pub quantity: String,
222    pub side: String,
223    pub symbol: String,
224    pub timestamp: i64,
225    pub r#type: String,
226    pub compute_commission_rates: Option<bool>,
227    pub iceberg_qty: Option<String>,
228    pub new_client_order_id: Option<String>,
229    pub new_order_resp_type: Option<String>,
230    pub price: Option<String>,
231    pub recv_window: Option<i64>,
232    pub self_trade_prevention_mode: Option<String>,
233    pub strategy_id: Option<i64>,
234    pub strategy_type: Option<i32>,
235    pub time_in_force: Option<String>
236}
237
238/// struct for passing parameters to the method [`spot_create_sor_order_v3`]
239#[derive(Clone, Debug, Default)]
240pub struct SpotCreateSorOrderV3Params {
241    pub quantity: String,
242    pub side: String,
243    pub symbol: String,
244    pub timestamp: i64,
245    pub r#type: String,
246    pub iceberg_qty: Option<String>,
247    pub new_client_order_id: Option<String>,
248    pub new_order_resp_type: Option<String>,
249    pub price: Option<String>,
250    pub recv_window: Option<i64>,
251    pub self_trade_prevention_mode: Option<String>,
252    pub strategy_id: Option<i64>,
253    pub strategy_type: Option<i32>,
254    pub time_in_force: Option<String>
255}
256
257/// struct for passing parameters to the method [`spot_delete_open_orders_v3`]
258#[derive(Clone, Debug, Default)]
259pub struct SpotDeleteOpenOrdersV3Params {
260    pub symbol: String,
261    pub timestamp: i64,
262    /// The value cannot be greater than `60000`
263    pub recv_window: Option<i64>
264}
265
266/// struct for passing parameters to the method [`spot_delete_order_list_v3`]
267#[derive(Clone, Debug, Default)]
268pub struct SpotDeleteOrderListV3Params {
269    pub symbol: String,
270    pub timestamp: i64,
271    /// Either `orderListId` or `listClientOrderId` must be provided
272    pub order_list_id: Option<i64>,
273    /// Either `orderListId` or `listClientOrderId` must be provided
274    pub list_client_order_id: Option<String>,
275    /// Used to uniquely identify this cancel. Automatically generated by default
276    pub new_client_order_id: Option<String>,
277    /// The value cannot be greater than `60000`
278    pub recv_window: Option<i64>
279}
280
281/// struct for passing parameters to the method [`spot_delete_order_v3`]
282#[derive(Clone, Debug, Default)]
283pub struct SpotDeleteOrderV3Params {
284    pub symbol: String,
285    pub timestamp: i64,
286    pub order_id: Option<i64>,
287    pub orig_client_order_id: Option<String>,
288    /// Used to uniquely identify this cancel. Automatically generated by default.
289    pub new_client_order_id: Option<String>,
290    /// Supported values: <br/>`ONLY_NEW` - Cancel will succeed if the order status is `NEW`.<br/> `ONLY_PARTIALLY_FILLED ` - Cancel will succeed if order status is `PARTIALLY_FILLED`.
291    pub cancel_restrictions: Option<String>,
292    /// The value cannot be greater than `60000`.
293    pub recv_window: Option<i64>
294}
295
296/// struct for passing parameters to the method [`spot_get_all_order_list_v3`]
297#[derive(Clone, Debug, Default)]
298pub struct SpotGetAllOrderListV3Params {
299    pub timestamp: i64,
300    /// If supplied, neither `startTime` or `endTime` can be provided
301    pub from_id: Option<i64>,
302    pub start_time: Option<i64>,
303    pub end_time: Option<i64>,
304    /// Default Value: 500; Max Value: 1000
305    pub limit: Option<i32>,
306    /// The value cannot be greater than `60000`
307    pub recv_window: Option<i64>
308}
309
310/// struct for passing parameters to the method [`spot_get_all_orders_v3`]
311#[derive(Clone, Debug, Default)]
312pub struct SpotGetAllOrdersV3Params {
313    pub symbol: String,
314    pub timestamp: i64,
315    pub order_id: Option<i64>,
316    pub start_time: Option<i64>,
317    pub end_time: Option<i64>,
318    /// Default 500; max 1000.
319    pub limit: Option<i32>,
320    /// The value cannot be greater than `60000`
321    pub recv_window: Option<i64>
322}
323
324/// struct for passing parameters to the method [`spot_get_open_order_list_v3`]
325#[derive(Clone, Debug, Default)]
326pub struct SpotGetOpenOrderListV3Params {
327    pub timestamp: i64,
328    /// The value cannot be greater than `60000`
329    pub recv_window: Option<i64>
330}
331
332/// struct for passing parameters to the method [`spot_get_open_orders_v3`]
333#[derive(Clone, Debug, Default)]
334pub struct SpotGetOpenOrdersV3Params {
335    pub timestamp: i64,
336    pub symbol: Option<String>,
337    /// The value cannot be greater than `60000`
338    pub recv_window: Option<i64>
339}
340
341/// struct for passing parameters to the method [`spot_get_order_list_v3`]
342#[derive(Clone, Debug, Default)]
343pub struct SpotGetOrderListV3Params {
344    pub timestamp: i64,
345    /// Either `orderListId` or `listClientOrderId` must be provided
346    pub order_list_id: Option<i64>,
347    /// Either `orderListId` or `listClientOrderId` must be provided
348    pub orig_client_order_id: Option<String>,
349    /// The value cannot be greater than `60000`
350    pub recv_window: Option<i64>
351}
352
353/// struct for passing parameters to the method [`spot_get_order_v3`]
354#[derive(Clone, Debug, Default)]
355pub struct SpotGetOrderV3Params {
356    pub symbol: String,
357    pub timestamp: i64,
358    pub order_id: Option<i64>,
359    pub orig_client_order_id: Option<String>,
360    /// The value cannot be greater than `60000`
361    pub recv_window: Option<i64>
362}
363
364
365/// struct for typed errors of method [`spot_create_order_cancel_replace_v3`]
366#[derive(Debug, Clone, Serialize, Deserialize)]
367#[serde(untagged)]
368pub enum SpotCreateOrderCancelReplaceV3Error {
369    Status4XX(models::ApiError),
370    Status5XX(models::ApiError),
371    UnknownValue(serde_json::Value),
372}
373
374/// struct for typed errors of method [`spot_create_order_list_oco_v3`]
375#[derive(Debug, Clone, Serialize, Deserialize)]
376#[serde(untagged)]
377pub enum SpotCreateOrderListOcoV3Error {
378    Status4XX(models::ApiError),
379    Status5XX(models::ApiError),
380    UnknownValue(serde_json::Value),
381}
382
383/// struct for typed errors of method [`spot_create_order_list_oto_v3`]
384#[derive(Debug, Clone, Serialize, Deserialize)]
385#[serde(untagged)]
386pub enum SpotCreateOrderListOtoV3Error {
387    Status4XX(models::ApiError),
388    Status5XX(models::ApiError),
389    UnknownValue(serde_json::Value),
390}
391
392/// struct for typed errors of method [`spot_create_order_list_otoco_v3`]
393#[derive(Debug, Clone, Serialize, Deserialize)]
394#[serde(untagged)]
395pub enum SpotCreateOrderListOtocoV3Error {
396    Status4XX(models::ApiError),
397    Status5XX(models::ApiError),
398    UnknownValue(serde_json::Value),
399}
400
401/// struct for typed errors of method [`spot_create_order_oco_v3`]
402#[derive(Debug, Clone, Serialize, Deserialize)]
403#[serde(untagged)]
404pub enum SpotCreateOrderOcoV3Error {
405    Status4XX(models::ApiError),
406    Status5XX(models::ApiError),
407    UnknownValue(serde_json::Value),
408}
409
410/// struct for typed errors of method [`spot_create_order_test_v3`]
411#[derive(Debug, Clone, Serialize, Deserialize)]
412#[serde(untagged)]
413pub enum SpotCreateOrderTestV3Error {
414    Status4XX(models::ApiError),
415    Status5XX(models::ApiError),
416    UnknownValue(serde_json::Value),
417}
418
419/// struct for typed errors of method [`spot_create_order_v3`]
420#[derive(Debug, Clone, Serialize, Deserialize)]
421#[serde(untagged)]
422pub enum SpotCreateOrderV3Error {
423    Status4XX(models::ApiError),
424    Status5XX(models::ApiError),
425    UnknownValue(serde_json::Value),
426}
427
428/// struct for typed errors of method [`spot_create_sor_order_test_v3`]
429#[derive(Debug, Clone, Serialize, Deserialize)]
430#[serde(untagged)]
431pub enum SpotCreateSorOrderTestV3Error {
432    Status4XX(models::ApiError),
433    Status5XX(models::ApiError),
434    UnknownValue(serde_json::Value),
435}
436
437/// struct for typed errors of method [`spot_create_sor_order_v3`]
438#[derive(Debug, Clone, Serialize, Deserialize)]
439#[serde(untagged)]
440pub enum SpotCreateSorOrderV3Error {
441    Status4XX(models::ApiError),
442    Status5XX(models::ApiError),
443    UnknownValue(serde_json::Value),
444}
445
446/// struct for typed errors of method [`spot_delete_open_orders_v3`]
447#[derive(Debug, Clone, Serialize, Deserialize)]
448#[serde(untagged)]
449pub enum SpotDeleteOpenOrdersV3Error {
450    Status4XX(models::ApiError),
451    Status5XX(models::ApiError),
452    UnknownValue(serde_json::Value),
453}
454
455/// struct for typed errors of method [`spot_delete_order_list_v3`]
456#[derive(Debug, Clone, Serialize, Deserialize)]
457#[serde(untagged)]
458pub enum SpotDeleteOrderListV3Error {
459    Status4XX(models::ApiError),
460    Status5XX(models::ApiError),
461    UnknownValue(serde_json::Value),
462}
463
464/// struct for typed errors of method [`spot_delete_order_v3`]
465#[derive(Debug, Clone, Serialize, Deserialize)]
466#[serde(untagged)]
467pub enum SpotDeleteOrderV3Error {
468    Status4XX(models::ApiError),
469    Status5XX(models::ApiError),
470    UnknownValue(serde_json::Value),
471}
472
473/// struct for typed errors of method [`spot_get_all_order_list_v3`]
474#[derive(Debug, Clone, Serialize, Deserialize)]
475#[serde(untagged)]
476pub enum SpotGetAllOrderListV3Error {
477    Status4XX(models::ApiError),
478    Status5XX(models::ApiError),
479    UnknownValue(serde_json::Value),
480}
481
482/// struct for typed errors of method [`spot_get_all_orders_v3`]
483#[derive(Debug, Clone, Serialize, Deserialize)]
484#[serde(untagged)]
485pub enum SpotGetAllOrdersV3Error {
486    Status4XX(models::ApiError),
487    Status5XX(models::ApiError),
488    UnknownValue(serde_json::Value),
489}
490
491/// struct for typed errors of method [`spot_get_open_order_list_v3`]
492#[derive(Debug, Clone, Serialize, Deserialize)]
493#[serde(untagged)]
494pub enum SpotGetOpenOrderListV3Error {
495    Status4XX(models::ApiError),
496    Status5XX(models::ApiError),
497    UnknownValue(serde_json::Value),
498}
499
500/// struct for typed errors of method [`spot_get_open_orders_v3`]
501#[derive(Debug, Clone, Serialize, Deserialize)]
502#[serde(untagged)]
503pub enum SpotGetOpenOrdersV3Error {
504    Status4XX(models::ApiError),
505    Status5XX(models::ApiError),
506    UnknownValue(serde_json::Value),
507}
508
509/// struct for typed errors of method [`spot_get_order_list_v3`]
510#[derive(Debug, Clone, Serialize, Deserialize)]
511#[serde(untagged)]
512pub enum SpotGetOrderListV3Error {
513    Status4XX(models::ApiError),
514    Status5XX(models::ApiError),
515    UnknownValue(serde_json::Value),
516}
517
518/// struct for typed errors of method [`spot_get_order_v3`]
519#[derive(Debug, Clone, Serialize, Deserialize)]
520#[serde(untagged)]
521pub enum SpotGetOrderV3Error {
522    Status4XX(models::ApiError),
523    Status5XX(models::ApiError),
524    UnknownValue(serde_json::Value),
525}
526
527
528/// Cancels an existing order and places a new order on the same symbol. Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs. A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED ), will still increase the order count by 1.
529pub async fn spot_create_order_cancel_replace_v3(configuration: &configuration::Configuration, params: SpotCreateOrderCancelReplaceV3Params) -> Result<models::SpotCreateOrderCancelReplaceV3Resp, Error<SpotCreateOrderCancelReplaceV3Error>> {
530
531    let uri_str = format!("{}/api/v3/order/cancelReplace", configuration.base_path);
532    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
533
534    // Create a mutable vector for query parameters
535    let mut query_params: Vec<(String, String)> = Vec::new();
536
537
538    // Create header parameters collection
539    let mut header_params = std::collections::HashMap::new();
540
541    // Handle Binance Auth first if configured
542    if let Some(ref binance_auth) = configuration.binance_auth {
543        // Add API key to headers
544        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
545        
546        // Generate request body for signing (if any)
547        let body_string: Option<Vec<u8>> = None;
548        
549        // Sign the request
550        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
551            Ok(sig) => sig,
552            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
553        };
554        
555        // Add signature to query params
556        query_params.push(("signature".to_string(), signature));
557    }
558
559    // Apply all query parameters
560    if !query_params.is_empty() {
561        req_builder = req_builder.query(&query_params);
562    }
563
564
565    // Add user agent if configured
566    if let Some(ref user_agent) = configuration.user_agent {
567        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
568    }
569
570    // Apply all header parameters
571    for (header_name, header_value) in header_params {
572        req_builder = req_builder.header(&header_name, &header_value);
573    }
574
575    let mut multipart_form_params = std::collections::HashMap::new();
576    if let Some(param_value) = params.cancel_new_client_order_id {
577        multipart_form_params.insert("cancelNewClientOrderId", param_value.to_string());
578    }
579    if let Some(param_value) = params.cancel_order_id {
580        multipart_form_params.insert("cancelOrderId", param_value.to_string());
581    }
582    if let Some(param_value) = params.cancel_orig_client_order_id {
583        multipart_form_params.insert("cancelOrigClientOrderId", param_value.to_string());
584    }
585    multipart_form_params.insert("cancelReplaceMode", params.cancel_replace_mode.to_string());
586    if let Some(param_value) = params.cancel_restrictions {
587        multipart_form_params.insert("cancelRestrictions", param_value.to_string());
588    }
589    if let Some(param_value) = params.iceberg_qty {
590        multipart_form_params.insert("icebergQty", param_value.to_string());
591    }
592    if let Some(param_value) = params.new_client_order_id {
593        multipart_form_params.insert("newClientOrderId", param_value.to_string());
594    }
595    if let Some(param_value) = params.new_order_resp_type {
596        multipart_form_params.insert("newOrderRespType", param_value.to_string());
597    }
598    if let Some(param_value) = params.order_rate_limit_exceeded_mode {
599        multipart_form_params.insert("orderRateLimitExceededMode", param_value.to_string());
600    }
601    if let Some(param_value) = params.price {
602        multipart_form_params.insert("price", param_value.to_string());
603    }
604    if let Some(param_value) = params.quantity {
605        multipart_form_params.insert("quantity", param_value.to_string());
606    }
607    if let Some(param_value) = params.quote_order_qty {
608        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
609    }
610    if let Some(param_value) = params.recv_window {
611        multipart_form_params.insert("recvWindow", param_value.to_string());
612    }
613    if let Some(param_value) = params.self_trade_prevention_mode {
614        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
615    }
616    multipart_form_params.insert("side", params.side.to_string());
617    if let Some(param_value) = params.stop_price {
618        multipart_form_params.insert("stopPrice", param_value.to_string());
619    }
620    if let Some(param_value) = params.strategy_id {
621        multipart_form_params.insert("strategyId", param_value.to_string());
622    }
623    if let Some(param_value) = params.strategy_type {
624        multipart_form_params.insert("strategyType", param_value.to_string());
625    }
626    multipart_form_params.insert("symbol", params.symbol.to_string());
627    if let Some(param_value) = params.time_in_force {
628        multipart_form_params.insert("timeInForce", param_value.to_string());
629    }
630    multipart_form_params.insert("timestamp", params.timestamp.to_string());
631    if let Some(param_value) = params.trailing_delta {
632        multipart_form_params.insert("trailingDelta", param_value.to_string());
633    }
634    multipart_form_params.insert("type", params.r#type.to_string());
635    req_builder = req_builder.form(&multipart_form_params);
636
637    let req = req_builder.build()?;
638    let resp = configuration.client.execute(req).await?;
639
640    let status = resp.status();
641    let content_type = resp
642        .headers()
643        .get("content-type")
644        .and_then(|v| v.to_str().ok())
645        .unwrap_or("application/octet-stream");
646    let content_type = super::ContentType::from(content_type);
647
648    if !status.is_client_error() && !status.is_server_error() {
649        let content = resp.text().await?;
650        match content_type {
651            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
652            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderCancelReplaceV3Resp`"))),
653            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderCancelReplaceV3Resp`")))),
654        }
655    } else {
656        let content = resp.text().await?;
657        let entity: Option<SpotCreateOrderCancelReplaceV3Error> = serde_json::from_str(&content).ok();
658        Err(Error::ResponseError(ResponseContent { status, content, entity }))
659    }
660}
661
662/// Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other. - An OCO has 2 orders called the above order and below order. - One of the orders must be a LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT order and the other must be STOP_LOSS or STOP_LOSS_LIMIT order. - Price restrictions  If the OCO is on the SELL side:  LIMIT_MAKER/TAKE_PROFIT_LIMIT price > Last Traded Price >  STOP_LOSS/STOP_LOSS_LIMIT stopPrice TAKE_PROFIT stopPrice > Last Traded Price > STOP_LOSS/STOP_LOSS_LIMIT stopPrice   If the OCO is on the BUY side:  LIMIT_MAKER/TAKE_PROFIT_LIMIT price < Last Traded Price < stopPrice TAKE_PROFIT stopPrice < Last Traded Price < STOP_LOSS/STOP_LOSS_LIMIT stopPrice - OCOs add 2 orders to the unfilled order count, EXCHANGE_MAX_ORDERS filter, and the MAX_NUM_ORDERS filter.
663pub async fn spot_create_order_list_oco_v3(configuration: &configuration::Configuration, params: SpotCreateOrderListOcoV3Params) -> Result<models::SpotCreateOrderListOcoV3Resp, Error<SpotCreateOrderListOcoV3Error>> {
664
665    let uri_str = format!("{}/api/v3/orderList/oco", configuration.base_path);
666    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
667
668    // Create a mutable vector for query parameters
669    let mut query_params: Vec<(String, String)> = Vec::new();
670
671
672    // Create header parameters collection
673    let mut header_params = std::collections::HashMap::new();
674
675    // Handle Binance Auth first if configured
676    if let Some(ref binance_auth) = configuration.binance_auth {
677        // Add API key to headers
678        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
679        
680        // Generate request body for signing (if any)
681        let body_string: Option<Vec<u8>> = None;
682        
683        // Sign the request
684        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
685            Ok(sig) => sig,
686            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
687        };
688        
689        // Add signature to query params
690        query_params.push(("signature".to_string(), signature));
691    }
692
693    // Apply all query parameters
694    if !query_params.is_empty() {
695        req_builder = req_builder.query(&query_params);
696    }
697
698
699    // Add user agent if configured
700    if let Some(ref user_agent) = configuration.user_agent {
701        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
702    }
703
704    // Apply all header parameters
705    for (header_name, header_value) in header_params {
706        req_builder = req_builder.header(&header_name, &header_value);
707    }
708
709    let mut multipart_form_params = std::collections::HashMap::new();
710    if let Some(param_value) = params.above_client_order_id {
711        multipart_form_params.insert("aboveClientOrderId", param_value.to_string());
712    }
713    if let Some(param_value) = params.above_iceberg_qty {
714        multipart_form_params.insert("aboveIcebergQty", param_value.to_string());
715    }
716    if let Some(param_value) = params.above_price {
717        multipart_form_params.insert("abovePrice", param_value.to_string());
718    }
719    if let Some(param_value) = params.above_stop_price {
720        multipart_form_params.insert("aboveStopPrice", param_value.to_string());
721    }
722    if let Some(param_value) = params.above_strategy_id {
723        multipart_form_params.insert("aboveStrategyId", param_value.to_string());
724    }
725    if let Some(param_value) = params.above_strategy_type {
726        multipart_form_params.insert("aboveStrategyType", param_value.to_string());
727    }
728    if let Some(param_value) = params.above_time_in_force {
729        multipart_form_params.insert("aboveTimeInForce", param_value.to_string());
730    }
731    if let Some(param_value) = params.above_trailing_delta {
732        multipart_form_params.insert("aboveTrailingDelta", param_value.to_string());
733    }
734    multipart_form_params.insert("aboveType", params.above_type.to_string());
735    if let Some(param_value) = params.below_client_order_id {
736        multipart_form_params.insert("belowClientOrderId", param_value.to_string());
737    }
738    if let Some(param_value) = params.below_iceberg_qty {
739        multipart_form_params.insert("belowIcebergQty", param_value.to_string());
740    }
741    if let Some(param_value) = params.below_price {
742        multipart_form_params.insert("belowPrice", param_value.to_string());
743    }
744    if let Some(param_value) = params.below_stop_price {
745        multipart_form_params.insert("belowStopPrice", param_value.to_string());
746    }
747    if let Some(param_value) = params.below_strategy_id {
748        multipart_form_params.insert("belowStrategyId", param_value.to_string());
749    }
750    if let Some(param_value) = params.below_strategy_type {
751        multipart_form_params.insert("belowStrategyType", param_value.to_string());
752    }
753    if let Some(param_value) = params.below_time_in_force {
754        multipart_form_params.insert("belowTimeInForce", param_value.to_string());
755    }
756    if let Some(param_value) = params.below_trailing_delta {
757        multipart_form_params.insert("belowTrailingDelta", param_value.to_string());
758    }
759    multipart_form_params.insert("belowType", params.below_type.to_string());
760    if let Some(param_value) = params.list_client_order_id {
761        multipart_form_params.insert("listClientOrderId", param_value.to_string());
762    }
763    if let Some(param_value) = params.new_order_resp_type {
764        multipart_form_params.insert("newOrderRespType", param_value.to_string());
765    }
766    multipart_form_params.insert("quantity", params.quantity.to_string());
767    if let Some(param_value) = params.recv_window {
768        multipart_form_params.insert("recvWindow", param_value.to_string());
769    }
770    if let Some(param_value) = params.self_trade_prevention_mode {
771        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
772    }
773    multipart_form_params.insert("side", params.side.to_string());
774    multipart_form_params.insert("symbol", params.symbol.to_string());
775    multipart_form_params.insert("timestamp", params.timestamp.to_string());
776    req_builder = req_builder.form(&multipart_form_params);
777
778    let req = req_builder.build()?;
779    let resp = configuration.client.execute(req).await?;
780
781    let status = resp.status();
782    let content_type = resp
783        .headers()
784        .get("content-type")
785        .and_then(|v| v.to_str().ok())
786        .unwrap_or("application/octet-stream");
787    let content_type = super::ContentType::from(content_type);
788
789    if !status.is_client_error() && !status.is_server_error() {
790        let content = resp.text().await?;
791        match content_type {
792            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
793            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderListOcoV3Resp`"))),
794            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderListOcoV3Resp`")))),
795        }
796    } else {
797        let content = resp.text().await?;
798        let entity: Option<SpotCreateOrderListOcoV3Error> = serde_json::from_str(&content).ok();
799        Err(Error::ResponseError(ResponseContent { status, content, entity }))
800    }
801}
802
803/// Places an OTO. - An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders. - The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book. - The second order is called the pending order. It can be any order type except for MARKET orders using parameter quoteOrderQty. The pending order is only placed on the order book when the working order gets fully filled. - If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired. - When the order list is placed, if the working order gets immediately fully filled, the placement response will show the working order as FILLED but the pending order will still appear as PENDING_NEW. You need to query the status of the pending order again to see its updated status. - OTOs add 2 orders to the unfilled order count, EXCHANGE_MAX_NUM_ORDERS filter and MAX_NUM_ORDERS filter.
804pub async fn spot_create_order_list_oto_v3(configuration: &configuration::Configuration, params: SpotCreateOrderListOtoV3Params) -> Result<models::SpotCreateOrderListOtoV3Resp, Error<SpotCreateOrderListOtoV3Error>> {
805
806    let uri_str = format!("{}/api/v3/orderList/oto", configuration.base_path);
807    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
808
809    // Create a mutable vector for query parameters
810    let mut query_params: Vec<(String, String)> = Vec::new();
811
812
813    // Create header parameters collection
814    let mut header_params = std::collections::HashMap::new();
815
816    // Handle Binance Auth first if configured
817    if let Some(ref binance_auth) = configuration.binance_auth {
818        // Add API key to headers
819        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
820        
821        // Generate request body for signing (if any)
822        let body_string: Option<Vec<u8>> = None;
823        
824        // Sign the request
825        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
826            Ok(sig) => sig,
827            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
828        };
829        
830        // Add signature to query params
831        query_params.push(("signature".to_string(), signature));
832    }
833
834    // Apply all query parameters
835    if !query_params.is_empty() {
836        req_builder = req_builder.query(&query_params);
837    }
838
839
840    // Add user agent if configured
841    if let Some(ref user_agent) = configuration.user_agent {
842        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
843    }
844
845    // Apply all header parameters
846    for (header_name, header_value) in header_params {
847        req_builder = req_builder.header(&header_name, &header_value);
848    }
849
850    let mut multipart_form_params = std::collections::HashMap::new();
851    if let Some(param_value) = params.list_client_order_id {
852        multipart_form_params.insert("listClientOrderId", param_value.to_string());
853    }
854    if let Some(param_value) = params.new_order_resp_type {
855        multipart_form_params.insert("newOrderRespType", param_value.to_string());
856    }
857    if let Some(param_value) = params.pending_client_order_id {
858        multipart_form_params.insert("pendingClientOrderId", param_value.to_string());
859    }
860    if let Some(param_value) = params.pending_iceberg_qty {
861        multipart_form_params.insert("pendingIcebergQty", param_value.to_string());
862    }
863    if let Some(param_value) = params.pending_price {
864        multipart_form_params.insert("pendingPrice", param_value.to_string());
865    }
866    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
867    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
868    if let Some(param_value) = params.pending_stop_price {
869        multipart_form_params.insert("pendingStopPrice", param_value.to_string());
870    }
871    if let Some(param_value) = params.pending_strategy_id {
872        multipart_form_params.insert("pendingStrategyId", param_value.to_string());
873    }
874    if let Some(param_value) = params.pending_strategy_type {
875        multipart_form_params.insert("pendingStrategyType", param_value.to_string());
876    }
877    if let Some(param_value) = params.pending_time_in_force {
878        multipart_form_params.insert("pendingTimeInForce", param_value.to_string());
879    }
880    if let Some(param_value) = params.pending_trailing_delta {
881        multipart_form_params.insert("pendingTrailingDelta", param_value.to_string());
882    }
883    multipart_form_params.insert("pendingType", params.pending_type.to_string());
884    if let Some(param_value) = params.recv_window {
885        multipart_form_params.insert("recvWindow", param_value.to_string());
886    }
887    if let Some(param_value) = params.self_trade_prevention_mode {
888        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
889    }
890    multipart_form_params.insert("symbol", params.symbol.to_string());
891    multipart_form_params.insert("timestamp", params.timestamp.to_string());
892    if let Some(param_value) = params.working_client_order_id {
893        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
894    }
895    if let Some(param_value) = params.working_iceberg_qty {
896        multipart_form_params.insert("workingIcebergQty", param_value.to_string());
897    }
898    multipart_form_params.insert("workingPrice", params.working_price.to_string());
899    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
900    multipart_form_params.insert("workingSide", params.working_side.to_string());
901    if let Some(param_value) = params.working_strategy_id {
902        multipart_form_params.insert("workingStrategyId", param_value.to_string());
903    }
904    if let Some(param_value) = params.working_strategy_type {
905        multipart_form_params.insert("workingStrategyType", param_value.to_string());
906    }
907    if let Some(param_value) = params.working_time_in_force {
908        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
909    }
910    multipart_form_params.insert("workingType", params.working_type.to_string());
911    req_builder = req_builder.form(&multipart_form_params);
912
913    let req = req_builder.build()?;
914    let resp = configuration.client.execute(req).await?;
915
916    let status = resp.status();
917    let content_type = resp
918        .headers()
919        .get("content-type")
920        .and_then(|v| v.to_str().ok())
921        .unwrap_or("application/octet-stream");
922    let content_type = super::ContentType::from(content_type);
923
924    if !status.is_client_error() && !status.is_server_error() {
925        let content = resp.text().await?;
926        match content_type {
927            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
928            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderListOtoV3Resp`"))),
929            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderListOtoV3Resp`")))),
930        }
931    } else {
932        let content = resp.text().await?;
933        let entity: Option<SpotCreateOrderListOtoV3Error> = serde_json::from_str(&content).ok();
934        Err(Error::ResponseError(ResponseContent { status, content, entity }))
935    }
936}
937
938/// Place an OTOCO. - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders. - The first order is called the working order and must be LIMIT or LIMIT_MAKER. Initially, only the working order goes on the order book.  The behavior of the working order is the same as the OTO. - OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets fully filled.  The rules of the pending above and pending below follow the same rules as the Order list OCO. - OTOCOs add 3 orders against the unfilled order count, EXCHANGE_MAX_NUM_ORDERS filter, and MAX_NUM_ORDERS filter.
939pub async fn spot_create_order_list_otoco_v3(configuration: &configuration::Configuration, params: SpotCreateOrderListOtocoV3Params) -> Result<models::SpotCreateOrderListOtocoV3Resp, Error<SpotCreateOrderListOtocoV3Error>> {
940
941    let uri_str = format!("{}/api/v3/orderList/otoco", configuration.base_path);
942    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
943
944    // Create a mutable vector for query parameters
945    let mut query_params: Vec<(String, String)> = Vec::new();
946
947
948    // Create header parameters collection
949    let mut header_params = std::collections::HashMap::new();
950
951    // Handle Binance Auth first if configured
952    if let Some(ref binance_auth) = configuration.binance_auth {
953        // Add API key to headers
954        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
955        
956        // Generate request body for signing (if any)
957        let body_string: Option<Vec<u8>> = None;
958        
959        // Sign the request
960        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
961            Ok(sig) => sig,
962            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
963        };
964        
965        // Add signature to query params
966        query_params.push(("signature".to_string(), signature));
967    }
968
969    // Apply all query parameters
970    if !query_params.is_empty() {
971        req_builder = req_builder.query(&query_params);
972    }
973
974
975    // Add user agent if configured
976    if let Some(ref user_agent) = configuration.user_agent {
977        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
978    }
979
980    // Apply all header parameters
981    for (header_name, header_value) in header_params {
982        req_builder = req_builder.header(&header_name, &header_value);
983    }
984
985    let mut multipart_form_params = std::collections::HashMap::new();
986    if let Some(param_value) = params.list_client_order_id {
987        multipart_form_params.insert("listClientOrderId", param_value.to_string());
988    }
989    if let Some(param_value) = params.new_order_resp_type {
990        multipart_form_params.insert("newOrderRespType", param_value.to_string());
991    }
992    if let Some(param_value) = params.pending_above_client_order_id {
993        multipart_form_params.insert("pendingAboveClientOrderId", param_value.to_string());
994    }
995    if let Some(param_value) = params.pending_above_iceberg_qty {
996        multipart_form_params.insert("pendingAboveIcebergQty", param_value.to_string());
997    }
998    if let Some(param_value) = params.pending_above_price {
999        multipart_form_params.insert("pendingAbovePrice", param_value.to_string());
1000    }
1001    if let Some(param_value) = params.pending_above_stop_price {
1002        multipart_form_params.insert("pendingAboveStopPrice", param_value.to_string());
1003    }
1004    if let Some(param_value) = params.pending_above_strategy_id {
1005        multipart_form_params.insert("pendingAboveStrategyId", param_value.to_string());
1006    }
1007    if let Some(param_value) = params.pending_above_strategy_type {
1008        multipart_form_params.insert("pendingAboveStrategyType", param_value.to_string());
1009    }
1010    if let Some(param_value) = params.pending_above_time_in_force {
1011        multipart_form_params.insert("pendingAboveTimeInForce", param_value.to_string());
1012    }
1013    if let Some(param_value) = params.pending_above_trailing_delta {
1014        multipart_form_params.insert("pendingAboveTrailingDelta", param_value.to_string());
1015    }
1016    multipart_form_params.insert("pendingAboveType", params.pending_above_type.to_string());
1017    if let Some(param_value) = params.pending_below_client_order_id {
1018        multipart_form_params.insert("pendingBelowClientOrderId", param_value.to_string());
1019    }
1020    if let Some(param_value) = params.pending_below_iceberg_qty {
1021        multipart_form_params.insert("pendingBelowIcebergQty", param_value.to_string());
1022    }
1023    if let Some(param_value) = params.pending_below_price {
1024        multipart_form_params.insert("pendingBelowPrice", param_value.to_string());
1025    }
1026    if let Some(param_value) = params.pending_below_stop_price {
1027        multipart_form_params.insert("pendingBelowStopPrice", param_value.to_string());
1028    }
1029    if let Some(param_value) = params.pending_below_strategy_id {
1030        multipart_form_params.insert("pendingBelowStrategyId", param_value.to_string());
1031    }
1032    if let Some(param_value) = params.pending_below_strategy_type {
1033        multipart_form_params.insert("pendingBelowStrategyType", param_value.to_string());
1034    }
1035    if let Some(param_value) = params.pending_below_time_in_force {
1036        multipart_form_params.insert("pendingBelowTimeInForce", param_value.to_string());
1037    }
1038    if let Some(param_value) = params.pending_below_trailing_delta {
1039        multipart_form_params.insert("pendingBelowTrailingDelta", param_value.to_string());
1040    }
1041    if let Some(param_value) = params.pending_below_type {
1042        multipart_form_params.insert("pendingBelowType", param_value.to_string());
1043    }
1044    multipart_form_params.insert("pendingQuantity", params.pending_quantity.to_string());
1045    multipart_form_params.insert("pendingSide", params.pending_side.to_string());
1046    if let Some(param_value) = params.recv_window {
1047        multipart_form_params.insert("recvWindow", param_value.to_string());
1048    }
1049    if let Some(param_value) = params.self_trade_prevention_mode {
1050        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1051    }
1052    multipart_form_params.insert("symbol", params.symbol.to_string());
1053    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1054    if let Some(param_value) = params.working_client_order_id {
1055        multipart_form_params.insert("workingClientOrderId", param_value.to_string());
1056    }
1057    if let Some(param_value) = params.working_iceberg_qty {
1058        multipart_form_params.insert("workingIcebergQty", param_value.to_string());
1059    }
1060    multipart_form_params.insert("workingPrice", params.working_price.to_string());
1061    multipart_form_params.insert("workingQuantity", params.working_quantity.to_string());
1062    multipart_form_params.insert("workingSide", params.working_side.to_string());
1063    if let Some(param_value) = params.working_strategy_id {
1064        multipart_form_params.insert("workingStrategyId", param_value.to_string());
1065    }
1066    if let Some(param_value) = params.working_strategy_type {
1067        multipart_form_params.insert("workingStrategyType", param_value.to_string());
1068    }
1069    if let Some(param_value) = params.working_time_in_force {
1070        multipart_form_params.insert("workingTimeInForce", param_value.to_string());
1071    }
1072    multipart_form_params.insert("workingType", params.working_type.to_string());
1073    req_builder = req_builder.form(&multipart_form_params);
1074
1075    let req = req_builder.build()?;
1076    let resp = configuration.client.execute(req).await?;
1077
1078    let status = resp.status();
1079    let content_type = resp
1080        .headers()
1081        .get("content-type")
1082        .and_then(|v| v.to_str().ok())
1083        .unwrap_or("application/octet-stream");
1084    let content_type = super::ContentType::from(content_type);
1085
1086    if !status.is_client_error() && !status.is_server_error() {
1087        let content = resp.text().await?;
1088        match content_type {
1089            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1090            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderListOtocoV3Resp`"))),
1091            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderListOtocoV3Resp`")))),
1092        }
1093    } else {
1094        let content = resp.text().await?;
1095        let entity: Option<SpotCreateOrderListOtocoV3Error> = serde_json::from_str(&content).ok();
1096        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1097    }
1098}
1099
1100/// Send in a new OCO. - Price Restrictions:  SELL: Limit Price > Last Price > Stop Price BUY: Limit Price < Last Price < Stop Price - Quantity Restrictions:  Both legs must have the same quantity. ICEBERG quantities however do not have to be the same - OCO adds 2 orders to the unfilled order count, EXCHANGE_MAX_ORDERS filter and the MAX_NUM_ORDERS filter.
1101pub async fn spot_create_order_oco_v3(configuration: &configuration::Configuration, params: SpotCreateOrderOcoV3Params) -> Result<models::SpotCreateOrderOcoV3Resp, Error<SpotCreateOrderOcoV3Error>> {
1102
1103    let uri_str = format!("{}/api/v3/order/oco", configuration.base_path);
1104    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1105
1106    // Create a mutable vector for query parameters
1107    let mut query_params: Vec<(String, String)> = Vec::new();
1108
1109
1110    // Create header parameters collection
1111    let mut header_params = std::collections::HashMap::new();
1112
1113    // Handle Binance Auth first if configured
1114    if let Some(ref binance_auth) = configuration.binance_auth {
1115        // Add API key to headers
1116        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1117        
1118        // Generate request body for signing (if any)
1119        let body_string: Option<Vec<u8>> = None;
1120        
1121        // Sign the request
1122        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1123            Ok(sig) => sig,
1124            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1125        };
1126        
1127        // Add signature to query params
1128        query_params.push(("signature".to_string(), signature));
1129    }
1130
1131    // Apply all query parameters
1132    if !query_params.is_empty() {
1133        req_builder = req_builder.query(&query_params);
1134    }
1135
1136
1137    // Add user agent if configured
1138    if let Some(ref user_agent) = configuration.user_agent {
1139        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1140    }
1141
1142    // Apply all header parameters
1143    for (header_name, header_value) in header_params {
1144        req_builder = req_builder.header(&header_name, &header_value);
1145    }
1146
1147    let mut multipart_form_params = std::collections::HashMap::new();
1148    if let Some(param_value) = params.limit_client_order_id {
1149        multipart_form_params.insert("limitClientOrderId", param_value.to_string());
1150    }
1151    if let Some(param_value) = params.limit_iceberg_qty {
1152        multipart_form_params.insert("limitIcebergQty", param_value.to_string());
1153    }
1154    if let Some(param_value) = params.limit_strategy_id {
1155        multipart_form_params.insert("limitStrategyId", param_value.to_string());
1156    }
1157    if let Some(param_value) = params.limit_strategy_type {
1158        multipart_form_params.insert("limitStrategyType", param_value.to_string());
1159    }
1160    if let Some(param_value) = params.list_client_order_id {
1161        multipart_form_params.insert("listClientOrderId", param_value.to_string());
1162    }
1163    if let Some(param_value) = params.new_order_resp_type {
1164        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1165    }
1166    multipart_form_params.insert("price", params.price.to_string());
1167    multipart_form_params.insert("quantity", params.quantity.to_string());
1168    if let Some(param_value) = params.recv_window {
1169        multipart_form_params.insert("recvWindow", param_value.to_string());
1170    }
1171    if let Some(param_value) = params.self_trade_prevention_mode {
1172        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1173    }
1174    multipart_form_params.insert("side", params.side.to_string());
1175    if let Some(param_value) = params.stop_client_order_id {
1176        multipart_form_params.insert("stopClientOrderId", param_value.to_string());
1177    }
1178    if let Some(param_value) = params.stop_iceberg_qty {
1179        multipart_form_params.insert("stopIcebergQty", param_value.to_string());
1180    }
1181    if let Some(param_value) = params.stop_limit_price {
1182        multipart_form_params.insert("stopLimitPrice", param_value.to_string());
1183    }
1184    if let Some(param_value) = params.stop_limit_time_in_force {
1185        multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
1186    }
1187    multipart_form_params.insert("stopPrice", params.stop_price.to_string());
1188    if let Some(param_value) = params.stop_strategy_id {
1189        multipart_form_params.insert("stopStrategyId", param_value.to_string());
1190    }
1191    if let Some(param_value) = params.stop_strategy_type {
1192        multipart_form_params.insert("stopStrategyType", param_value.to_string());
1193    }
1194    multipart_form_params.insert("symbol", params.symbol.to_string());
1195    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1196    if let Some(param_value) = params.trailing_delta {
1197        multipart_form_params.insert("trailingDelta", param_value.to_string());
1198    }
1199    req_builder = req_builder.form(&multipart_form_params);
1200
1201    let req = req_builder.build()?;
1202    let resp = configuration.client.execute(req).await?;
1203
1204    let status = resp.status();
1205    let content_type = resp
1206        .headers()
1207        .get("content-type")
1208        .and_then(|v| v.to_str().ok())
1209        .unwrap_or("application/octet-stream");
1210    let content_type = super::ContentType::from(content_type);
1211
1212    if !status.is_client_error() && !status.is_server_error() {
1213        let content = resp.text().await?;
1214        match content_type {
1215            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1216            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderOcoV3Resp`"))),
1217            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderOcoV3Resp`")))),
1218        }
1219    } else {
1220        let content = resp.text().await?;
1221        let entity: Option<SpotCreateOrderOcoV3Error> = serde_json::from_str(&content).ok();
1222        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1223    }
1224}
1225
1226/// Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
1227pub async fn spot_create_order_test_v3(configuration: &configuration::Configuration, params: SpotCreateOrderTestV3Params) -> Result<models::SpotCreateOrderTestV3Resp, Error<SpotCreateOrderTestV3Error>> {
1228
1229    let uri_str = format!("{}/api/v3/order/test", configuration.base_path);
1230    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1231
1232    // Create a mutable vector for query parameters
1233    let mut query_params: Vec<(String, String)> = Vec::new();
1234
1235
1236    // Create header parameters collection
1237    let mut header_params = std::collections::HashMap::new();
1238
1239    // Handle Binance Auth first if configured
1240    if let Some(ref binance_auth) = configuration.binance_auth {
1241        // Add API key to headers
1242        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1243        
1244        // Generate request body for signing (if any)
1245        let body_string: Option<Vec<u8>> = None;
1246        
1247        // Sign the request
1248        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1249            Ok(sig) => sig,
1250            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1251        };
1252        
1253        // Add signature to query params
1254        query_params.push(("signature".to_string(), signature));
1255    }
1256
1257    // Apply all query parameters
1258    if !query_params.is_empty() {
1259        req_builder = req_builder.query(&query_params);
1260    }
1261
1262
1263    // Add user agent if configured
1264    if let Some(ref user_agent) = configuration.user_agent {
1265        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1266    }
1267
1268    // Apply all header parameters
1269    for (header_name, header_value) in header_params {
1270        req_builder = req_builder.header(&header_name, &header_value);
1271    }
1272
1273    let mut multipart_form_params = std::collections::HashMap::new();
1274    if let Some(param_value) = params.compute_commission_rates {
1275        multipart_form_params.insert("computeCommissionRates", param_value.to_string());
1276    }
1277    if let Some(param_value) = params.iceberg_qty {
1278        multipart_form_params.insert("icebergQty", param_value.to_string());
1279    }
1280    if let Some(param_value) = params.new_client_order_id {
1281        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1282    }
1283    if let Some(param_value) = params.new_order_resp_type {
1284        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1285    }
1286    if let Some(param_value) = params.price {
1287        multipart_form_params.insert("price", param_value.to_string());
1288    }
1289    if let Some(param_value) = params.quantity {
1290        multipart_form_params.insert("quantity", param_value.to_string());
1291    }
1292    if let Some(param_value) = params.quote_order_qty {
1293        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1294    }
1295    if let Some(param_value) = params.recv_window {
1296        multipart_form_params.insert("recvWindow", param_value.to_string());
1297    }
1298    if let Some(param_value) = params.self_trade_prevention_mode {
1299        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1300    }
1301    multipart_form_params.insert("side", params.side.to_string());
1302    if let Some(param_value) = params.stop_price {
1303        multipart_form_params.insert("stopPrice", param_value.to_string());
1304    }
1305    if let Some(param_value) = params.strategy_id {
1306        multipart_form_params.insert("strategyId", param_value.to_string());
1307    }
1308    if let Some(param_value) = params.strategy_type {
1309        multipart_form_params.insert("strategyType", param_value.to_string());
1310    }
1311    multipart_form_params.insert("symbol", params.symbol.to_string());
1312    if let Some(param_value) = params.time_in_force {
1313        multipart_form_params.insert("timeInForce", param_value.to_string());
1314    }
1315    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1316    if let Some(param_value) = params.trailing_delta {
1317        multipart_form_params.insert("trailingDelta", param_value.to_string());
1318    }
1319    multipart_form_params.insert("type", params.r#type.to_string());
1320    req_builder = req_builder.form(&multipart_form_params);
1321
1322    let req = req_builder.build()?;
1323    let resp = configuration.client.execute(req).await?;
1324
1325    let status = resp.status();
1326    let content_type = resp
1327        .headers()
1328        .get("content-type")
1329        .and_then(|v| v.to_str().ok())
1330        .unwrap_or("application/octet-stream");
1331    let content_type = super::ContentType::from(content_type);
1332
1333    if !status.is_client_error() && !status.is_server_error() {
1334        let content = resp.text().await?;
1335        match content_type {
1336            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1337            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderTestV3Resp`"))),
1338            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderTestV3Resp`")))),
1339        }
1340    } else {
1341        let content = resp.text().await?;
1342        let entity: Option<SpotCreateOrderTestV3Error> = serde_json::from_str(&content).ok();
1343        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1344    }
1345}
1346
1347/// Send in a new order.
1348pub async fn spot_create_order_v3(configuration: &configuration::Configuration, params: SpotCreateOrderV3Params) -> Result<models::SpotCreateOrderV3Resp, Error<SpotCreateOrderV3Error>> {
1349
1350    let uri_str = format!("{}/api/v3/order", configuration.base_path);
1351    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1352
1353    // Create a mutable vector for query parameters
1354    let mut query_params: Vec<(String, String)> = Vec::new();
1355
1356
1357    // Create header parameters collection
1358    let mut header_params = std::collections::HashMap::new();
1359
1360    // Handle Binance Auth first if configured
1361    if let Some(ref binance_auth) = configuration.binance_auth {
1362        // Add API key to headers
1363        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1364        
1365        // Generate request body for signing (if any)
1366        let body_string: Option<Vec<u8>> = None;
1367        
1368        // Sign the request
1369        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1370            Ok(sig) => sig,
1371            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1372        };
1373        
1374        // Add signature to query params
1375        query_params.push(("signature".to_string(), signature));
1376    }
1377
1378    // Apply all query parameters
1379    if !query_params.is_empty() {
1380        req_builder = req_builder.query(&query_params);
1381    }
1382
1383
1384    // Add user agent if configured
1385    if let Some(ref user_agent) = configuration.user_agent {
1386        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1387    }
1388
1389    // Apply all header parameters
1390    for (header_name, header_value) in header_params {
1391        req_builder = req_builder.header(&header_name, &header_value);
1392    }
1393
1394    let mut multipart_form_params = std::collections::HashMap::new();
1395    if let Some(param_value) = params.iceberg_qty {
1396        multipart_form_params.insert("icebergQty", param_value.to_string());
1397    }
1398    if let Some(param_value) = params.new_client_order_id {
1399        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1400    }
1401    if let Some(param_value) = params.new_order_resp_type {
1402        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1403    }
1404    if let Some(param_value) = params.price {
1405        multipart_form_params.insert("price", param_value.to_string());
1406    }
1407    if let Some(param_value) = params.quantity {
1408        multipart_form_params.insert("quantity", param_value.to_string());
1409    }
1410    if let Some(param_value) = params.quote_order_qty {
1411        multipart_form_params.insert("quoteOrderQty", param_value.to_string());
1412    }
1413    if let Some(param_value) = params.recv_window {
1414        multipart_form_params.insert("recvWindow", param_value.to_string());
1415    }
1416    if let Some(param_value) = params.self_trade_prevention_mode {
1417        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1418    }
1419    multipart_form_params.insert("side", params.side.to_string());
1420    if let Some(param_value) = params.stop_price {
1421        multipart_form_params.insert("stopPrice", param_value.to_string());
1422    }
1423    if let Some(param_value) = params.strategy_id {
1424        multipart_form_params.insert("strategyId", param_value.to_string());
1425    }
1426    if let Some(param_value) = params.strategy_type {
1427        multipart_form_params.insert("strategyType", param_value.to_string());
1428    }
1429    multipart_form_params.insert("symbol", params.symbol.to_string());
1430    if let Some(param_value) = params.time_in_force {
1431        multipart_form_params.insert("timeInForce", param_value.to_string());
1432    }
1433    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1434    if let Some(param_value) = params.trailing_delta {
1435        multipart_form_params.insert("trailingDelta", param_value.to_string());
1436    }
1437    multipart_form_params.insert("type", params.r#type.to_string());
1438    req_builder = req_builder.form(&multipart_form_params);
1439
1440    let req = req_builder.build()?;
1441    let resp = configuration.client.execute(req).await?;
1442
1443    let status = resp.status();
1444    let content_type = resp
1445        .headers()
1446        .get("content-type")
1447        .and_then(|v| v.to_str().ok())
1448        .unwrap_or("application/octet-stream");
1449    let content_type = super::ContentType::from(content_type);
1450
1451    if !status.is_client_error() && !status.is_server_error() {
1452        let content = resp.text().await?;
1453        match content_type {
1454            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1455            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateOrderV3Resp`"))),
1456            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateOrderV3Resp`")))),
1457        }
1458    } else {
1459        let content = resp.text().await?;
1460        let entity: Option<SpotCreateOrderV3Error> = serde_json::from_str(&content).ok();
1461        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1462    }
1463}
1464
1465/// Test new order creation and signature/recvWindow using smart order routing (SOR). Creates and validates a new order but does not send it into the matching engine.
1466pub async fn spot_create_sor_order_test_v3(configuration: &configuration::Configuration, params: SpotCreateSorOrderTestV3Params) -> Result<models::SpotCreateSorOrderTestV3Resp, Error<SpotCreateSorOrderTestV3Error>> {
1467
1468    let uri_str = format!("{}/api/v3/sor/order/test", configuration.base_path);
1469    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1470
1471    // Create a mutable vector for query parameters
1472    let mut query_params: Vec<(String, String)> = Vec::new();
1473
1474
1475    // Create header parameters collection
1476    let mut header_params = std::collections::HashMap::new();
1477
1478    // Handle Binance Auth first if configured
1479    if let Some(ref binance_auth) = configuration.binance_auth {
1480        // Add API key to headers
1481        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1482        
1483        // Generate request body for signing (if any)
1484        let body_string: Option<Vec<u8>> = None;
1485        
1486        // Sign the request
1487        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1488            Ok(sig) => sig,
1489            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1490        };
1491        
1492        // Add signature to query params
1493        query_params.push(("signature".to_string(), signature));
1494    }
1495
1496    // Apply all query parameters
1497    if !query_params.is_empty() {
1498        req_builder = req_builder.query(&query_params);
1499    }
1500
1501
1502    // Add user agent if configured
1503    if let Some(ref user_agent) = configuration.user_agent {
1504        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1505    }
1506
1507    // Apply all header parameters
1508    for (header_name, header_value) in header_params {
1509        req_builder = req_builder.header(&header_name, &header_value);
1510    }
1511
1512    let mut multipart_form_params = std::collections::HashMap::new();
1513    if let Some(param_value) = params.compute_commission_rates {
1514        multipart_form_params.insert("computeCommissionRates", param_value.to_string());
1515    }
1516    if let Some(param_value) = params.iceberg_qty {
1517        multipart_form_params.insert("icebergQty", param_value.to_string());
1518    }
1519    if let Some(param_value) = params.new_client_order_id {
1520        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1521    }
1522    if let Some(param_value) = params.new_order_resp_type {
1523        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1524    }
1525    if let Some(param_value) = params.price {
1526        multipart_form_params.insert("price", param_value.to_string());
1527    }
1528    multipart_form_params.insert("quantity", params.quantity.to_string());
1529    if let Some(param_value) = params.recv_window {
1530        multipart_form_params.insert("recvWindow", param_value.to_string());
1531    }
1532    if let Some(param_value) = params.self_trade_prevention_mode {
1533        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1534    }
1535    multipart_form_params.insert("side", params.side.to_string());
1536    if let Some(param_value) = params.strategy_id {
1537        multipart_form_params.insert("strategyId", param_value.to_string());
1538    }
1539    if let Some(param_value) = params.strategy_type {
1540        multipart_form_params.insert("strategyType", param_value.to_string());
1541    }
1542    multipart_form_params.insert("symbol", params.symbol.to_string());
1543    if let Some(param_value) = params.time_in_force {
1544        multipart_form_params.insert("timeInForce", param_value.to_string());
1545    }
1546    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1547    multipart_form_params.insert("type", params.r#type.to_string());
1548    req_builder = req_builder.form(&multipart_form_params);
1549
1550    let req = req_builder.build()?;
1551    let resp = configuration.client.execute(req).await?;
1552
1553    let status = resp.status();
1554    let content_type = resp
1555        .headers()
1556        .get("content-type")
1557        .and_then(|v| v.to_str().ok())
1558        .unwrap_or("application/octet-stream");
1559    let content_type = super::ContentType::from(content_type);
1560
1561    if !status.is_client_error() && !status.is_server_error() {
1562        let content = resp.text().await?;
1563        match content_type {
1564            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1565            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateSorOrderTestV3Resp`"))),
1566            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateSorOrderTestV3Resp`")))),
1567        }
1568    } else {
1569        let content = resp.text().await?;
1570        let entity: Option<SpotCreateSorOrderTestV3Error> = serde_json::from_str(&content).ok();
1571        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1572    }
1573}
1574
1575/// Places an order using smart order routing (SOR).
1576pub async fn spot_create_sor_order_v3(configuration: &configuration::Configuration, params: SpotCreateSorOrderV3Params) -> Result<models::SpotCreateSorOrderV3Resp, Error<SpotCreateSorOrderV3Error>> {
1577
1578    let uri_str = format!("{}/api/v3/sor/order", configuration.base_path);
1579    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1580
1581    // Create a mutable vector for query parameters
1582    let mut query_params: Vec<(String, String)> = Vec::new();
1583
1584
1585    // Create header parameters collection
1586    let mut header_params = std::collections::HashMap::new();
1587
1588    // Handle Binance Auth first if configured
1589    if let Some(ref binance_auth) = configuration.binance_auth {
1590        // Add API key to headers
1591        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1592        
1593        // Generate request body for signing (if any)
1594        let body_string: Option<Vec<u8>> = None;
1595        
1596        // Sign the request
1597        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1598            Ok(sig) => sig,
1599            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1600        };
1601        
1602        // Add signature to query params
1603        query_params.push(("signature".to_string(), signature));
1604    }
1605
1606    // Apply all query parameters
1607    if !query_params.is_empty() {
1608        req_builder = req_builder.query(&query_params);
1609    }
1610
1611
1612    // Add user agent if configured
1613    if let Some(ref user_agent) = configuration.user_agent {
1614        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1615    }
1616
1617    // Apply all header parameters
1618    for (header_name, header_value) in header_params {
1619        req_builder = req_builder.header(&header_name, &header_value);
1620    }
1621
1622    let mut multipart_form_params = std::collections::HashMap::new();
1623    if let Some(param_value) = params.iceberg_qty {
1624        multipart_form_params.insert("icebergQty", param_value.to_string());
1625    }
1626    if let Some(param_value) = params.new_client_order_id {
1627        multipart_form_params.insert("newClientOrderId", param_value.to_string());
1628    }
1629    if let Some(param_value) = params.new_order_resp_type {
1630        multipart_form_params.insert("newOrderRespType", param_value.to_string());
1631    }
1632    if let Some(param_value) = params.price {
1633        multipart_form_params.insert("price", param_value.to_string());
1634    }
1635    multipart_form_params.insert("quantity", params.quantity.to_string());
1636    if let Some(param_value) = params.recv_window {
1637        multipart_form_params.insert("recvWindow", param_value.to_string());
1638    }
1639    if let Some(param_value) = params.self_trade_prevention_mode {
1640        multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
1641    }
1642    multipart_form_params.insert("side", params.side.to_string());
1643    if let Some(param_value) = params.strategy_id {
1644        multipart_form_params.insert("strategyId", param_value.to_string());
1645    }
1646    if let Some(param_value) = params.strategy_type {
1647        multipart_form_params.insert("strategyType", param_value.to_string());
1648    }
1649    multipart_form_params.insert("symbol", params.symbol.to_string());
1650    if let Some(param_value) = params.time_in_force {
1651        multipart_form_params.insert("timeInForce", param_value.to_string());
1652    }
1653    multipart_form_params.insert("timestamp", params.timestamp.to_string());
1654    multipart_form_params.insert("type", params.r#type.to_string());
1655    req_builder = req_builder.form(&multipart_form_params);
1656
1657    let req = req_builder.build()?;
1658    let resp = configuration.client.execute(req).await?;
1659
1660    let status = resp.status();
1661    let content_type = resp
1662        .headers()
1663        .get("content-type")
1664        .and_then(|v| v.to_str().ok())
1665        .unwrap_or("application/octet-stream");
1666    let content_type = super::ContentType::from(content_type);
1667
1668    if !status.is_client_error() && !status.is_server_error() {
1669        let content = resp.text().await?;
1670        match content_type {
1671            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1672            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotCreateSorOrderV3Resp`"))),
1673            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotCreateSorOrderV3Resp`")))),
1674        }
1675    } else {
1676        let content = resp.text().await?;
1677        let entity: Option<SpotCreateSorOrderV3Error> = serde_json::from_str(&content).ok();
1678        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1679    }
1680}
1681
1682/// Cancels all active orders on a symbol. This includes orders that are part of an order list.
1683pub async fn spot_delete_open_orders_v3(configuration: &configuration::Configuration, params: SpotDeleteOpenOrdersV3Params) -> Result<Vec<Vec<models::SpotDeleteOpenOrdersV3RespInner>>, Error<SpotDeleteOpenOrdersV3Error>> {
1684
1685    let uri_str = format!("{}/api/v3/openOrders", configuration.base_path);
1686    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1687
1688    // Create a mutable vector for query parameters
1689    let mut query_params: Vec<(String, String)> = Vec::new();
1690
1691    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1692    if let Some(ref param_value) = params.recv_window {
1693        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1694    }
1695    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1696
1697    // Create header parameters collection
1698    let mut header_params = std::collections::HashMap::new();
1699
1700    // Handle Binance Auth first if configured
1701    if let Some(ref binance_auth) = configuration.binance_auth {
1702        // Add API key to headers
1703        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1704        
1705        // Generate request body for signing (if any)
1706        let body_string: Option<Vec<u8>> = None;
1707        
1708        // Sign the request
1709        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1710            Ok(sig) => sig,
1711            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1712        };
1713        
1714        // Add signature to query params
1715        query_params.push(("signature".to_string(), signature));
1716    }
1717
1718    // Apply all query parameters
1719    if !query_params.is_empty() {
1720        req_builder = req_builder.query(&query_params);
1721    }
1722
1723
1724    // Add user agent if configured
1725    if let Some(ref user_agent) = configuration.user_agent {
1726        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1727    }
1728
1729    // Apply all header parameters
1730    for (header_name, header_value) in header_params {
1731        req_builder = req_builder.header(&header_name, &header_value);
1732    }
1733
1734
1735    let req = req_builder.build()?;
1736    let resp = configuration.client.execute(req).await?;
1737
1738    let status = resp.status();
1739    let content_type = resp
1740        .headers()
1741        .get("content-type")
1742        .and_then(|v| v.to_str().ok())
1743        .unwrap_or("application/octet-stream");
1744    let content_type = super::ContentType::from(content_type);
1745
1746    if !status.is_client_error() && !status.is_server_error() {
1747        let content = resp.text().await?;
1748        match content_type {
1749            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1750            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotDeleteOpenOrdersV3RespInner&gt;&gt;`"))),
1751            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;Vec&lt;models::SpotDeleteOpenOrdersV3RespInner&gt;&gt;`")))),
1752        }
1753    } else {
1754        let content = resp.text().await?;
1755        let entity: Option<SpotDeleteOpenOrdersV3Error> = serde_json::from_str(&content).ok();
1756        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1757    }
1758}
1759
1760/// Cancel an entire Order list
1761pub async fn spot_delete_order_list_v3(configuration: &configuration::Configuration, params: SpotDeleteOrderListV3Params) -> Result<models::SpotDeleteOrderListV3Resp, Error<SpotDeleteOrderListV3Error>> {
1762
1763    let uri_str = format!("{}/api/v3/orderList", configuration.base_path);
1764    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1765
1766    // Create a mutable vector for query parameters
1767    let mut query_params: Vec<(String, String)> = Vec::new();
1768
1769    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1770    if let Some(ref param_value) = params.order_list_id {
1771        query_params.push(("orderListId".to_string(), param_value.to_string()));
1772    }
1773    if let Some(ref param_value) = params.list_client_order_id {
1774        query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
1775    }
1776    if let Some(ref param_value) = params.new_client_order_id {
1777        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
1778    }
1779    if let Some(ref param_value) = params.recv_window {
1780        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1781    }
1782    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1783
1784    // Create header parameters collection
1785    let mut header_params = std::collections::HashMap::new();
1786
1787    // Handle Binance Auth first if configured
1788    if let Some(ref binance_auth) = configuration.binance_auth {
1789        // Add API key to headers
1790        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1791        
1792        // Generate request body for signing (if any)
1793        let body_string: Option<Vec<u8>> = None;
1794        
1795        // Sign the request
1796        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1797            Ok(sig) => sig,
1798            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1799        };
1800        
1801        // Add signature to query params
1802        query_params.push(("signature".to_string(), signature));
1803    }
1804
1805    // Apply all query parameters
1806    if !query_params.is_empty() {
1807        req_builder = req_builder.query(&query_params);
1808    }
1809
1810
1811    // Add user agent if configured
1812    if let Some(ref user_agent) = configuration.user_agent {
1813        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1814    }
1815
1816    // Apply all header parameters
1817    for (header_name, header_value) in header_params {
1818        req_builder = req_builder.header(&header_name, &header_value);
1819    }
1820
1821
1822    let req = req_builder.build()?;
1823    let resp = configuration.client.execute(req).await?;
1824
1825    let status = resp.status();
1826    let content_type = resp
1827        .headers()
1828        .get("content-type")
1829        .and_then(|v| v.to_str().ok())
1830        .unwrap_or("application/octet-stream");
1831    let content_type = super::ContentType::from(content_type);
1832
1833    if !status.is_client_error() && !status.is_server_error() {
1834        let content = resp.text().await?;
1835        match content_type {
1836            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1837            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotDeleteOrderListV3Resp`"))),
1838            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotDeleteOrderListV3Resp`")))),
1839        }
1840    } else {
1841        let content = resp.text().await?;
1842        let entity: Option<SpotDeleteOrderListV3Error> = serde_json::from_str(&content).ok();
1843        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1844    }
1845}
1846
1847/// Cancel an active order.
1848pub async fn spot_delete_order_v3(configuration: &configuration::Configuration, params: SpotDeleteOrderV3Params) -> Result<models::SpotDeleteOrderV3Resp, Error<SpotDeleteOrderV3Error>> {
1849
1850    let uri_str = format!("{}/api/v3/order", configuration.base_path);
1851    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1852
1853    // Create a mutable vector for query parameters
1854    let mut query_params: Vec<(String, String)> = Vec::new();
1855
1856    query_params.push(("symbol".to_string(), params.symbol.to_string()));
1857    if let Some(ref param_value) = params.order_id {
1858        query_params.push(("orderId".to_string(), param_value.to_string()));
1859    }
1860    if let Some(ref param_value) = params.orig_client_order_id {
1861        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
1862    }
1863    if let Some(ref param_value) = params.new_client_order_id {
1864        query_params.push(("newClientOrderId".to_string(), param_value.to_string()));
1865    }
1866    if let Some(ref param_value) = params.cancel_restrictions {
1867        query_params.push(("cancelRestrictions".to_string(), param_value.to_string()));
1868    }
1869    if let Some(ref param_value) = params.recv_window {
1870        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1871    }
1872    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1873
1874    // Create header parameters collection
1875    let mut header_params = std::collections::HashMap::new();
1876
1877    // Handle Binance Auth first if configured
1878    if let Some(ref binance_auth) = configuration.binance_auth {
1879        // Add API key to headers
1880        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1881        
1882        // Generate request body for signing (if any)
1883        let body_string: Option<Vec<u8>> = None;
1884        
1885        // Sign the request
1886        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1887            Ok(sig) => sig,
1888            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1889        };
1890        
1891        // Add signature to query params
1892        query_params.push(("signature".to_string(), signature));
1893    }
1894
1895    // Apply all query parameters
1896    if !query_params.is_empty() {
1897        req_builder = req_builder.query(&query_params);
1898    }
1899
1900
1901    // Add user agent if configured
1902    if let Some(ref user_agent) = configuration.user_agent {
1903        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1904    }
1905
1906    // Apply all header parameters
1907    for (header_name, header_value) in header_params {
1908        req_builder = req_builder.header(&header_name, &header_value);
1909    }
1910
1911
1912    let req = req_builder.build()?;
1913    let resp = configuration.client.execute(req).await?;
1914
1915    let status = resp.status();
1916    let content_type = resp
1917        .headers()
1918        .get("content-type")
1919        .and_then(|v| v.to_str().ok())
1920        .unwrap_or("application/octet-stream");
1921    let content_type = super::ContentType::from(content_type);
1922
1923    if !status.is_client_error() && !status.is_server_error() {
1924        let content = resp.text().await?;
1925        match content_type {
1926            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1927            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotDeleteOrderV3Resp`"))),
1928            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotDeleteOrderV3Resp`")))),
1929        }
1930    } else {
1931        let content = resp.text().await?;
1932        let entity: Option<SpotDeleteOrderV3Error> = serde_json::from_str(&content).ok();
1933        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1934    }
1935}
1936
1937/// Retrieves all order lists based on provided optional parameters. Note that the time between startTime and endTime can't be longer than 24 hours.
1938pub async fn spot_get_all_order_list_v3(configuration: &configuration::Configuration, params: SpotGetAllOrderListV3Params) -> Result<Vec<models::SpotGetAllOrderListV3RespItem>, Error<SpotGetAllOrderListV3Error>> {
1939
1940    let uri_str = format!("{}/api/v3/allOrderList", configuration.base_path);
1941    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1942
1943    // Create a mutable vector for query parameters
1944    let mut query_params: Vec<(String, String)> = Vec::new();
1945
1946    if let Some(ref param_value) = params.from_id {
1947        query_params.push(("fromId".to_string(), param_value.to_string()));
1948    }
1949    if let Some(ref param_value) = params.start_time {
1950        query_params.push(("startTime".to_string(), param_value.to_string()));
1951    }
1952    if let Some(ref param_value) = params.end_time {
1953        query_params.push(("endTime".to_string(), param_value.to_string()));
1954    }
1955    if let Some(ref param_value) = params.limit {
1956        query_params.push(("limit".to_string(), param_value.to_string()));
1957    }
1958    if let Some(ref param_value) = params.recv_window {
1959        query_params.push(("recvWindow".to_string(), param_value.to_string()));
1960    }
1961    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
1962
1963    // Create header parameters collection
1964    let mut header_params = std::collections::HashMap::new();
1965
1966    // Handle Binance Auth first if configured
1967    if let Some(ref binance_auth) = configuration.binance_auth {
1968        // Add API key to headers
1969        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
1970        
1971        // Generate request body for signing (if any)
1972        let body_string: Option<Vec<u8>> = None;
1973        
1974        // Sign the request
1975        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
1976            Ok(sig) => sig,
1977            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
1978        };
1979        
1980        // Add signature to query params
1981        query_params.push(("signature".to_string(), signature));
1982    }
1983
1984    // Apply all query parameters
1985    if !query_params.is_empty() {
1986        req_builder = req_builder.query(&query_params);
1987    }
1988
1989
1990    // Add user agent if configured
1991    if let Some(ref user_agent) = configuration.user_agent {
1992        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1993    }
1994
1995    // Apply all header parameters
1996    for (header_name, header_value) in header_params {
1997        req_builder = req_builder.header(&header_name, &header_value);
1998    }
1999
2000
2001    let req = req_builder.build()?;
2002    let resp = configuration.client.execute(req).await?;
2003
2004    let status = resp.status();
2005    let content_type = resp
2006        .headers()
2007        .get("content-type")
2008        .and_then(|v| v.to_str().ok())
2009        .unwrap_or("application/octet-stream");
2010    let content_type = super::ContentType::from(content_type);
2011
2012    if !status.is_client_error() && !status.is_server_error() {
2013        let content = resp.text().await?;
2014        match content_type {
2015            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2016            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetAllOrderListV3RespItem&gt;`"))),
2017            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetAllOrderListV3RespItem&gt;`")))),
2018        }
2019    } else {
2020        let content = resp.text().await?;
2021        let entity: Option<SpotGetAllOrderListV3Error> = serde_json::from_str(&content).ok();
2022        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2023    }
2024}
2025
2026/// Get all account orders; active, canceled, or filled.
2027pub async fn spot_get_all_orders_v3(configuration: &configuration::Configuration, params: SpotGetAllOrdersV3Params) -> Result<Vec<models::SpotGetAllOrdersV3RespItem>, Error<SpotGetAllOrdersV3Error>> {
2028
2029    let uri_str = format!("{}/api/v3/allOrders", configuration.base_path);
2030    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2031
2032    // Create a mutable vector for query parameters
2033    let mut query_params: Vec<(String, String)> = Vec::new();
2034
2035    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2036    if let Some(ref param_value) = params.order_id {
2037        query_params.push(("orderId".to_string(), param_value.to_string()));
2038    }
2039    if let Some(ref param_value) = params.start_time {
2040        query_params.push(("startTime".to_string(), param_value.to_string()));
2041    }
2042    if let Some(ref param_value) = params.end_time {
2043        query_params.push(("endTime".to_string(), param_value.to_string()));
2044    }
2045    if let Some(ref param_value) = params.limit {
2046        query_params.push(("limit".to_string(), param_value.to_string()));
2047    }
2048    if let Some(ref param_value) = params.recv_window {
2049        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2050    }
2051    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2052
2053    // Create header parameters collection
2054    let mut header_params = std::collections::HashMap::new();
2055
2056    // Handle Binance Auth first if configured
2057    if let Some(ref binance_auth) = configuration.binance_auth {
2058        // Add API key to headers
2059        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2060        
2061        // Generate request body for signing (if any)
2062        let body_string: Option<Vec<u8>> = None;
2063        
2064        // Sign the request
2065        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2066            Ok(sig) => sig,
2067            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2068        };
2069        
2070        // Add signature to query params
2071        query_params.push(("signature".to_string(), signature));
2072    }
2073
2074    // Apply all query parameters
2075    if !query_params.is_empty() {
2076        req_builder = req_builder.query(&query_params);
2077    }
2078
2079
2080    // Add user agent if configured
2081    if let Some(ref user_agent) = configuration.user_agent {
2082        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2083    }
2084
2085    // Apply all header parameters
2086    for (header_name, header_value) in header_params {
2087        req_builder = req_builder.header(&header_name, &header_value);
2088    }
2089
2090
2091    let req = req_builder.build()?;
2092    let resp = configuration.client.execute(req).await?;
2093
2094    let status = resp.status();
2095    let content_type = resp
2096        .headers()
2097        .get("content-type")
2098        .and_then(|v| v.to_str().ok())
2099        .unwrap_or("application/octet-stream");
2100    let content_type = super::ContentType::from(content_type);
2101
2102    if !status.is_client_error() && !status.is_server_error() {
2103        let content = resp.text().await?;
2104        match content_type {
2105            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2106            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetAllOrdersV3RespItem&gt;`"))),
2107            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetAllOrdersV3RespItem&gt;`")))),
2108        }
2109    } else {
2110        let content = resp.text().await?;
2111        let entity: Option<SpotGetAllOrdersV3Error> = serde_json::from_str(&content).ok();
2112        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2113    }
2114}
2115
2116pub async fn spot_get_open_order_list_v3(configuration: &configuration::Configuration, params: SpotGetOpenOrderListV3Params) -> Result<Vec<models::SpotGetOpenOrderListV3RespItem>, Error<SpotGetOpenOrderListV3Error>> {
2117
2118    let uri_str = format!("{}/api/v3/openOrderList", configuration.base_path);
2119    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2120
2121    // Create a mutable vector for query parameters
2122    let mut query_params: Vec<(String, String)> = Vec::new();
2123
2124    if let Some(ref param_value) = params.recv_window {
2125        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2126    }
2127    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2128
2129    // Create header parameters collection
2130    let mut header_params = std::collections::HashMap::new();
2131
2132    // Handle Binance Auth first if configured
2133    if let Some(ref binance_auth) = configuration.binance_auth {
2134        // Add API key to headers
2135        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2136        
2137        // Generate request body for signing (if any)
2138        let body_string: Option<Vec<u8>> = None;
2139        
2140        // Sign the request
2141        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2142            Ok(sig) => sig,
2143            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2144        };
2145        
2146        // Add signature to query params
2147        query_params.push(("signature".to_string(), signature));
2148    }
2149
2150    // Apply all query parameters
2151    if !query_params.is_empty() {
2152        req_builder = req_builder.query(&query_params);
2153    }
2154
2155
2156    // Add user agent if configured
2157    if let Some(ref user_agent) = configuration.user_agent {
2158        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2159    }
2160
2161    // Apply all header parameters
2162    for (header_name, header_value) in header_params {
2163        req_builder = req_builder.header(&header_name, &header_value);
2164    }
2165
2166
2167    let req = req_builder.build()?;
2168    let resp = configuration.client.execute(req).await?;
2169
2170    let status = resp.status();
2171    let content_type = resp
2172        .headers()
2173        .get("content-type")
2174        .and_then(|v| v.to_str().ok())
2175        .unwrap_or("application/octet-stream");
2176    let content_type = super::ContentType::from(content_type);
2177
2178    if !status.is_client_error() && !status.is_server_error() {
2179        let content = resp.text().await?;
2180        match content_type {
2181            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2182            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetOpenOrderListV3RespItem&gt;`"))),
2183            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetOpenOrderListV3RespItem&gt;`")))),
2184        }
2185    } else {
2186        let content = resp.text().await?;
2187        let entity: Option<SpotGetOpenOrderListV3Error> = serde_json::from_str(&content).ok();
2188        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2189    }
2190}
2191
2192/// Get all open orders on a symbol. Careful when accessing this with no symbol. Weight: 6 for a single symbol; 80 when the symbol parameter is omitted
2193pub async fn spot_get_open_orders_v3(configuration: &configuration::Configuration, params: SpotGetOpenOrdersV3Params) -> Result<Vec<models::SpotGetOpenOrdersV3RespItem>, Error<SpotGetOpenOrdersV3Error>> {
2194
2195    let uri_str = format!("{}/api/v3/openOrders", configuration.base_path);
2196    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2197
2198    // Create a mutable vector for query parameters
2199    let mut query_params: Vec<(String, String)> = Vec::new();
2200
2201    if let Some(ref param_value) = params.symbol {
2202        query_params.push(("symbol".to_string(), param_value.to_string()));
2203    }
2204    if let Some(ref param_value) = params.recv_window {
2205        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2206    }
2207    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2208
2209    // Create header parameters collection
2210    let mut header_params = std::collections::HashMap::new();
2211
2212    // Handle Binance Auth first if configured
2213    if let Some(ref binance_auth) = configuration.binance_auth {
2214        // Add API key to headers
2215        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2216        
2217        // Generate request body for signing (if any)
2218        let body_string: Option<Vec<u8>> = None;
2219        
2220        // Sign the request
2221        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2222            Ok(sig) => sig,
2223            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2224        };
2225        
2226        // Add signature to query params
2227        query_params.push(("signature".to_string(), signature));
2228    }
2229
2230    // Apply all query parameters
2231    if !query_params.is_empty() {
2232        req_builder = req_builder.query(&query_params);
2233    }
2234
2235
2236    // Add user agent if configured
2237    if let Some(ref user_agent) = configuration.user_agent {
2238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2239    }
2240
2241    // Apply all header parameters
2242    for (header_name, header_value) in header_params {
2243        req_builder = req_builder.header(&header_name, &header_value);
2244    }
2245
2246
2247    let req = req_builder.build()?;
2248    let resp = configuration.client.execute(req).await?;
2249
2250    let status = resp.status();
2251    let content_type = resp
2252        .headers()
2253        .get("content-type")
2254        .and_then(|v| v.to_str().ok())
2255        .unwrap_or("application/octet-stream");
2256    let content_type = super::ContentType::from(content_type);
2257
2258    if !status.is_client_error() && !status.is_server_error() {
2259        let content = resp.text().await?;
2260        match content_type {
2261            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2262            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::SpotGetOpenOrdersV3RespItem&gt;`"))),
2263            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::SpotGetOpenOrdersV3RespItem&gt;`")))),
2264        }
2265    } else {
2266        let content = resp.text().await?;
2267        let entity: Option<SpotGetOpenOrdersV3Error> = serde_json::from_str(&content).ok();
2268        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2269    }
2270}
2271
2272/// Retrieves a specific order list based on provided optional parameters.
2273pub async fn spot_get_order_list_v3(configuration: &configuration::Configuration, params: SpotGetOrderListV3Params) -> Result<models::SpotGetOrderListV3Resp, Error<SpotGetOrderListV3Error>> {
2274
2275    let uri_str = format!("{}/api/v3/orderList", configuration.base_path);
2276    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2277
2278    // Create a mutable vector for query parameters
2279    let mut query_params: Vec<(String, String)> = Vec::new();
2280
2281    if let Some(ref param_value) = params.order_list_id {
2282        query_params.push(("orderListId".to_string(), param_value.to_string()));
2283    }
2284    if let Some(ref param_value) = params.orig_client_order_id {
2285        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2286    }
2287    if let Some(ref param_value) = params.recv_window {
2288        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2289    }
2290    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2291
2292    // Create header parameters collection
2293    let mut header_params = std::collections::HashMap::new();
2294
2295    // Handle Binance Auth first if configured
2296    if let Some(ref binance_auth) = configuration.binance_auth {
2297        // Add API key to headers
2298        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2299        
2300        // Generate request body for signing (if any)
2301        let body_string: Option<Vec<u8>> = None;
2302        
2303        // Sign the request
2304        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2305            Ok(sig) => sig,
2306            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2307        };
2308        
2309        // Add signature to query params
2310        query_params.push(("signature".to_string(), signature));
2311    }
2312
2313    // Apply all query parameters
2314    if !query_params.is_empty() {
2315        req_builder = req_builder.query(&query_params);
2316    }
2317
2318
2319    // Add user agent if configured
2320    if let Some(ref user_agent) = configuration.user_agent {
2321        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2322    }
2323
2324    // Apply all header parameters
2325    for (header_name, header_value) in header_params {
2326        req_builder = req_builder.header(&header_name, &header_value);
2327    }
2328
2329
2330    let req = req_builder.build()?;
2331    let resp = configuration.client.execute(req).await?;
2332
2333    let status = resp.status();
2334    let content_type = resp
2335        .headers()
2336        .get("content-type")
2337        .and_then(|v| v.to_str().ok())
2338        .unwrap_or("application/octet-stream");
2339    let content_type = super::ContentType::from(content_type);
2340
2341    if !status.is_client_error() && !status.is_server_error() {
2342        let content = resp.text().await?;
2343        match content_type {
2344            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2345            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetOrderListV3Resp`"))),
2346            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetOrderListV3Resp`")))),
2347        }
2348    } else {
2349        let content = resp.text().await?;
2350        let entity: Option<SpotGetOrderListV3Error> = serde_json::from_str(&content).ok();
2351        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2352    }
2353}
2354
2355/// Check an order's status.
2356pub async fn spot_get_order_v3(configuration: &configuration::Configuration, params: SpotGetOrderV3Params) -> Result<models::SpotGetOrderV3Resp, Error<SpotGetOrderV3Error>> {
2357
2358    let uri_str = format!("{}/api/v3/order", configuration.base_path);
2359    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2360
2361    // Create a mutable vector for query parameters
2362    let mut query_params: Vec<(String, String)> = Vec::new();
2363
2364    query_params.push(("symbol".to_string(), params.symbol.to_string()));
2365    if let Some(ref param_value) = params.order_id {
2366        query_params.push(("orderId".to_string(), param_value.to_string()));
2367    }
2368    if let Some(ref param_value) = params.orig_client_order_id {
2369        query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
2370    }
2371    if let Some(ref param_value) = params.recv_window {
2372        query_params.push(("recvWindow".to_string(), param_value.to_string()));
2373    }
2374    query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
2375
2376    // Create header parameters collection
2377    let mut header_params = std::collections::HashMap::new();
2378
2379    // Handle Binance Auth first if configured
2380    if let Some(ref binance_auth) = configuration.binance_auth {
2381        // Add API key to headers
2382        header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
2383        
2384        // Generate request body for signing (if any)
2385        let body_string: Option<Vec<u8>> = None;
2386        
2387        // Sign the request
2388        let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
2389            Ok(sig) => sig,
2390            Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
2391        };
2392        
2393        // Add signature to query params
2394        query_params.push(("signature".to_string(), signature));
2395    }
2396
2397    // Apply all query parameters
2398    if !query_params.is_empty() {
2399        req_builder = req_builder.query(&query_params);
2400    }
2401
2402
2403    // Add user agent if configured
2404    if let Some(ref user_agent) = configuration.user_agent {
2405        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2406    }
2407
2408    // Apply all header parameters
2409    for (header_name, header_value) in header_params {
2410        req_builder = req_builder.header(&header_name, &header_value);
2411    }
2412
2413
2414    let req = req_builder.build()?;
2415    let resp = configuration.client.execute(req).await?;
2416
2417    let status = resp.status();
2418    let content_type = resp
2419        .headers()
2420        .get("content-type")
2421        .and_then(|v| v.to_str().ok())
2422        .unwrap_or("application/octet-stream");
2423    let content_type = super::ContentType::from(content_type);
2424
2425    if !status.is_client_error() && !status.is_server_error() {
2426        let content = resp.text().await?;
2427        match content_type {
2428            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2429            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpotGetOrderV3Resp`"))),
2430            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SpotGetOrderV3Resp`")))),
2431        }
2432    } else {
2433        let content = resp.text().await?;
2434        let entity: Option<SpotGetOrderV3Error> = serde_json::from_str(&content).ok();
2435        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2436    }
2437}
2438