Skip to main content

bybit/models/
recent_trade.rs

1use crate::prelude::*;
2
3/// Represents a single trade record.
4///
5/// Each trade record details an executed trade, including price, quantity, side, and timestamp. For perpetual futures, this data is critical for understanding short-term market dynamics and confirming trading signals.
6#[derive(Serialize, Deserialize, Clone, Debug)]
7#[serde(rename_all = "camelCase")]
8pub struct RecentTrade {
9    /// The timestamp of the trade execution (Unix timestamp in milliseconds).
10    ///
11    /// Indicates when the trade occurred. Bots use this to align trade data with other time-series data (e.g., Klines) and to assess the recency of market activity for real-time strategies.
12    #[serde(with = "string_to_u64")]
13    pub time: u64,
14
15    /// The trading pair symbol (e.g., "BTCUSDT").
16    ///
17    /// Identifies the perpetual futures contract for the trade. Bots should verify this matches the requested symbol to ensure data accuracy.
18    pub symbol: String,
19
20    /// The trade execution price.
21    ///
22    /// The price at which the trade was executed. Bots use this to track price movements and calculate metrics like average trade price or slippage in perpetual futures. Stored as a string to preserve precision, so bots must parse it to `f64` for calculations.
23    #[serde(with = "string_to_float")]
24    pub price: f64,
25
26    /// The trade quantity (in base asset).
27    ///
28    /// The amount of the base asset traded (e.g., BTC in `BTCUSDT`). Bots use this to assess trade size and market liquidity, as large trades may indicate institutional activity or strong market sentiment.
29    #[serde(with = "string_to_float")]
30    pub size: f64,
31
32    /// The side of the trade ("Buy" or "Sell").
33    ///
34    /// Indicates whether the trade was a buy (taker buying from maker) or sell (taker selling to maker). Bots use this to analyze buying vs. selling pressure, which can inform momentum-based strategies in perpetual futures.
35    pub side: Side,
36
37    /// The unique trade ID.
38    ///
39    /// A unique identifier for the trade on Bybit’s exchange. Bots can use this to track specific trades, avoid duplicates in data processing, or correlate trades with other exchange data.
40    pub exec_id: String,
41
42    /// Indicates if the trade is a block trade.
43    ///
44    /// A boolean (`true` or `false`) indicating whether the trade was a large block trade, typically executed off the public order book. Bots can use this to identify significant market moves driven by institutional or large traders in perpetual futures.
45    pub is_block_trade: bool,
46
47    #[serde(rename = "isRPITrade")]
48    pub is_rpi_trade: bool,
49}