简体   繁体   English

用于获取价格历史记录的 TDAmeritrade API 返回空白

[英]TDAmeritrade API for getting price history returns blank

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}它返回: {'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. TDAmeritrade api 不允许您同时使用periodstartDate/endDate Remove the period from your payload and it should work.从您的有效负载中删除句点,它应该可以工作。 Also, make sure that your times are corresponding 6.00am.另外,请确保您的时间对应于早上 6 点。

I was watching the same tutorial and encountered this problem.我正在观看相同的教程并遇到了这个问题。 I changed the startDate and endDate and it returned an output我更改了 startDate 和 endDate,它返回了 output

for instance, use:例如,使用:

'endDate':'1659697860000',
'startDate': '1659697500000', 

you should get an output.你应该得到一个 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. pdrersin 提到时间应该对应于早上 6:00,但不知道在这种情况下这意味着什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM