Robinhood API Python

时间:2018-07-08 19:36:45

标签: python json python-2.7 python-requests

Robinhood API发生了一些奇怪的事情。特别是在获取所有期权工具时(只是有关期权的数据)。以下代码是我的程序的一部分

def get_options_instruments(self):

        params = {
        "chain_symbol" : "AMD",
        "chain_id" : "e66ce029-db96-4572-87a0-b144613c08bf",
        "type": "call",
        "state": "active",
        "tradability": "tradable",
        "strike_price" : "16.0000",
        "expiration_date": "2018-10-19"
        }


        #API_URLS['option-instrument']= "https://api.robinhood.com/options/instruments/"
        response = self.login_session.get(API_URLS['option-instrument'],params = params)
        response = response.json()["results"]
        print(json.dumps(response,indent = 4,separators=(',', ': ')))#'option-instrument'       : "https://api.robinhood.com/options/instruments/",

所有参数似乎都在接收期权工具时有效,除了到期日(这是我需要使用的最重要的参数之一)。以下是期权工具的示例响应。

{
    "issue_date": "1987-01-12",
    "strike_price": "16.0000",
    "url": "https://api.robinhood.com/options/instruments/3cb75cca-0987-46d7-bff1-20cadfb74a83/",
    "expiration_date": "2018-07-20",
    "tradability": "tradable",
    "chain_id": "e66ce029-db96-4572-87a0-b144613c08bf",
    "updated_at": "2018-06-03T00:16:56.985489Z",
    "min_ticks": {
        "cutoff_price": "3.00",
        "below_tick": "0.01",
        "above_tick": "0.05"
    },
    "state": "active",
    "id": "3cb75cca-0987-46d7-bff1-20cadfb74a83",
    "chain_symbol": "AMD",
    "type": "call",
    "created_at": "2017-11-18T04:15:17.795113Z"
}

我只是想知道是否有人知道为什么会发生这种情况?可能是API方面的事情而不是我的事情吗?谢谢。

1 个答案:

答案 0 :(得分:0)

改为使用"expiration_dates",它将起作用。

我最近也遇到了这个问题,在"expiration_date"字段中指定参数不会产生任何结果。