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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Structs and utilities for building API request parameters.

/// Parameters for the `get_account()` method.
///
/// [API Documentation](https://developer.tdameritrade.com/account-access/apis/get/accounts/%7BaccountId%7D-0)
#[derive(Debug)]
pub struct GetAccountParams {
    /// Balances displayed by default, additional fields can be added here by adding `positions` or `orders`
    ///
    /// Choices: `positions` or `orders`
    pub fields: Option<String>,
}

impl Default for GetAccountParams {
    fn default() -> Self {
        Self {
            fields: None,
        }
    }
}

/// Parameters for the `get_accounts()` method.
///
/// [API Documentation](https://developer.tdameritrade.com/account-access/apis/get/accounts-0)
#[derive(Debug)]
pub struct GetAccountsParams {
    /// Balances displayed by default, additional fields can be added here by adding `positions` or `orders`
    ///
    /// Choices: `positions` or `order`s
    pub fields: Option<String>,
}

impl Default for GetAccountsParams {
    fn default() -> Self {
        Self {
            fields: None,
        }
    }
}

/// Parameters for the `get_movers()` method.
///
/// [API Documentation](https://developer.tdameritrade.com/movers/apis/get/marketdata/%7Bindex%7D/movers)
#[derive(Debug)]
pub struct GetMoversParams {
    /// To return movers with the specified directions of up or down
    ///
    /// Choices: `up` or `down`
    pub change: Option<String>,

    /// To return movers with the specified change types of percent or value
    ///
    /// Choices: `value` or `percent`
    pub direction: Option<String>,
}

impl Default for GetMoversParams {
    fn default() -> Self {
        Self {
            change: None,
            direction: None,
        }
    }
}

/// Parameters for the `get_price_history()` method.
///
/// [API Documentation](https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory)
#[derive(Debug)]
pub struct GetPriceHistoryParams {
    /// End date as milliseconds since epoch. If startDate and endDate are
    /// provided, period should not be provided. Default is previous trading
    /// day.
    pub end_date: Option<String>,

    /// The type of frequency with which a new candle is formed.
    ///
    /// Valid frequencyTypes by periodType (defaults marked with an asterisk):
    ///
    /// `day`: minute*
    ///
    /// `month`: daily, weekly*
    ///
    /// `year`: daily, weekly, monthly*
    ///
    /// `ytd`: daily, weekly*
    pub frequency_type: Option<String>,

    /// The number of the frequencyType to be included in each candle.
    ///
    /// Valid frequencies by frequencyType (defaults marked with an asterisk):
    ///
    /// `minute`: 1*, 5, 10, 15, 30
    ///
    /// `daily`: 1*
    ///
    /// `weekly`: 1*
    ///
    /// `monthly`: 1*
    pub frequency: Option<String>,

    /// `true` to return extended hours data, `false` for regular market hours
    /// only. Default is `true`
    pub need_extended_hours_data: Option<bool>,

    /// The type of period to show. Valid values are `day`, `month`, `year`, or
    /// `ytd` (year to date). Default is `day`.
    pub period_type: Option<String>,

    /// The number of periods to show.
    ///
    /// Example: For a 2 day / 1 min chart, the values would be:
    ///
    /// `period`: 2
    ///
    /// `periodType`: day
    ///
    /// `frequency`: 1
    ///
    /// `frequencyType`: min
    ///
    /// Valid periods by periodType (defaults marked with an asterisk):
    ///
    /// `day`: 1, 2, 3, 4, 5, 10*
    ///
    /// `month`: 1*, 2, 3, 6
    ///
    /// `year`: 1*, 2, 3, 5, 10, 15, 20
    ///
    /// `ytd`: 1*
    pub period: Option<String>,

    /// Start date as milliseconds since epoch. If startDate and endDate are
    /// provided, period should not be provided.
    pub start_date: Option<String>,
}

impl Default for GetPriceHistoryParams {
    fn default() -> Self {
        Self {
            end_date: None,
            frequency_type: None,
            frequency: None,
            need_extended_hours_data: None,
            period_type: None,
            period: None,
            start_date: None,
        }
    }
}