bybit/models/transaction_log_request.rs
1use crate::prelude::*;
2
3/// Parameters for requesting transaction log data.
4///
5/// Used to construct a request to the `/v5/account/transaction-log` endpoint to retrieve historical transaction records, such as trades, fees, and funding. Bots use this to audit trading activity, calculate costs, and analyze performance in perpetual futures trading.
6#[derive(Clone, Default)]
7pub struct TransactionLogRequest<'a> {
8 /// The account type to filter logs (e.g., "UNIFIED", "SPOT") (optional).
9 ///
10 /// Optionally filters transactions by account type. If unset, data for all account types is returned. Bots should specify this to focus on specific account activities.
11 pub account_type: Option<Cow<'a, str>>,
12
13 /// The product category (e.g., Linear, Inverse) (optional).
14 ///
15 /// Optionally filters transactions by instrument type. If unset, data for all categories is returned. Bots should specify this to analyze specific contract types.
16 pub category: Option<Category>,
17
18 /// The currency to filter logs (e.g., "USDT") (optional).
19 ///
20 /// Optionally filters transactions by settlement currency. If unset, data for all currencies is returned. Bots should specify this for targeted financial analysis.
21 pub currency: Option<Cow<'a, str>>,
22
23 /// The base coin to filter logs (e.g., "BTC") (optional).
24 ///
25 /// Optionally filters transactions by base asset. If unset, data for all base coins is returned. Bots should specify this to focus on specific trading pairs.
26 pub base_coin: Option<Cow<'a, str>>,
27
28 /// The transaction type to filter logs (e.g., "TRADE", "FUNDING") (optional).
29 ///
30 /// Optionally filters transactions by type, such as trades or funding fees. If unset, all transaction types are returned. Bots should specify this to analyze specific activities.
31 pub log_type: Option<Cow<'a, str>>,
32
33 /// The start time for the transaction log (Unix timestamp in milliseconds) (optional).
34 ///
35 /// Defines the beginning of the time range. Bots should set this to focus on a specific historical period, such as a trading session.
36 pub start_time: Option<u64>,
37
38 /// The end time for the transaction log (Unix timestamp in milliseconds) (optional).
39 ///
40 /// Defines the end of the time range. Bots should set this to limit data to a specific period, optimizing performance.
41 pub end_time: Option<u64>,
42
43 /// The maximum number of transaction records to return (optional).
44 ///
45 /// Controls the number of records returned (e.g., max 50). Bots should set a reasonable limit to balance data completeness with performance.
46 pub limit: Option<u32>,
47}
48
49impl<'a> TransactionLogRequest<'a> {
50 /// Constructs a new TransactionLog request with specified parameters.
51 ///
52 /// Allows customization of the transaction log request. Bots should use this to specify the exact filters and time range to align with their analysis needs.
53 pub fn new(
54 account_type: Option<&'a str>,
55 category: Option<Category>,
56 currency: Option<&'a str>,
57 base_coin: Option<&'a str>,
58 log_type: Option<&'a str>,
59 start_time: Option<u64>,
60 end_time: Option<u64>,
61 limit: Option<u32>,
62 ) -> Self {
63 Self {
64 account_type: account_type.map(Cow::Borrowed),
65 category,
66 currency: currency.map(Cow::Borrowed),
67 base_coin: base_coin.map(Cow::Borrowed),
68 log_type: log_type.map(Cow::Borrowed),
69 start_time,
70 end_time,
71 limit,
72 }
73 }
74 /// Creates a default TransactionLog request.
75 ///
76 /// Returns a request with all fields unset. Suitable for broad queries but should be customized for specific analysis needs in production.
77 pub fn default() -> Self {
78 Self::new(None, None, None, None, None, None, None, None)
79 }
80}