Skip to main content

longbridge/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    // Pagination cursor (1-based), set internally by `history_executions` while
22    // walking pages. Not a public builder — callers always get every page.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    page: Option<u32>,
25}
26
27impl GetHistoryExecutionsOptions {
28    /// Create a new `GetHistoryExecutionsOptions`
29    #[inline]
30    pub fn new() -> Self {
31        Default::default()
32    }
33
34    /// Set the security symbol
35    #[inline]
36    #[must_use]
37    pub fn symbol(self, symbol: impl Into<String>) -> Self {
38        Self {
39            symbol: Some(symbol.into()),
40            ..self
41        }
42    }
43
44    /// Set the start time
45    #[inline]
46    #[must_use]
47    pub fn start_at(self, start_at: OffsetDateTime) -> Self {
48        Self {
49            start_at: Some(start_at),
50            ..self
51        }
52    }
53
54    /// Set the end time
55    #[inline]
56    #[must_use]
57    pub fn end_at(self, end_at: OffsetDateTime) -> Self {
58        Self {
59            end_at: Some(end_at),
60            ..self
61        }
62    }
63
64    /// Internal 1-based pagination cursor used by `history_executions` to walk
65    /// all pages. Not a public builder — the SDK sets this while paginating.
66    #[inline]
67    pub(crate) fn with_page(self, page: u32) -> Self {
68        Self {
69            page: Some(page),
70            ..self
71        }
72    }
73}