Here's the code that i am currently using...
endpoint = r'https://api.tdameritrade.com/v1/marketdata/{}/pricehistory'.format('MSFT')
payload = {
'apikey':client_id,
'periodType':'day',
'frequencyType':'minute',
'frequency':'1',
'period':'2',
'endDate':'1556158524000',
'startDate':'1554535854000',
'needExtendedHoursData':'false'
}
content = requests.get(url = endpoint, params = payload)
data = content.json()
data
It returns: {'candles': [], 'symbol': 'MSFT', 'empty': True}
I've tried doing it without the payload and it works fine, but i really would like to clean it up using the method now. Does anyone know the issue here?
The TDAmeritrade api does not let you use period
and startDate/endDate
together. Remove the period from your payload and it should work. Also, make sure that your times are corresponding 6.00am.
I was watching the same tutorial and encountered this problem. I changed the startDate and endDate and it returned an output
for instance, use:
'endDate':'1659697860000',
'startDate': '1659697500000',
you should get an output.
I'm still confused, as using other, seemingly valid, start and end dates returns blank.
I'm a noob so I can't tell what end/starts are valid, but it's clearly the main issue. pdrersin mentioned that the times should be corresponding to 6:00am, but idk what that means in this context.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.