bybit/models/
transaction_log_entry.rs

1use crate::prelude::*;
2
3/// Represents a single transaction log entry.
4///
5/// Details a specific transaction, such as a trade, funding fee, or margin adjustment, including associated costs and quantities. Bots use this to audit trading activity and calculate net performance in perpetual futures trading.
6#[derive(Debug, Serialize, Deserialize, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct TransactionLogEntry {
9    /// The unique identifier for the transaction.
10    ///
11    /// A unique ID assigned by Bybit to track the transaction. Bots use this to correlate transactions with other data, such as orders or executions.
12    pub id: String,
13
14    /// The trading pair symbol (e.g., "BTCUSDT").
15    ///
16    /// Identifies the perpetual futures contract or asset involved in the transaction. Bots use this to filter transactions by market.
17    pub symbol: String,
18
19    /// The trade side ("Buy" or "Sell").
20    ///
21    /// Indicates whether the transaction was a buy or sell action. Bots use this to track position direction and calculate net exposure.
22    pub side: String,
23
24    /// The funding fee (optional).
25    ///
26    /// The funding fee applied to the transaction, if applicable, in the settlement currency. Bots use this to calculate funding costs for perpetual futures positions.
27    pub funding: Option<String>,
28
29    /// The user-defined order link ID (optional).
30    ///
31    /// A custom identifier for the order, if set by the bot. Bots use this to track specific orders across transactions.
32    pub order_link_id: Option<String>,
33
34    /// The unique order ID.
35    ///
36    /// The Bybit-assigned ID for the order associated with the transaction. Bots use this to correlate transactions with specific orders.
37    pub order_id: String,
38
39    /// The transaction fee.
40    ///
41    /// The fee charged for the transaction, in the settlement currency. Bots use this to calculate trading costs and optimize fee-efficient strategies.
42    #[serde(with = "string_to_float")]
43    pub fee: f64,
44
45    /// The balance change caused by the transaction.
46    ///
47    /// The net change in account balance due to the transaction, as a string (e.g., "+100.50" or "-50.25"). Bots use this to track account balance updates.
48    pub change: String,
49
50    /// The cash flow of the transaction.
51    ///
52    /// The net cash flow (positive or negative) resulting from the transaction, in the settlement currency. Bots use this to calculate liquidity impacts.
53    #[serde(with = "string_to_float")]
54    pub cash_flow: f64,
55
56    /// The timestamp of the transaction.
57    ///
58    /// The time when the transaction occurred, as a string (e.g., "2025-05-19T13:07:00Z"). Bots use this to align transactions with market events.
59    pub transaction_time: String,
60
61    /// The type of transaction (e.g., "TRADE", "FUNDING").
62    ///
63    /// Specifies the nature of the transaction, such as trade execution or funding fee. Bots use this to categorize transactions for analysis.
64    pub type_field: String,
65
66    /// The fee rate applied to the transaction.
67    ///
68    /// The fee rate (e.g., "0.00075" for 0.075%) applied to the transaction. Bots use this to verify fee calculations and optimize trading costs.
69    pub fee_rate: String,
70
71    /// The bonus change, if any (optional).
72    ///
73    /// Any bonus or promotional balance changes applied to the transaction, in the settlement currency. Bots use this to account for special incentives.
74    pub bonus_change: Option<String>,
75
76    /// The position size affected by the transaction.
77    ///
78    /// The size of the position involved in the transaction, in base asset units. Bots use this to track position changes and calculate exposure.
79    #[serde(with = "string_to_float")]
80    pub size: f64,
81
82    /// The quantity traded in the transaction.
83    ///
84    /// The amount of the base asset traded, in base asset units. Bots use this to verify trade execution details.
85    #[serde(with = "string_to_float")]
86    pub qty: f64,
87
88    /// The resulting cash balance after the transaction.
89    ///
90    /// The account’s cash balance after the transaction, in the settlement currency. Bots use this to monitor available funds for trading.
91    #[serde(with = "string_to_float")]
92    pub cash_balance: f64,
93
94    /// The currency of the transaction (e.g., "USDT").
95    ///
96    /// The settlement currency used for the transaction. Bots use this to ensure correct currency handling in multi-currency accounts.
97    pub currency: String,
98
99    /// The product category (e.g., "linear").
100    ///
101    /// The instrument type of the transaction, such as `linear` for USDT-margined perpetuals. Bots use this to filter transactions by contract type.
102    pub category: String,
103
104    /// The trade price.
105    ///
106    /// The price at which the trade was executed, as a string (e.g., "50000.00"). Bots use this to verify execution prices and calculate P&L.
107    pub trade_price: String,
108
109    /// The unique trade ID.
110    ///
111    /// A unique identifier for the trade execution associated with the transaction. Bots use this to track specific trade events.
112    pub trade_id: String,
113}