webull_rs/models/
account.rs

1use serde::{Deserialize, Serialize};
2use chrono::{DateTime, Utc};
3
4/// Account information from Webull.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Account {
7    /// Account ID
8    pub id: String,
9    
10    /// Account number
11    pub account_number: String,
12    
13    /// Account type
14    pub account_type: AccountType,
15    
16    /// Account status
17    pub status: AccountStatus,
18    
19    /// When the account was created
20    pub created_at: DateTime<Utc>,
21    
22    /// Currency of the account
23    pub currency: String,
24    
25    /// Whether the account is a paper trading account
26    pub paper_trading: bool,
27}
28
29/// Type of account.
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
31#[serde(rename_all = "UPPERCASE")]
32pub enum AccountType {
33    /// Cash account
34    Cash,
35    
36    /// Margin account
37    Margin,
38    
39    /// IRA account
40    Ira,
41    
42    /// Other account type
43    Other,
44}
45
46/// Status of an account.
47#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(rename_all = "UPPERCASE")]
49pub enum AccountStatus {
50    /// Account is active
51    Active,
52    
53    /// Account is closed
54    Closed,
55    
56    /// Account is pending approval
57    Pending,
58    
59    /// Account is suspended
60    Suspended,
61}
62
63/// Account balance information.
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct AccountBalance {
66    /// Cash balance
67    pub cash: f64,
68    
69    /// Buying power
70    pub buying_power: f64,
71    
72    /// Market value of holdings
73    pub market_value: f64,
74    
75    /// Total account value
76    pub total_value: f64,
77    
78    /// Unrealized profit/loss
79    pub unrealized_profit_loss: f64,
80    
81    /// Unrealized profit/loss percentage
82    pub unrealized_profit_loss_percentage: f64,
83}
84
85/// Position in an account.
86#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct Position {
88    /// Symbol of the position
89    pub symbol: String,
90    
91    /// Quantity of shares
92    pub quantity: f64,
93    
94    /// Average cost basis
95    pub cost_basis: f64,
96    
97    /// Current market value
98    pub market_value: f64,
99    
100    /// Unrealized profit/loss
101    pub unrealized_profit_loss: f64,
102    
103    /// Unrealized profit/loss percentage
104    pub unrealized_profit_loss_percentage: f64,
105    
106    /// Current price
107    pub current_price: f64,
108    
109    /// When the position was opened
110    pub opened_at: DateTime<Utc>,
111}