1#[cfg(feature = "python")]
19use pyo3::prelude::*;
20use serde::Serialize;
21
22use crate::{
23 common::enums::{BinanceSelfTradePreventionMode, BinanceSide, BinanceTimeInForce},
24 spot::enums::{BinanceCancelReplaceMode, BinanceOrderResponseType, BinanceSpotOrderType},
25};
26
27#[derive(Debug, Clone, Serialize)]
29pub struct DepthParams {
30 pub symbol: String,
32 #[serde(skip_serializing_if = "Option::is_none")]
34 pub limit: Option<u32>,
35}
36
37impl DepthParams {
38 #[must_use]
40 pub fn new(symbol: impl Into<String>) -> Self {
41 Self {
42 symbol: symbol.into(),
43 limit: None,
44 }
45 }
46
47 #[must_use]
49 pub fn with_limit(mut self, limit: u32) -> Self {
50 self.limit = Some(limit);
51 self
52 }
53}
54
55#[derive(Debug, Clone, Serialize)]
57pub struct TradesParams {
58 pub symbol: String,
60 #[serde(skip_serializing_if = "Option::is_none")]
62 pub limit: Option<u32>,
63}
64
65impl TradesParams {
66 #[must_use]
68 pub fn new(symbol: impl Into<String>) -> Self {
69 Self {
70 symbol: symbol.into(),
71 limit: None,
72 }
73 }
74
75 #[must_use]
77 pub fn with_limit(mut self, limit: u32) -> Self {
78 self.limit = Some(limit);
79 self
80 }
81}
82
83#[derive(Debug, Clone, Serialize)]
85pub struct NewOrderParams {
86 pub symbol: String,
88 pub side: BinanceSide,
90 #[serde(rename = "type")]
92 pub order_type: BinanceSpotOrderType,
93 #[serde(skip_serializing_if = "Option::is_none", rename = "timeInForce")]
95 pub time_in_force: Option<BinanceTimeInForce>,
96 #[serde(skip_serializing_if = "Option::is_none")]
98 pub quantity: Option<String>,
99 #[serde(skip_serializing_if = "Option::is_none", rename = "quoteOrderQty")]
101 pub quote_order_qty: Option<String>,
102 #[serde(skip_serializing_if = "Option::is_none")]
104 pub price: Option<String>,
105 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
107 pub new_client_order_id: Option<String>,
108 #[serde(skip_serializing_if = "Option::is_none", rename = "stopPrice")]
110 pub stop_price: Option<String>,
111 #[serde(skip_serializing_if = "Option::is_none", rename = "trailingDelta")]
113 pub trailing_delta: Option<i64>,
114 #[serde(skip_serializing_if = "Option::is_none", rename = "icebergQty")]
116 pub iceberg_qty: Option<String>,
117 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
119 pub new_order_resp_type: Option<BinanceOrderResponseType>,
120 #[serde(
122 skip_serializing_if = "Option::is_none",
123 rename = "selfTradePreventionMode"
124 )]
125 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
126 #[serde(skip_serializing_if = "Option::is_none", rename = "strategyId")]
128 pub strategy_id: Option<i64>,
129 #[serde(skip_serializing_if = "Option::is_none", rename = "strategyType")]
131 pub strategy_type: Option<i64>,
132}
133
134impl NewOrderParams {
135 #[must_use]
137 pub fn limit(
138 symbol: impl Into<String>,
139 side: BinanceSide,
140 quantity: impl Into<String>,
141 price: impl Into<String>,
142 ) -> Self {
143 Self {
144 symbol: symbol.into(),
145 side,
146 order_type: BinanceSpotOrderType::Limit,
147 time_in_force: Some(BinanceTimeInForce::Gtc),
148 quantity: Some(quantity.into()),
149 quote_order_qty: None,
150 price: Some(price.into()),
151 new_client_order_id: None,
152 stop_price: None,
153 trailing_delta: None,
154 iceberg_qty: None,
155 new_order_resp_type: Some(BinanceOrderResponseType::Full),
156 self_trade_prevention_mode: None,
157 strategy_id: None,
158 strategy_type: None,
159 }
160 }
161
162 #[must_use]
164 pub fn market(
165 symbol: impl Into<String>,
166 side: BinanceSide,
167 quantity: impl Into<String>,
168 ) -> Self {
169 Self {
170 symbol: symbol.into(),
171 side,
172 order_type: BinanceSpotOrderType::Market,
173 time_in_force: None,
174 quantity: Some(quantity.into()),
175 quote_order_qty: None,
176 price: None,
177 new_client_order_id: None,
178 stop_price: None,
179 trailing_delta: None,
180 iceberg_qty: None,
181 new_order_resp_type: Some(BinanceOrderResponseType::Full),
182 self_trade_prevention_mode: None,
183 strategy_id: None,
184 strategy_type: None,
185 }
186 }
187
188 #[must_use]
190 pub fn with_client_order_id(mut self, id: impl Into<String>) -> Self {
191 self.new_client_order_id = Some(id.into());
192 self
193 }
194
195 #[must_use]
197 pub fn with_time_in_force(mut self, tif: BinanceTimeInForce) -> Self {
198 self.time_in_force = Some(tif);
199 self
200 }
201
202 #[must_use]
204 pub fn with_stop_price(mut self, price: impl Into<String>) -> Self {
205 self.stop_price = Some(price.into());
206 self
207 }
208
209 #[must_use]
211 pub fn with_stp_mode(mut self, mode: BinanceSelfTradePreventionMode) -> Self {
212 self.self_trade_prevention_mode = Some(mode);
213 self
214 }
215}
216
217#[derive(Debug, Clone, Serialize)]
219pub struct CancelOrderParams {
220 pub symbol: String,
222 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
224 pub order_id: Option<i64>,
225 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
227 pub orig_client_order_id: Option<String>,
228 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
230 pub new_client_order_id: Option<String>,
231}
232
233impl CancelOrderParams {
234 #[must_use]
236 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
237 Self {
238 symbol: symbol.into(),
239 order_id: Some(order_id),
240 orig_client_order_id: None,
241 new_client_order_id: None,
242 }
243 }
244
245 #[must_use]
247 pub fn by_client_order_id(
248 symbol: impl Into<String>,
249 client_order_id: impl Into<String>,
250 ) -> Self {
251 Self {
252 symbol: symbol.into(),
253 order_id: None,
254 orig_client_order_id: Some(client_order_id.into()),
255 new_client_order_id: None,
256 }
257 }
258}
259
260#[derive(Debug, Clone, Serialize)]
262pub struct CancelOpenOrdersParams {
263 pub symbol: String,
265}
266
267impl CancelOpenOrdersParams {
268 #[must_use]
270 pub fn new(symbol: impl Into<String>) -> Self {
271 Self {
272 symbol: symbol.into(),
273 }
274 }
275}
276
277#[derive(Debug, Clone, Serialize)]
279pub struct CancelReplaceOrderParams {
280 pub symbol: String,
282 pub side: BinanceSide,
284 #[serde(rename = "type")]
286 pub order_type: BinanceSpotOrderType,
287 #[serde(rename = "cancelReplaceMode")]
289 pub cancel_replace_mode: BinanceCancelReplaceMode,
290 #[serde(skip_serializing_if = "Option::is_none", rename = "timeInForce")]
292 pub time_in_force: Option<BinanceTimeInForce>,
293 #[serde(skip_serializing_if = "Option::is_none")]
295 pub quantity: Option<String>,
296 #[serde(skip_serializing_if = "Option::is_none", rename = "quoteOrderQty")]
298 pub quote_order_qty: Option<String>,
299 #[serde(skip_serializing_if = "Option::is_none")]
301 pub price: Option<String>,
302 #[serde(skip_serializing_if = "Option::is_none", rename = "cancelOrderId")]
304 pub cancel_order_id: Option<i64>,
305 #[serde(
307 skip_serializing_if = "Option::is_none",
308 rename = "cancelOrigClientOrderId"
309 )]
310 pub cancel_orig_client_order_id: Option<String>,
311 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
313 pub new_client_order_id: Option<String>,
314 #[serde(skip_serializing_if = "Option::is_none", rename = "stopPrice")]
316 pub stop_price: Option<String>,
317 #[serde(skip_serializing_if = "Option::is_none", rename = "trailingDelta")]
319 pub trailing_delta: Option<i64>,
320 #[serde(skip_serializing_if = "Option::is_none", rename = "icebergQty")]
322 pub iceberg_qty: Option<String>,
323 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
325 pub new_order_resp_type: Option<BinanceOrderResponseType>,
326 #[serde(
328 skip_serializing_if = "Option::is_none",
329 rename = "selfTradePreventionMode"
330 )]
331 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
332}
333
334#[derive(Debug, Clone, Serialize)]
336pub struct QueryOrderParams {
337 pub symbol: String,
339 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
341 pub order_id: Option<i64>,
342 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
344 pub orig_client_order_id: Option<String>,
345}
346
347impl QueryOrderParams {
348 #[must_use]
350 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
351 Self {
352 symbol: symbol.into(),
353 order_id: Some(order_id),
354 orig_client_order_id: None,
355 }
356 }
357
358 #[must_use]
360 pub fn by_client_order_id(
361 symbol: impl Into<String>,
362 client_order_id: impl Into<String>,
363 ) -> Self {
364 Self {
365 symbol: symbol.into(),
366 order_id: None,
367 orig_client_order_id: Some(client_order_id.into()),
368 }
369 }
370}
371
372#[derive(Debug, Clone, Default, Serialize)]
374pub struct OpenOrdersParams {
375 #[serde(skip_serializing_if = "Option::is_none")]
377 pub symbol: Option<String>,
378}
379
380impl OpenOrdersParams {
381 #[must_use]
383 pub fn all() -> Self {
384 Self { symbol: None }
385 }
386
387 #[must_use]
389 pub fn for_symbol(symbol: impl Into<String>) -> Self {
390 Self {
391 symbol: Some(symbol.into()),
392 }
393 }
394}
395
396#[derive(Debug, Clone, Serialize)]
398pub struct AllOrdersParams {
399 pub symbol: String,
401 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
403 pub order_id: Option<i64>,
404 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
406 pub start_time: Option<i64>,
407 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
409 pub end_time: Option<i64>,
410 #[serde(skip_serializing_if = "Option::is_none")]
412 pub limit: Option<u32>,
413}
414
415impl AllOrdersParams {
416 #[must_use]
418 pub fn new(symbol: impl Into<String>) -> Self {
419 Self {
420 symbol: symbol.into(),
421 order_id: None,
422 start_time: None,
423 end_time: None,
424 limit: None,
425 }
426 }
427
428 #[must_use]
430 pub fn with_limit(mut self, limit: u32) -> Self {
431 self.limit = Some(limit);
432 self
433 }
434
435 #[must_use]
437 pub fn with_time_range(mut self, start: i64, end: i64) -> Self {
438 self.start_time = Some(start);
439 self.end_time = Some(end);
440 self
441 }
442}
443
444#[derive(Debug, Clone, Serialize)]
446pub struct NewOcoOrderParams {
447 pub symbol: String,
449 pub side: BinanceSide,
451 pub quantity: String,
453 pub price: String,
455 #[serde(rename = "stopPrice")]
457 pub stop_price: String,
458 #[serde(skip_serializing_if = "Option::is_none", rename = "stopLimitPrice")]
460 pub stop_limit_price: Option<String>,
461 #[serde(skip_serializing_if = "Option::is_none", rename = "listClientOrderId")]
463 pub list_client_order_id: Option<String>,
464 #[serde(skip_serializing_if = "Option::is_none", rename = "limitClientOrderId")]
466 pub limit_client_order_id: Option<String>,
467 #[serde(skip_serializing_if = "Option::is_none", rename = "stopClientOrderId")]
469 pub stop_client_order_id: Option<String>,
470 #[serde(skip_serializing_if = "Option::is_none", rename = "limitIcebergQty")]
472 pub limit_iceberg_qty: Option<String>,
473 #[serde(skip_serializing_if = "Option::is_none", rename = "stopIcebergQty")]
475 pub stop_iceberg_qty: Option<String>,
476 #[serde(
478 skip_serializing_if = "Option::is_none",
479 rename = "stopLimitTimeInForce"
480 )]
481 pub stop_limit_time_in_force: Option<BinanceTimeInForce>,
482 #[serde(skip_serializing_if = "Option::is_none", rename = "newOrderRespType")]
484 pub new_order_resp_type: Option<BinanceOrderResponseType>,
485 #[serde(
487 skip_serializing_if = "Option::is_none",
488 rename = "selfTradePreventionMode"
489 )]
490 pub self_trade_prevention_mode: Option<BinanceSelfTradePreventionMode>,
491}
492
493impl NewOcoOrderParams {
494 #[must_use]
496 pub fn new(
497 symbol: impl Into<String>,
498 side: BinanceSide,
499 quantity: impl Into<String>,
500 price: impl Into<String>,
501 stop_price: impl Into<String>,
502 ) -> Self {
503 Self {
504 symbol: symbol.into(),
505 side,
506 quantity: quantity.into(),
507 price: price.into(),
508 stop_price: stop_price.into(),
509 stop_limit_price: None,
510 list_client_order_id: None,
511 limit_client_order_id: None,
512 stop_client_order_id: None,
513 limit_iceberg_qty: None,
514 stop_iceberg_qty: None,
515 stop_limit_time_in_force: None,
516 new_order_resp_type: Some(BinanceOrderResponseType::Full),
517 self_trade_prevention_mode: None,
518 }
519 }
520
521 #[must_use]
523 pub fn with_stop_limit_price(mut self, price: impl Into<String>) -> Self {
524 self.stop_limit_price = Some(price.into());
525 self.stop_limit_time_in_force = Some(BinanceTimeInForce::Gtc);
526 self
527 }
528}
529
530#[derive(Debug, Clone, Serialize)]
532pub struct CancelOrderListParams {
533 pub symbol: String,
535 #[serde(skip_serializing_if = "Option::is_none", rename = "orderListId")]
537 pub order_list_id: Option<i64>,
538 #[serde(skip_serializing_if = "Option::is_none", rename = "listClientOrderId")]
540 pub list_client_order_id: Option<String>,
541 #[serde(skip_serializing_if = "Option::is_none", rename = "newClientOrderId")]
543 pub new_client_order_id: Option<String>,
544}
545
546impl CancelOrderListParams {
547 #[must_use]
549 pub fn by_order_list_id(symbol: impl Into<String>, order_list_id: i64) -> Self {
550 Self {
551 symbol: symbol.into(),
552 order_list_id: Some(order_list_id),
553 list_client_order_id: None,
554 new_client_order_id: None,
555 }
556 }
557
558 #[must_use]
560 pub fn by_list_client_order_id(
561 symbol: impl Into<String>,
562 list_client_order_id: impl Into<String>,
563 ) -> Self {
564 Self {
565 symbol: symbol.into(),
566 order_list_id: None,
567 list_client_order_id: Some(list_client_order_id.into()),
568 new_client_order_id: None,
569 }
570 }
571}
572
573#[derive(Debug, Clone, Serialize)]
575pub struct QueryOrderListParams {
576 #[serde(skip_serializing_if = "Option::is_none", rename = "orderListId")]
578 pub order_list_id: Option<i64>,
579 #[serde(skip_serializing_if = "Option::is_none", rename = "origClientOrderId")]
581 pub orig_client_order_id: Option<String>,
582}
583
584impl QueryOrderListParams {
585 #[must_use]
587 pub fn by_order_list_id(order_list_id: i64) -> Self {
588 Self {
589 order_list_id: Some(order_list_id),
590 orig_client_order_id: None,
591 }
592 }
593
594 #[must_use]
596 pub fn by_client_order_id(client_order_id: impl Into<String>) -> Self {
597 Self {
598 order_list_id: None,
599 orig_client_order_id: Some(client_order_id.into()),
600 }
601 }
602}
603
604#[derive(Debug, Clone, Default, Serialize)]
606pub struct AllOrderListsParams {
607 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
609 pub start_time: Option<i64>,
610 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
612 pub end_time: Option<i64>,
613 #[serde(skip_serializing_if = "Option::is_none")]
615 pub limit: Option<u32>,
616}
617
618#[derive(Debug, Clone, Default, Serialize)]
620pub struct OpenOrderListsParams {}
621
622#[derive(Debug, Clone, Default, Serialize)]
624pub struct AccountInfoParams {
625 #[serde(skip_serializing_if = "Option::is_none", rename = "omitZeroBalances")]
627 pub omit_zero_balances: Option<bool>,
628}
629
630impl AccountInfoParams {
631 #[must_use]
633 pub fn new() -> Self {
634 Self::default()
635 }
636
637 #[must_use]
639 pub fn omit_zero_balances(mut self) -> Self {
640 self.omit_zero_balances = Some(true);
641 self
642 }
643}
644
645#[derive(Debug, Clone, Serialize)]
647pub struct AccountTradesParams {
648 pub symbol: String,
650 #[serde(skip_serializing_if = "Option::is_none", rename = "orderId")]
652 pub order_id: Option<i64>,
653 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
655 pub start_time: Option<i64>,
656 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
658 pub end_time: Option<i64>,
659 #[serde(skip_serializing_if = "Option::is_none", rename = "fromId")]
661 pub from_id: Option<i64>,
662 #[serde(skip_serializing_if = "Option::is_none")]
664 pub limit: Option<u32>,
665}
666
667impl AccountTradesParams {
668 #[must_use]
670 pub fn new(symbol: impl Into<String>) -> Self {
671 Self {
672 symbol: symbol.into(),
673 order_id: None,
674 start_time: None,
675 end_time: None,
676 from_id: None,
677 limit: None,
678 }
679 }
680
681 #[must_use]
683 pub fn for_order(mut self, order_id: i64) -> Self {
684 self.order_id = Some(order_id);
685 self
686 }
687
688 #[must_use]
690 pub fn with_limit(mut self, limit: u32) -> Self {
691 self.limit = Some(limit);
692 self
693 }
694
695 #[must_use]
697 pub fn with_time_range(mut self, start: i64, end: i64) -> Self {
698 self.start_time = Some(start);
699 self.end_time = Some(end);
700 self
701 }
702}
703
704#[derive(Debug, Clone, Serialize)]
706pub struct KlinesParams {
707 pub symbol: String,
709 pub interval: String,
711 #[serde(skip_serializing_if = "Option::is_none", rename = "startTime")]
713 pub start_time: Option<i64>,
714 #[serde(skip_serializing_if = "Option::is_none", rename = "endTime")]
716 pub end_time: Option<i64>,
717 #[serde(skip_serializing_if = "Option::is_none", rename = "timeZone")]
719 pub time_zone: Option<String>,
720 #[serde(skip_serializing_if = "Option::is_none")]
722 pub limit: Option<u32>,
723}
724
725#[derive(Debug, Clone, Serialize)]
727pub struct ListenKeyParams {
728 #[serde(rename = "listenKey")]
730 pub listen_key: String,
731}
732
733impl ListenKeyParams {
734 #[must_use]
736 pub fn new(listen_key: impl Into<String>) -> Self {
737 Self {
738 listen_key: listen_key.into(),
739 }
740 }
741}
742
743#[derive(Debug, Clone, Default, Serialize)]
745pub struct TickerParams {
746 #[serde(skip_serializing_if = "Option::is_none")]
748 pub symbol: Option<String>,
749}
750
751impl TickerParams {
752 #[must_use]
754 pub fn all() -> Self {
755 Self { symbol: None }
756 }
757
758 #[must_use]
760 pub fn for_symbol(symbol: impl Into<String>) -> Self {
761 Self {
762 symbol: Some(symbol.into()),
763 }
764 }
765}
766
767#[derive(Debug, Clone, Serialize)]
769pub struct AvgPriceParams {
770 pub symbol: String,
772}
773
774impl AvgPriceParams {
775 #[must_use]
777 pub fn new(symbol: impl Into<String>) -> Self {
778 Self {
779 symbol: symbol.into(),
780 }
781 }
782}
783
784#[derive(Debug, Clone, Default, Serialize)]
786pub struct TradeFeeParams {
787 #[serde(skip_serializing_if = "Option::is_none")]
789 pub symbol: Option<String>,
790}
791
792impl TradeFeeParams {
793 #[must_use]
795 pub fn all() -> Self {
796 Self { symbol: None }
797 }
798
799 #[must_use]
801 pub fn for_symbol(symbol: impl Into<String>) -> Self {
802 Self {
803 symbol: Some(symbol.into()),
804 }
805 }
806}
807
808#[derive(Debug, Clone, Serialize)]
810#[serde(rename_all = "camelCase")]
811#[cfg_attr(
812 feature = "python",
813 pyclass(
814 module = "nautilus_trader.core.nautilus_pyo3.binance",
815 name = "SpotBatchOrderItem",
816 get_all,
817 from_py_object,
818 )
819)]
820pub struct BatchOrderItem {
821 pub symbol: String,
823 pub side: String,
825 #[serde(rename = "type")]
827 pub order_type: String,
828 #[serde(skip_serializing_if = "Option::is_none")]
830 pub time_in_force: Option<String>,
831 #[serde(skip_serializing_if = "Option::is_none")]
833 pub quantity: Option<String>,
834 #[serde(skip_serializing_if = "Option::is_none")]
836 pub price: Option<String>,
837 #[serde(skip_serializing_if = "Option::is_none")]
839 pub new_client_order_id: Option<String>,
840 #[serde(skip_serializing_if = "Option::is_none")]
842 pub stop_price: Option<String>,
843}
844
845impl BatchOrderItem {
846 #[must_use]
848 pub fn from_params(params: &NewOrderParams) -> Self {
849 Self {
850 symbol: params.symbol.clone(),
851 side: format!("{:?}", params.side).to_uppercase(),
852 order_type: format!("{:?}", params.order_type).to_uppercase(),
853 time_in_force: params
854 .time_in_force
855 .map(|t| format!("{t:?}").to_uppercase()),
856 quantity: params.quantity.clone(),
857 price: params.price.clone(),
858 new_client_order_id: params.new_client_order_id.clone(),
859 stop_price: params.stop_price.clone(),
860 }
861 }
862}
863
864#[cfg(feature = "python")]
865#[pymethods]
866impl BatchOrderItem {
867 #[new]
868 #[pyo3(signature = (symbol, side, order_type, time_in_force=None, quantity=None, price=None, new_client_order_id=None, stop_price=None))]
869 #[allow(clippy::too_many_arguments)]
870 fn py_new(
871 symbol: String,
872 side: String,
873 order_type: String,
874 time_in_force: Option<String>,
875 quantity: Option<String>,
876 price: Option<String>,
877 new_client_order_id: Option<String>,
878 stop_price: Option<String>,
879 ) -> Self {
880 Self {
881 symbol,
882 side,
883 order_type,
884 time_in_force,
885 quantity,
886 price,
887 new_client_order_id,
888 stop_price,
889 }
890 }
891}
892
893#[derive(Debug, Clone, Serialize)]
895#[serde(rename_all = "camelCase")]
896#[cfg_attr(
897 feature = "python",
898 pyclass(
899 module = "nautilus_trader.core.nautilus_pyo3.binance",
900 name = "SpotBatchCancelItem",
901 get_all,
902 from_py_object,
903 )
904)]
905pub struct BatchCancelItem {
906 pub symbol: String,
908 #[serde(skip_serializing_if = "Option::is_none")]
910 pub order_id: Option<i64>,
911 #[serde(skip_serializing_if = "Option::is_none")]
913 pub orig_client_order_id: Option<String>,
914}
915
916impl BatchCancelItem {
917 #[must_use]
919 pub fn by_order_id(symbol: impl Into<String>, order_id: i64) -> Self {
920 Self {
921 symbol: symbol.into(),
922 order_id: Some(order_id),
923 orig_client_order_id: None,
924 }
925 }
926
927 #[must_use]
929 pub fn by_client_order_id(
930 symbol: impl Into<String>,
931 client_order_id: impl Into<String>,
932 ) -> Self {
933 Self {
934 symbol: symbol.into(),
935 order_id: None,
936 orig_client_order_id: Some(client_order_id.into()),
937 }
938 }
939}
940
941#[cfg(feature = "python")]
942#[pymethods]
943impl BatchCancelItem {
944 #[new]
945 #[pyo3(signature = (symbol, order_id=None, orig_client_order_id=None))]
946 fn py_new(symbol: String, order_id: Option<i64>, orig_client_order_id: Option<String>) -> Self {
947 Self {
948 symbol,
949 order_id,
950 orig_client_order_id,
951 }
952 }
953
954 #[staticmethod]
956 #[pyo3(name = "by_order_id")]
957 fn py_by_order_id(symbol: String, order_id: i64) -> Self {
958 Self::by_order_id(symbol, order_id)
959 }
960
961 #[staticmethod]
963 #[pyo3(name = "by_client_order_id")]
964 fn py_by_client_order_id(symbol: String, client_order_id: String) -> Self {
965 Self::by_client_order_id(symbol, client_order_id)
966 }
967}