longport/trade/requests/
get_history_executions.rs

1use serde::Serialize;
2use time::OffsetDateTime;
3
4use crate::serde_utils;
5
6/// Options for get history executions request
7#[derive(Debug, Serialize, Default, Clone)]
8pub struct GetHistoryExecutionsOptions {
9    #[serde(skip_serializing_if = "Option::is_none")]
10    symbol: Option<String>,
11    #[serde(
12        skip_serializing_if = "Option::is_none",
13        with = "serde_utils::timestamp_opt"
14    )]
15    start_at: Option<OffsetDateTime>,
16    #[serde(
17        skip_serializing_if = "Option::is_none",
18        with = "serde_utils::timestamp_opt"
19    )]
20    end_at: Option<OffsetDateTime>,
21}
22
23impl GetHistoryExecutionsOptions {
24    /// Create a new `GetHistoryExecutionsOptions`
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 start time
41    #[inline]
42    #[must_use]
43    pub fn start_at(self, start_at: OffsetDateTime) -> Self {
44        Self {
45            start_at: Some(start_at),
46            ..self
47        }
48    }
49
50    /// Set the end time
51    #[inline]
52    #[must_use]
53    pub fn end_at(self, end_at: OffsetDateTime) -> Self {
54        Self {
55            end_at: Some(end_at),
56            ..self
57        }
58    }
59}