【问题标题】:TD Ameritrade API 'Get Option Chain' giving <Response [200]> but I'm getting JSONDecodeError: Expecting value?TD Ameritrade API 'Get Option Chain' 给出 <Response [200]> 但我收到 JSONDecodeError: Expecting value?
【发布时间】:2021-06-24 08:57:42
【问题描述】:

生成 access_token(当我在 TD Ameritrade 的 API 网站上使用它时有效)后,我正在尝试获取股票的期权链。我可以让它在 TD Ameritrade 的 API 网站上运行,我在运行代码时得到“OKAY”响应,但没有附加 JSON 数据,知道为什么吗?我的相关代码如下。

content = requests.get(url = https://api.tdameritrade.com/v1/marketdata/chains, params = params_dictionary, headers = access_token)
print(content)
print(repr(content.text))
data = content.json()
print(data)

但是对于我的输出,我得到了

<Response [200]>
''
Traceback (most recent call last):

  File "C:\Users\USER\Documents\GitHub\pythonfiles\TD Ameritrade API tests.py", line 98, in <module>
    data = content.json()

  File "C:\Users\USER\Anaconda3\lib\site-packages\requests\models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)

  File "C:\Users\USER\Anaconda3\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)

  File "C:\Users\USER\Anaconda3\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "C:\Users\USER\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

JSONDecodeError: Expecting value

【问题讨论】:

    标签: python json api


    【解决方案1】:

    这是我的一个错误,但在我的问题中没有显示出来。我不小心使用了“https://api.tdameritrade.com/v1/marketdata/https://api.tdameritrade.com/v1/marketdata/chains”作为我的 URL。我不确定这不会破坏事情,但这是我的问题。

    【讨论】:

      猜你喜欢
      • 2017-05-11
      • 2020-09-05
      • 2022-06-11
      • 2012-02-27
      • 1970-01-01
      • 2021-09-29
      • 2019-08-06
      • 2020-04-19
      • 1970-01-01
      相关资源
      最近更新 更多