Skip to main content

ctrader_rs/
misc.rs

1///
2///
3///
4///
5///
6///
7///
8///
9///
10///
11///
12///
13///
14///
15///
16///
17use crate::{client::Client, error::Error, payload, proto::common::*};
18
19impl Client {
20    /// Get cash flow history (deposits, withdrawals) for a time range.
21    ///
22    ///
23    ///
24    ///
25    ///
26    ///
27    ///
28    ///
29    ///
30    ///
31    /// Max range: 1 week (604 800 000 ms). Timestamps in Unix milliseconds.
32    pub async fn get_cash_flow_history(
33        &self,
34        ctid_trader_account_id: i64,
35        from_timestamp: i64,
36        to_timestamp: i64,
37    ) -> Result<ProtoOaCashFlowHistoryListRes, Error> {
38        let req = ProtoOaCashFlowHistoryListReq {
39            payload_type: Some(payload::OA_CASH_FLOW_HISTORY_LIST_REQ as i32),
40            ctid_trader_account_id,
41            from_timestamp,
42            to_timestamp,
43        };
44        self.command(
45            payload::OA_CASH_FLOW_HISTORY_LIST_REQ,
46            req,
47            payload::OA_CASH_FLOW_HISTORY_LIST_RES,
48        )
49        .await
50    }
51
52    /// Get leverage details for a given leverage ID.
53    ///
54    ///
55    ///
56    ///
57    ///
58    ///
59    ///
60    ///
61    ///
62    ///
63    ///
64    ///
65    ///
66    pub async fn get_dynamic_leverage(
67        &self,
68        ctid_trader_account_id: i64,
69        leverage_id: i64,
70    ) -> Result<ProtoOaGetDynamicLeverageByIdRes, Error> {
71        let req = ProtoOaGetDynamicLeverageByIdReq {
72            payload_type: Some(payload::OA_GET_DYNAMIC_LEVERAGE_REQ as i32),
73            ctid_trader_account_id,
74            leverage_id,
75        };
76        self.command(
77            payload::OA_GET_DYNAMIC_LEVERAGE_REQ,
78            req,
79            payload::OA_GET_DYNAMIC_LEVERAGE_RES,
80        )
81        .await
82    }
83}
84
85#[cfg(test)]
86mod tests {
87
88    #[async_std::test]
89    async fn test() {}
90}