1use serde::Serialize;
19
20use crate::{
21 common::enums::{BinanceSelfTradePreventionMode, BinanceSide, BinanceTimeInForce},
22 spot::enums::{BinanceCancelReplaceMode, BinanceOrderResponseType, BinanceSpotOrderType},
23};
24
25#[derive(Debug, Clone, Serialize)]
27pub struct DepthParams {
28 pub symbol: String,
30 #[serde(skip_serializing_if = "Option::is_none")]
32 pub limit: Option<u32>,
33}
34
35impl DepthParams {
36 #[must_use]
38 pub fn new(symbol: impl Into<String>) -> Self {
39 Self {
40 symbol: symbol.into(),
41 limit: None,
42 }
43 }
44
45 #[must_use]
47 pub fn with_limit(mut self, limit: u32) -> Self {
48 self.limit = Some(limit);
49 self
50 }
51}
52
53#[derive(Debug, Clone, Serialize)]
55pub struct TradesParams {
56 pub symbol: String,
58 #[serde(skip_serializing_if = "Option::is_none")]
60 pub limit: Option<u32>,
61}
62
63impl TradesParams {
64 #[must_use]
66 pub fn new(symbol: impl Into<String>) -> Self {
67 Self {
68 symbol: symbol.into(),
69 limit: None,
70 }
71 }
72
73 #[must_use]
75 pub fn with_limit(mut self, limit: u32) -> Self {
76 self.limit = Some(limit);
77 self
78 }
79}
80
81#[derive(Debug, Clone, Serialize)]
83pub struct AggTradesParams {
84 pub symbol: String,
86 #[serde(skip_serializing_if = "Option::is_none", rename = "fromId")]
88 pub from_id: Option<i64>,
89 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
91 pub start_time: Option<i64>,
92 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
94 pub end_time: Option<i64>,
95 #[serde(skip_serializing_if = "Option::is_none")]
97 pub limit: Option<u32>,
98}
99
100#[cfg(test)]
101mod market_data_tests {
102 use rstest::rstest;
103
104 use super::*;
105
106 #[rstest]
107 fn test_agg_trades_params_serialization() {
108 let params = AggTradesParams {
109 symbol: "ETHUSDT".to_string(),
110 from_id: Some(123),
111 start_time: Some(1_700_000_000_001),
112 end_time: Some(1_700_000_000_999),
113 limit: Some(456),
114 };
115
116 let serialized = serde_urlencoded::to_string(¶ms).unwrap();
117
118 assert_eq!(
119 serialized,
120 "symbol=ETHUSDT&fromId=123&startTime=1700000000001&endTime=1700000000999&limit=456"
121 );
122 }
123}
124
125#[derive(Debug, Clone, Serialize)]
127pub struct NewOrderParams {
128 pub symbol: String,
130 pub side: BinanceSide,
132 #[serde(rename = "type")]
134 pub order_type: BinanceSpotOrderType,
135 #[serde(skip_serializing_if = "Option::is_none", rename = "timeInForce")]
137 pub time_in_force: Option<BinanceTimeInForce>,
138 #[serde(skip_serializing_if = "Option::is_none")]
140 pub quantity: Option<String>,
141 #[serde(skip_serializing_if = "Option::is_none", rename = "quoteOrderQty")]
143 pub quote_order_qty: Option<String>,
144 #[serde(skip_serializing_if = "Option::is_none")]
146 pub price: Option<String>,
147 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
149 pub new_client_order_id: Option<String>,
150 #[serde(skip_serializing_if = "Option::is_none", rename = "stopPrice")]
152 pub stop_price: Option<String>,
153 #[serde(skip_serializing_if = "Option::is_none", rename = "trailingDelta")]
155 pub trailing_delta: Option<i64>,
156 #[serde(skip_serializing_if = "Option::is_none", rename = "icebergQty")]
158 pub iceberg_qty: Option<String>,
159 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
161 pub new_order_resp_type: Option<BinanceOrderResponseType>,
162 #[serde(
164 skip_serializing_if = "Option::is_none",
165 rename = "selfTradePreventionMode"
166 )]
167 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
168 #[serde(skip_serializing_if = "Option::is_none", rename = "strategyId")]
170 pub strategy_id: Option<i64>,
171 #[serde(skip_serializing_if = "Option::is_none", rename = "strategyType")]
173 pub strategy_type: Option<i64>,
174}
175
176impl NewOrderParams {
177 #[must_use]
179 pub fn limit(
180 symbol: impl Into<String>,
181 side: BinanceSide,
182 quantity: impl Into<String>,
183 price: impl Into<String>,
184 ) -> Self {
185 Self {
186 symbol: symbol.into(),
187 side,
188 order_type: BinanceSpotOrderType::Limit,
189 time_in_force: Some(BinanceTimeInForce::Gtc),
190 quantity: Some(quantity.into()),
191 quote_order_qty: None,
192 price: Some(price.into()),
193 new_client_order_id: None,
194 stop_price: None,
195 trailing_delta: None,
196 iceberg_qty: None,
197 new_order_resp_type: Some(BinanceOrderResponseType::Full),
198 self_trade_prevention_mode: None,
199 strategy_id: None,
200 strategy_type: None,
201 }
202 }
203
204 #[must_use]
206 pub fn market(
207 symbol: impl Into<String>,
208 side: BinanceSide,
209 quantity: impl Into<String>,
210 ) -> Self {
211 Self {
212 symbol: symbol.into(),
213 side,
214 order_type: BinanceSpotOrderType::Market,
215 time_in_force: None,
216 quantity: Some(quantity.into()),
217 quote_order_qty: None,
218 price: None,
219 new_client_order_id: None,
220 stop_price: None,
221 trailing_delta: None,
222 iceberg_qty: None,
223 new_order_resp_type: Some(BinanceOrderResponseType::Full),
224 self_trade_prevention_mode: None,
225 strategy_id: None,
226 strategy_type: None,
227 }
228 }
229
230 #[must_use]
232 pub fn with_client_order_id(mut self, id: impl Into<String>) -> Self {
233 self.new_client_order_id = Some(id.into());
234 self
235 }
236
237 #[must_use]
239 pub fn with_time_in_force(mut self, tif: BinanceTimeInForce) -> Self {
240 self.time_in_force = Some(tif);
241 self
242 }
243
244 #[must_use]
246 pub fn with_stop_price(mut self, price: impl Into<String>) -> Self {
247 self.stop_price = Some(price.into());
248 self
249 }
250
251 #[must_use]
253 pub fn with_stp_mode(mut self, mode: BinanceSelfTradePreventionMode) -> Self {
254 self.self_trade_prevention_mode = Some(mode);
255 self
256 }
257}
258
259#[derive(Debug, Clone, Serialize)]
261pub struct CancelOrderParams {
262 pub symbol: String,
264 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
266 pub order_id: Option<i64>,
267 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
269 pub orig_client_order_id: Option<String>,
270 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
272 pub new_client_order_id: Option<String>,
273}
274
275impl CancelOrderParams {
276 #[must_use]
278 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
279 Self {
280 symbol: symbol.into(),
281 order_id: Some(order_id),
282 orig_client_order_id: None,
283 new_client_order_id: None,
284 }
285 }
286
287 #[must_use]
289 pub fn by_client_order_id(
290 symbol: impl Into<String>,
291 client_order_id: impl Into<String>,
292 ) -> Self {
293 Self {
294 symbol: symbol.into(),
295 order_id: None,
296 orig_client_order_id: Some(client_order_id.into()),
297 new_client_order_id: None,
298 }
299 }
300}
301
302#[derive(Debug, Clone, Serialize)]
304pub struct CancelOpenOrdersParams {
305 pub symbol: String,
307}
308
309impl CancelOpenOrdersParams {
310 #[must_use]
312 pub fn new(symbol: impl Into<String>) -> Self {
313 Self {
314 symbol: symbol.into(),
315 }
316 }
317}
318
319#[derive(Debug, Clone, Serialize)]
321pub struct CancelReplaceOrderParams {
322 pub symbol: String,
324 pub side: BinanceSide,
326 #[serde(rename = "type")]
328 pub order_type: BinanceSpotOrderType,
329 #[serde(rename = "cancelReplaceMode")]
331 pub cancel_replace_mode: BinanceCancelReplaceMode,
332 #[serde(skip_serializing_if = "Option::is_none", rename = "timeInForce")]
334 pub time_in_force: Option<BinanceTimeInForce>,
335 #[serde(skip_serializing_if = "Option::is_none")]
337 pub quantity: Option<String>,
338 #[serde(skip_serializing_if = "Option::is_none", rename = "quoteOrderQty")]
340 pub quote_order_qty: Option<String>,
341 #[serde(skip_serializing_if = "Option::is_none")]
343 pub price: Option<String>,
344 #[serde(skip_serializing_if = "Option::is_none", rename = "cancelOrderId")]
346 pub cancel_order_id: Option<i64>,
347 #[serde(
349 skip_serializing_if = "Option::is_none",
350 rename = "cancelOrigClientOrderId"
351 )]
352 pub cancel_orig_client_order_id: Option<String>,
353 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
355 pub new_client_order_id: Option<String>,
356 #[serde(skip_serializing_if = "Option::is_none", rename = "stopPrice")]
358 pub stop_price: Option<String>,
359 #[serde(skip_serializing_if = "Option::is_none", rename = "trailingDelta")]
361 pub trailing_delta: Option<i64>,
362 #[serde(skip_serializing_if = "Option::is_none", rename = "icebergQty")]
364 pub iceberg_qty: Option<String>,
365 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
367 pub new_order_resp_type: Option<BinanceOrderResponseType>,
368 #[serde(
370 skip_serializing_if = "Option::is_none",
371 rename = "selfTradePreventionMode"
372 )]
373 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
374}
375
376#[derive(Debug, Clone, Serialize)]
378pub struct QueryOrderParams {
379 pub symbol: String,
381 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
383 pub order_id: Option<i64>,
384 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
386 pub orig_client_order_id: Option<String>,
387}
388
389impl QueryOrderParams {
390 #[must_use]
392 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
393 Self {
394 symbol: symbol.into(),
395 order_id: Some(order_id),
396 orig_client_order_id: None,
397 }
398 }
399
400 #[must_use]
402 pub fn by_client_order_id(
403 symbol: impl Into<String>,
404 client_order_id: impl Into<String>,
405 ) -> Self {
406 Self {
407 symbol: symbol.into(),
408 order_id: None,
409 orig_client_order_id: Some(client_order_id.into()),
410 }
411 }
412}
413
414#[derive(Debug, Clone, Default, Serialize)]
416pub struct OpenOrdersParams {
417 #[serde(skip_serializing_if = "Option::is_none")]
419 pub symbol: Option<String>,
420}
421
422impl OpenOrdersParams {
423 #[must_use]
425 pub fn all() -> Self {
426 Self { symbol: None }
427 }
428
429 #[must_use]
431 pub fn for_symbol(symbol: impl Into<String>) -> Self {
432 Self {
433 symbol: Some(symbol.into()),
434 }
435 }
436}
437
438#[derive(Debug, Clone, Serialize)]
440pub struct AllOrdersParams {
441 pub symbol: String,
443 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
445 pub order_id: Option<i64>,
446 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
448 pub start_time: Option<i64>,
449 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
451 pub end_time: Option<i64>,
452 #[serde(skip_serializing_if = "Option::is_none")]
454 pub limit: Option<u32>,
455}
456
457impl AllOrdersParams {
458 #[must_use]
460 pub fn new(symbol: impl Into<String>) -> Self {
461 Self {
462 symbol: symbol.into(),
463 order_id: None,
464 start_time: None,
465 end_time: None,
466 limit: None,
467 }
468 }
469
470 #[must_use]
472 pub fn with_limit(mut self, limit: u32) -> Self {
473 self.limit = Some(limit);
474 self
475 }
476
477 #[must_use]
479 pub fn with_time_range(mut self, start: i64, end: i64) -> Self {
480 self.start_time = Some(start);
481 self.end_time = Some(end);
482 self
483 }
484}
485
486#[derive(Debug, Clone, Serialize)]
488pub struct NewOcoOrderParams {
489 pub symbol: String,
491 pub side: BinanceSide,
493 pub quantity: String,
495 pub price: String,
497 #[serde(rename = "stopPrice")]
499 pub stop_price: String,
500 #[serde(skip_serializing_if = "Option::is_none", rename = "stopLimitPrice")]
502 pub stop_limit_price: Option<String>,
503 #[serde(skip_serializing_if = "Option::is_none", rename = "listClientOrderId")]
505 pub list_client_order_id: Option<String>,
506 #[serde(skip_serializing_if = "Option::is_none", rename = "limitClientOrderId")]
508 pub limit_client_order_id: Option<String>,
509 #[serde(skip_serializing_if = "Option::is_none", rename = "stopClientOrderId")]
511 pub stop_client_order_id: Option<String>,
512 #[serde(skip_serializing_if = "Option::is_none", rename = "limitIcebergQty")]
514 pub limit_iceberg_qty: Option<String>,
515 #[serde(skip_serializing_if = "Option::is_none", rename = "stopIcebergQty")]
517 pub stop_iceberg_qty: Option<String>,
518 #[serde(
520 skip_serializing_if = "Option::is_none",
521 rename = "stopLimitTimeInForce"
522 )]
523 pub stop_limit_time_in_force: Option<BinanceTimeInForce>,
524 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
526 pub new_order_resp_type: Option<BinanceOrderResponseType>,
527 #[serde(
529 skip_serializing_if = "Option::is_none",
530 rename = "selfTradePreventionMode"
531 )]
532 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
533}
534
535impl NewOcoOrderParams {
536 #[must_use]
538 pub fn new(
539 symbol: impl Into<String>,
540 side: BinanceSide,
541 quantity: impl Into<String>,
542 price: impl Into<String>,
543 stop_price: impl Into<String>,
544 ) -> Self {
545 Self {
546 symbol: symbol.into(),
547 side,
548 quantity: quantity.into(),
549 price: price.into(),
550 stop_price: stop_price.into(),
551 stop_limit_price: None,
552 list_client_order_id: None,
553 limit_client_order_id: None,
554 stop_client_order_id: None,
555 limit_iceberg_qty: None,
556 stop_iceberg_qty: None,
557 stop_limit_time_in_force: None,
558 new_order_resp_type: Some(BinanceOrderResponseType::Full),
559 self_trade_prevention_mode: None,
560 }
561 }
562
563 #[must_use]
565 pub fn with_stop_limit_price(mut self, price: impl Into<String>) -> Self {
566 self.stop_limit_price = Some(price.into());
567 self.stop_limit_time_in_force = Some(BinanceTimeInForce::Gtc);
568 self
569 }
570}
571
572#[derive(Debug, Clone, Serialize)]
574#[serde(rename_all = "camelCase")]
575pub struct NewOcoOrderListParams {
576 pub symbol: String,
578 #[serde(skip_serializing_if = "Option::is_none")]
580 pub list_client_order_id: Option<String>,
581 pub side: BinanceSide,
583 pub quantity: String,
585 pub above_type: BinanceSpotOrderType,
587 #[serde(skip_serializing_if = "Option::is_none")]
589 pub above_client_order_id: Option<String>,
590 #[serde(skip_serializing_if = "Option::is_none")]
592 pub above_iceberg_qty: Option<String>,
593 #[serde(skip_serializing_if = "Option::is_none")]
595 pub above_price: Option<String>,
596 #[serde(skip_serializing_if = "Option::is_none")]
598 pub above_stop_price: Option<String>,
599 #[serde(skip_serializing_if = "Option::is_none")]
601 pub above_time_in_force: Option<BinanceTimeInForce>,
602 pub below_type: BinanceSpotOrderType,
604 #[serde(skip_serializing_if = "Option::is_none")]
606 pub below_client_order_id: Option<String>,
607 #[serde(skip_serializing_if = "Option::is_none")]
609 pub below_iceberg_qty: Option<String>,
610 #[serde(skip_serializing_if = "Option::is_none")]
612 pub below_price: Option<String>,
613 #[serde(skip_serializing_if = "Option::is_none")]
615 pub below_stop_price: Option<String>,
616 #[serde(skip_serializing_if = "Option::is_none")]
618 pub below_time_in_force: Option<BinanceTimeInForce>,
619 #[serde(skip_serializing_if = "Option::is_none")]
621 pub new_order_resp_type: Option<BinanceOrderResponseType>,
622 #[serde(skip_serializing_if = "Option::is_none")]
624 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
625}
626
627#[derive(Debug, Clone, Serialize)]
629pub struct CancelOrderListParams {
630 pub symbol: String,
632 #[serde(skip_serializing_if = "Option::is_none", rename = "orderListId")]
634 pub order_list_id: Option<i64>,
635 #[serde(skip_serializing_if = "Option::is_none", rename = "listClientOrderId")]
637 pub list_client_order_id: Option<String>,
638 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
640 pub new_client_order_id: Option<String>,
641}
642
643impl CancelOrderListParams {
644 #[must_use]
646 pub fn by_order_list_id(symbol: impl Into<String>, order_list_id: i64) -> Self {
647 Self {
648 symbol: symbol.into(),
649 order_list_id: Some(order_list_id),
650 list_client_order_id: None,
651 new_client_order_id: None,
652 }
653 }
654
655 #[must_use]
657 pub fn by_list_client_order_id(
658 symbol: impl Into<String>,
659 list_client_order_id: impl Into<String>,
660 ) -> Self {
661 Self {
662 symbol: symbol.into(),
663 order_list_id: None,
664 list_client_order_id: Some(list_client_order_id.into()),
665 new_client_order_id: None,
666 }
667 }
668}
669
670#[derive(Debug, Clone, Serialize)]
672pub struct QueryOrderListParams {
673 #[serde(skip_serializing_if = "Option::is_none", rename = "orderListId")]
675 pub order_list_id: Option<i64>,
676 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
678 pub orig_client_order_id: Option<String>,
679}
680
681impl QueryOrderListParams {
682 #[must_use]
684 pub fn by_order_list_id(order_list_id: i64) -> Self {
685 Self {
686 order_list_id: Some(order_list_id),
687 orig_client_order_id: None,
688 }
689 }
690
691 #[must_use]
693 pub fn by_client_order_id(client_order_id: impl Into<String>) -> Self {
694 Self {
695 order_list_id: None,
696 orig_client_order_id: Some(client_order_id.into()),
697 }
698 }
699}
700
701#[derive(Debug, Clone, Default, Serialize)]
703pub struct AllOrderListsParams {
704 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
706 pub start_time: Option<i64>,
707 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
709 pub end_time: Option<i64>,
710 #[serde(skip_serializing_if = "Option::is_none")]
712 pub limit: Option<u32>,
713}
714
715#[derive(Debug, Clone, Default, Serialize)]
717pub struct OpenOrderListsParams {}
718
719#[derive(Debug, Clone, Default, Serialize)]
721pub struct AccountInfoParams {
722 #[serde(skip_serializing_if = "Option::is_none", rename = "omitZeroBalances")]
724 pub omit_zero_balances: Option<bool>,
725}
726
727#[derive(Debug, Clone, Serialize)]
729pub struct AccountCommissionParams {
730 pub symbol: String,
732}
733
734impl AccountCommissionParams {
735 #[must_use]
737 pub fn new(symbol: impl Into<String>) -> Self {
738 Self {
739 symbol: symbol.into(),
740 }
741 }
742}
743
744impl AccountInfoParams {
745 #[must_use]
747 pub fn new() -> Self {
748 Self::default()
749 }
750
751 #[must_use]
753 pub fn omit_zero_balances(mut self) -> Self {
754 self.omit_zero_balances = Some(true);
755 self
756 }
757}
758
759#[derive(Debug, Clone, Serialize)]
761pub struct AccountTradesParams {
762 pub symbol: String,
764 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
766 pub order_id: Option<i64>,
767 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
769 pub start_time: Option<i64>,
770 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
772 pub end_time: Option<i64>,
773 #[serde(skip_serializing_if = "Option::is_none", rename = "fromId")]
775 pub from_id: Option<i64>,
776 #[serde(skip_serializing_if = "Option::is_none")]
778 pub limit: Option<u32>,
779}
780
781impl AccountTradesParams {
782 #[must_use]
784 pub fn new(symbol: impl Into<String>) -> Self {
785 Self {
786 symbol: symbol.into(),
787 order_id: None,
788 start_time: None,
789 end_time: None,
790 from_id: None,
791 limit: None,
792 }
793 }
794
795 #[must_use]
797 pub fn for_order(mut self, order_id: i64) -> Self {
798 self.order_id = Some(order_id);
799 self
800 }
801
802 #[must_use]
804 pub fn with_limit(mut self, limit: u32) -> Self {
805 self.limit = Some(limit);
806 self
807 }
808
809 #[must_use]
811 pub fn with_time_range(mut self, start: i64, end: i64) -> Self {
812 self.start_time = Some(start);
813 self.end_time = Some(end);
814 self
815 }
816}
817
818#[derive(Debug, Clone, Serialize)]
820pub struct KlinesParams {
821 pub symbol: String,
823 pub interval: String,
825 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
827 pub start_time: Option<i64>,
828 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
830 pub end_time: Option<i64>,
831 #[serde(skip_serializing_if = "Option::is_none", rename = "timeZone")]
833 pub time_zone: Option<String>,
834 #[serde(skip_serializing_if = "Option::is_none")]
836 pub limit: Option<u32>,
837}
838
839#[derive(Debug, Clone, Serialize)]
841pub struct ListenKeyParams {
842 #[serde(rename = "listenKey")]
844 pub listen_key: String,
845}
846
847impl ListenKeyParams {
848 #[must_use]
850 pub fn new(listen_key: impl Into<String>) -> Self {
851 Self {
852 listen_key: listen_key.into(),
853 }
854 }
855}
856
857#[derive(Debug, Clone, Default, Serialize)]
859pub struct TickerParams {
860 #[serde(skip_serializing_if = "Option::is_none")]
862 pub symbol: Option<String>,
863}
864
865impl TickerParams {
866 #[must_use]
868 pub fn all() -> Self {
869 Self { symbol: None }
870 }
871
872 #[must_use]
874 pub fn for_symbol(symbol: impl Into<String>) -> Self {
875 Self {
876 symbol: Some(symbol.into()),
877 }
878 }
879}
880
881#[derive(Debug, Clone, Serialize)]
883pub struct AvgPriceParams {
884 pub symbol: String,
886}
887
888impl AvgPriceParams {
889 #[must_use]
891 pub fn new(symbol: impl Into<String>) -> Self {
892 Self {
893 symbol: symbol.into(),
894 }
895 }
896}
897
898#[derive(Debug, Clone, Default, Serialize)]
900pub struct TradeFeeParams {
901 #[serde(skip_serializing_if = "Option::is_none")]
903 pub symbol: Option<String>,
904}
905
906impl TradeFeeParams {
907 #[must_use]
909 pub fn all() -> Self {
910 Self { symbol: None }
911 }
912
913 #[must_use]
915 pub fn for_symbol(symbol: impl Into<String>) -> Self {
916 Self {
917 symbol: Some(symbol.into()),
918 }
919 }
920}
921
922#[derive(Debug, Clone, Serialize)]
924#[serde(rename_all = "camelCase")]
925pub struct BatchOrderItem {
926 pub symbol: String,
928 pub side: String,
930 #[serde(rename = "type")]
932 pub order_type: String,
933 #[serde(skip_serializing_if = "Option::is_none")]
935 pub time_in_force: Option<String>,
936 #[serde(skip_serializing_if = "Option::is_none")]
938 pub quantity: Option<String>,
939 #[serde(skip_serializing_if = "Option::is_none")]
941 pub price: Option<String>,
942 #[serde(skip_serializing_if = "Option::is_none")]
944 pub new_client_order_id: Option<String>,
945 #[serde(skip_serializing_if = "Option::is_none")]
947 pub stop_price: Option<String>,
948}
949
950impl BatchOrderItem {
951 #[must_use]
953 pub fn from_params(params: &NewOrderParams) -> Self {
954 Self {
955 symbol: params.symbol.clone(),
956 side: format!("{:?}", params.side).to_uppercase(),
957 order_type: format!("{:?}", params.order_type).to_uppercase(),
958 time_in_force: params
959 .time_in_force
960 .map(|t| format!("{t:?}").to_uppercase()),
961 quantity: params.quantity.clone(),
962 price: params.price.clone(),
963 new_client_order_id: params.new_client_order_id.clone(),
964 stop_price: params.stop_price.clone(),
965 }
966 }
967}
968
969#[derive(Debug, Clone, Serialize)]
971#[serde(rename_all = "camelCase")]
972pub struct BatchCancelItem {
973 pub symbol: String,
975 #[serde(skip_serializing_if = "Option::is_none")]
977 pub order_id: Option<i64>,
978 #[serde(skip_serializing_if = "Option::is_none")]
980 pub orig_client_order_id: Option<String>,
981}
982
983impl BatchCancelItem {
984 #[must_use]
986 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
987 Self {
988 symbol: symbol.into(),
989 order_id: Some(order_id),
990 orig_client_order_id: None,
991 }
992 }
993
994 #[must_use]
996 pub fn by_client_order_id(
997 symbol: impl Into<String>,
998 client_order_id: impl Into<String>,
999 ) -> Self {
1000 Self {
1001 symbol: symbol.into(),
1002 order_id: None,
1003 orig_client_order_id: Some(client_order_id.into()),
1004 }
1005 }
1006}