ig_client/application/interfaces/
account.rs

1use crate::error::AppError;
2use crate::prelude::{
3    AccountActivityResponse, AccountsResponse, PositionsResponse, TransactionHistoryResponse,
4    WorkingOrdersResponse,
5};
6use async_trait::async_trait;
7
8/// Interface for the account service
9#[async_trait]
10pub trait AccountService: Send + Sync {
11    /// Gets information about all user accounts
12    async fn get_accounts(&self) -> Result<AccountsResponse, AppError>;
13
14    /// Gets open positions
15    async fn get_positions(&self) -> Result<PositionsResponse, AppError>;
16
17    /// Gets open positions base in filter
18    async fn get_positions_w_filter(&self, filter: &str) -> Result<PositionsResponse, AppError>;
19
20    /// Gets working orders
21    async fn get_working_orders(&self) -> Result<WorkingOrdersResponse, AppError>;
22
23    /// Gets account activity
24    ///
25    /// # Arguments
26    /// * `session` - The current session
27    /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
28    /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
29    ///
30    /// # Returns
31    /// * Account activity for the specified period
32    async fn get_activity(&self, from: &str, to: &str)
33    -> Result<AccountActivityResponse, AppError>;
34
35    /// Gets detailed account activity
36    ///
37    /// This method includes additional details for each activity item by using
38    /// the detailed=true parameter in the API request.
39    ///
40    /// # Arguments
41    /// * `session` - The current session
42    /// * `from` - Start date in ISO format (e.g. "2023-01-01T00:00:00Z")
43    /// * `to` - End date in ISO format (e.g. "2023-02-01T00:00:00Z")
44    ///
45    /// # Returns
46    /// * Detailed account activity for the specified period
47    async fn get_activity_with_details(
48        &self,
49
50        from: &str,
51        to: &str,
52    ) -> Result<AccountActivityResponse, AppError>;
53
54    /// Gets transaction history for a given period, handling pagination automatically.
55    async fn get_transactions(
56        &self,
57        from: &str,
58        to: &str,
59    ) -> Result<TransactionHistoryResponse, AppError>;
60}