bybit/models/server_time.rs
1use crate::prelude::*;
2
3/// ----------------------------------------
4/// RESPONSE STRUCTS FOR MARKET REQUESTS
5/// ----------------------------------------
6/// Contains the server time in seconds and nanoseconds.
7///
8/// This struct is part of the `ServerTimeResponse` and provides high-precision server time, which is essential for timestamp-sensitive API requests in trading bots.
9#[derive(Serialize, Deserialize, Clone, Debug)]
10#[serde(rename_all = "camelCase")]
11pub struct ServerTime {
12 /// The server time in seconds since the Unix epoch.
13 ///
14 /// This is the primary timestamp used for validating API request timestamps. Trading bots must ensure their request timestamps are within a small window (e.g., ±5 seconds) of this value to avoid `10004` (timestamp error) rejections. For example, if `time_second` is `1697051234`, the bot's request timestamp should be very close to this value.
15 #[serde(with = "string_to_u64")]
16 pub time_second: u64,
17
18 /// The nanosecond component of the server time.
19 ///
20 /// Provides sub-second precision for the server time. While not typically used directly in API requests, it can be useful for high-frequency trading bots requiring precise timing for latency measurements or event ordering. For most bots, this can be ignored unless nanosecond precision is critical.
21 #[serde(with = "string_to_u64")]
22 pub time_nano: u64,
23}