bybit/models/move_history_request.rs
1use crate::prelude::*;
2
3/// Parameters for requesting position move history.
4///
5/// Used to construct a request to the `/v5/position/move-history` endpoint to retrieve historical data on position transfers between accounts. Bots use this to audit past transfers, verify portfolio changes, and ensure compliance with trading rules.
6#[derive(Serialize, Clone, Default)]
7pub struct MoveHistoryRequest<'a> {
8 /// The product category (e.g., Linear, Inverse) (optional).
9 ///
10 /// Optionally filters transfer history by instrument type. If unset, data for all categories is returned. Bots should specify this for targeted analysis.
11 pub category: Option<Category>,
12
13 /// The trading pair symbol (e.g., "BTCUSDT") (optional).
14 ///
15 /// Optionally filters transfer history by symbol. If unset, data for all symbols is returned. Bots should specify this to focus on specific contracts.
16 pub symbol: Option<Cow<'a, str>>,
17
18 /// The start time for the transfer history (Unix timestamp in milliseconds) (optional).
19 ///
20 /// Defines the beginning of the time range. Bots should set this to focus on a specific historical period.
21 pub start_time: Option<u64>,
22
23 /// The end time for the transfer history (Unix timestamp in milliseconds) (optional).
24 ///
25 /// Defines the end of the time range. Bots should set this to limit data to a specific period, optimizing performance.
26 pub end_time: Option<u64>,
27
28 /// The status of the transfers (e.g., "Filled", "Rejected") (optional).
29 ///
30 /// Optionally filters transfers by status. Bots can use this to analyze successful or failed transfers separately.
31 pub status: Option<Cow<'a, str>>,
32
33 /// The block trade ID (optional).
34 ///
35 /// Optionally filters transfers by a specific block trade ID. Bots can use this to retrieve details of a particular transfer event.
36 pub block_trade_id: Option<Cow<'a, str>>,
37
38 /// The maximum number of transfer records to return (optional).
39 ///
40 /// Controls the number of records returned as a string (e.g., "50"). Bots should set a reasonable limit to balance data completeness with performance.
41 pub limit: Option<Cow<'a, str>>,
42}
43
44impl<'a> MoveHistoryRequest<'a> {
45 /// Constructs a new MoveHistory request with specified parameters.
46 ///
47 /// Allows customization of the transfer history request. Bots should use this to specify the exact category, symbol, time range, and filters to align with their analysis needs.
48 pub fn new(
49 category: Option<Category>,
50 symbol: Option<&'a str>,
51 start_time: Option<u64>,
52 end_time: Option<u64>,
53 status: Option<&'a str>,
54 block_trade_id: Option<&'a str>,
55 limit: Option<&'a str>,
56 ) -> Self {
57 Self {
58 category,
59 symbol: symbol.map(Cow::Borrowed),
60 start_time,
61 end_time,
62 status: status.map(Cow::Borrowed),
63 block_trade_id: block_trade_id.map(Cow::Borrowed),
64 limit: limit.map(Cow::Borrowed),
65 }
66 }
67 /// Creates a default MoveHistory request.
68 ///
69 /// Returns a request with all fields unset. Suitable for broad queries but should be customized for specific analysis needs.
70 pub fn default() -> MoveHistoryRequest<'a> {
71 MoveHistoryRequest::new(None, None, None, None, None, None, None)
72 }
73}