1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#[derive(Debug, Deserialize, Serialize)]
pub struct AccessTokenResponse {
pub access_token: String,
pub scope: String,
pub expires_in: i64,
}
#[derive(Debug, Deserialize)]
pub struct GetPriceHistoryResponse {
pub candles: Vec<Candle>,
pub empty: bool,
pub symbol: String,
}
#[derive(Clone, Copy, Debug, Deserialize)]
pub struct Candle {
pub close: f64,
pub datetime: usize,
pub high: f64,
pub low: f64,
pub open: f64,
pub volume: i64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Mover {
pub change: f64,
pub description: String,
pub direction: String,
pub last: f64,
pub symbol: String,
pub total_volume: i64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Account {
pub securities_account: SecuritiesAccount,
}
#[derive(Debug, Deserialize)]
#[serde(untagged)]
pub enum SecuritiesAccount {
#[serde(rename_all = "camelCase")]
MarginAccount {
r#type: String,
account_id: String,
round_trips: usize,
is_day_trader: bool,
is_closing_only_restricted: bool,
initial_balances: InitialBalances,
current_balances: CurrentBalances,
projected_balances: ProjectedBalances,
},
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InitialBalances {
pub account_value: f64,
pub accrued_interest: f64,
pub bond_value: f64,
pub cash_available_for_trading: f64,
pub cash_available_for_withdrawal: f64,
pub cash_balance: f64,
pub cash_debit_call_value: f64,
pub cash_receipts: f64,
pub is_in_call: bool,
pub liquidation_value: f64,
pub long_option_market_value: f64,
pub money_market_fund: f64,
pub mutual_fund_value: f64,
pub pending_deposits: f64,
pub short_option_market_value: f64,
pub short_stock_value: f64,
pub unsettled_cash: f64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CurrentBalances {
pub accrued_interest: f64,
pub bond_value: f64,
pub cash_available_for_trading: f64,
pub cash_available_for_withdrawal: f64,
pub cash_balance: f64,
pub cash_call: f64,
pub cash_debit_call_value: f64,
pub cash_receipts: f64,
pub liquidation_value: f64,
pub long_market_value: f64,
pub long_option_market_value: f64,
pub money_market_fund: f64,
pub mutual_fund_value: f64,
pub pending_deposits: f64,
pub savings: f64,
pub short_market_value: f64,
pub short_option_market_value: f64,
pub total_cash: f64,
pub unsettled_cash: f64,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProjectedBalances {
pub cash_available_for_trading: f64,
pub cash_available_for_withdrawal: f64,
}