tda_sdk/params.rs
1//! Structs and utilities for building API request parameters.
2
3/// Parameters for the `get_account()` method.
4///
5/// [API Documentation](https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D-0)
6#[derive(Debug)]
7pub struct GetAccountParams {
8 /// Balances displayed by default, additional fields can be added here by adding `positions` or `orders`
9 ///
10 /// Choices: `positions` or `orders`
11 pub fields: Option<String>,
12}
13
14impl Default for GetAccountParams {
15 fn default() -> Self {
16 Self {
17 fields: None,
18 }
19 }
20}
21
22/// Parameters for the `get_accounts()` method.
23///
24/// [API Documentation](https://developer.tdameritrade.com/account-access/apis/get/accounts-0)
25#[derive(Debug)]
26pub struct GetAccountsParams {
27 /// Balances displayed by default, additional fields can be added here by adding `positions` or `orders`
28 ///
29 /// Choices: `positions` or `order`s
30 pub fields: Option<String>,
31}
32
33impl Default for GetAccountsParams {
34 fn default() -> Self {
35 Self {
36 fields: None,
37 }
38 }
39}
40
41/// Parameters for the `get_movers()` method.
42///
43/// [API Documentation](https://developer.tdameritrade.com/movers/apis/get/marketdata/%7Bindex%7D/movers)
44#[derive(Debug)]
45pub struct GetMoversParams {
46 /// To return movers with the specified directions of up or down
47 ///
48 /// Choices: `up` or `down`
49 pub change: Option<String>,
50
51 /// To return movers with the specified change types of percent or value
52 ///
53 /// Choices: `value` or `percent`
54 pub direction: Option<String>,
55}
56
57impl Default for GetMoversParams {
58 fn default() -> Self {
59 Self {
60 change: None,
61 direction: None,
62 }
63 }
64}
65
66/// Parameters for the `get_price_history()` method.
67///
68/// [API Documentation](https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory)
69#[derive(Debug)]
70pub struct GetPriceHistoryParams {
71 /// End date as milliseconds since epoch. If startDate and endDate are
72 /// provided, period should not be provided. Default is previous trading
73 /// day.
74 pub end_date: Option<String>,
75
76 /// The type of frequency with which a new candle is formed.
77 ///
78 /// Valid frequencyTypes by periodType (defaults marked with an asterisk):
79 ///
80 /// `day`: minute*
81 ///
82 /// `month`: daily, weekly*
83 ///
84 /// `year`: daily, weekly, monthly*
85 ///
86 /// `ytd`: daily, weekly*
87 pub frequency_type: Option<String>,
88
89 /// The number of the frequencyType to be included in each candle.
90 ///
91 /// Valid frequencies by frequencyType (defaults marked with an asterisk):
92 ///
93 /// `minute`: 1*, 5, 10, 15, 30
94 ///
95 /// `daily`: 1*
96 ///
97 /// `weekly`: 1*
98 ///
99 /// `monthly`: 1*
100 pub frequency: Option<String>,
101
102 /// `true` to return extended hours data, `false` for regular market hours
103 /// only. Default is `true`
104 pub need_extended_hours_data: Option<bool>,
105
106 /// The type of period to show. Valid values are `day`, `month`, `year`, or
107 /// `ytd` (year to date). Default is `day`.
108 pub period_type: Option<String>,
109
110 /// The number of periods to show.
111 ///
112 /// Example: For a 2 day / 1 min chart, the values would be:
113 ///
114 /// `period`: 2
115 ///
116 /// `periodType`: day
117 ///
118 /// `frequency`: 1
119 ///
120 /// `frequencyType`: min
121 ///
122 /// Valid periods by periodType (defaults marked with an asterisk):
123 ///
124 /// `day`: 1, 2, 3, 4, 5, 10*
125 ///
126 /// `month`: 1*, 2, 3, 6
127 ///
128 /// `year`: 1*, 2, 3, 5, 10, 15, 20
129 ///
130 /// `ytd`: 1*
131 pub period: Option<String>,
132
133 /// Start date as milliseconds since epoch. If startDate and endDate are
134 /// provided, period should not be provided.
135 pub start_date: Option<String>,
136}
137
138impl Default for GetPriceHistoryParams {
139 fn default() -> Self {
140 Self {
141 end_date: None,
142 frequency_type: None,
143 frequency: None,
144 need_extended_hours_data: None,
145 period_type: None,
146 period: None,
147 start_date: None,
148 }
149 }
150}