altanalytics / rameritrade

R package for the TD Ameritrade API
GNU General Public License v3.0
14 stars 8 forks source link

How to request minute data? #6

Closed prRZ5F4LXZ closed 3 years ago

prRZ5F4LXZ commented 3 years ago

I am trying to request minute data. But I was not successful. How to request minute data?

R> tickHistDay = td_priceHistory(c('SPY','IWM'), startDate = '1990-01-01')
No encoding supplied: defaulting to UTF-8.
No encoding supplied: defaulting to UTF-8.
R> head(tickHistDay)
# A tibble: 6 x 8
  ticker date       date_time            open  high   low close  volume
  <chr>  <date>     <dttm>              <dbl> <dbl> <dbl> <dbl>   <int>
1 SPY    1993-01-29 1993-01-29 01:00:00  44.0  44.0  43.8  43.9 1003200
2 SPY    1993-02-01 1993-02-01 01:00:00  44.0  44.2  44.0  44.2  480500
3 SPY    1993-02-02 1993-02-02 01:00:00  44.2  44.4  44.1  44.3  201300
4 SPY    1993-02-03 1993-02-03 01:00:00  44.4  44.8  44.4  44.8  529400
5 SPY    1993-02-04 1993-02-04 01:00:00  45.0  45.1  44.5  45    531500
6 SPY    1993-02-05 1993-02-05 01:00:00  45.0  45.1  44.7  45.0  492100
R> tickHistDay = td_priceHistory(c('SPY','IWM'), startDate = '1990-01-01', freq='1m')
Error: 400 - Bad request.
R> tickHistDay = td_priceHistory(c('SPY','IWM'), startDate = '2020-01-01', freq='1m')
Error: 400 - Bad request.
R> tickHistDay = td_priceHistory(c('SPY','IWM'), startDate = '2020-01-01', endDate='2020-01-10', freq='1m')
Error: 400 - Bad request.
R> tickHistDay = td_priceHistory(c('SPY','IWM'), startDate = '2020-07-11', freq='1m')
Error: 400 - Bad request.
altanalytics commented 3 years ago

minute level data is only available going back a couple months. additonally, you need to pass '1min' not '1m'

td_priceHistory(c('SPY','IWM'), startDate = '2021-06-01', freq='1min')