longport/trade/requests/
get_today_orders.rs

1use serde::Serialize;
2
3use crate::{
4    Market,
5    trade::{OrderSide, OrderStatus},
6};
7
8/// Options for get today orders request
9#[derive(Debug, Default, Serialize, Clone)]
10pub struct GetTodayOrdersOptions {
11    #[serde(skip_serializing_if = "Option::is_none")]
12    symbol: Option<String>,
13    #[serde(skip_serializing_if = "<[_]>::is_empty")]
14    status: Vec<OrderStatus>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    side: Option<OrderSide>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    market: Option<Market>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    order_id: Option<String>,
21}
22
23impl GetTodayOrdersOptions {
24    /// Create a new `GetTodayOrdersOptions`
25    #[inline]
26    pub fn new() -> Self {
27        Default::default()
28    }
29
30    /// Set the security symbol
31    #[inline]
32    #[must_use]
33    pub fn symbol(self, symbol: impl Into<String>) -> Self {
34        Self {
35            symbol: Some(symbol.into()),
36            ..self
37        }
38    }
39
40    /// Set the order status
41    #[inline]
42    #[must_use]
43    pub fn status(self, status: impl IntoIterator<Item = OrderStatus>) -> Self {
44        Self {
45            status: status.into_iter().collect(),
46            ..self
47        }
48    }
49
50    /// Set the order side
51    #[inline]
52    #[must_use]
53    pub fn side(self, side: OrderSide) -> Self {
54        Self {
55            side: Some(side),
56            ..self
57        }
58    }
59
60    /// Set the market
61    #[inline]
62    #[must_use]
63    pub fn market(self, market: Market) -> Self {
64        Self {
65            market: Some(market),
66            ..self
67        }
68    }
69
70    /// Set the order id
71    #[inline]
72    #[must_use]
73    pub fn order_id(self, order_id: String) -> Self {
74        Self {
75            order_id: Some(order_id),
76            ..self
77        }
78    }
79}