alexgolec / tda-api

A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
https://tda-api.readthedocs.io
MIT License
1.27k stars 338 forks source link

Get market hours API does not work #167

Closed SunnyRaj closed 3 years ago

SunnyRaj commented 3 years ago

Description of Bug

get_hours_for_single_market always returns an error

Code to Reproduce

response = client.get_hours_for_single_market(client.Markets.EQUITY, datetime.datetime.today())
print(json.dumps(response.json()))

Expected Behavior

{
  "equity": {
    "EQ": {
      "date": "2021-02-11",
      "marketType": "EQUITY",
      "exchange": "NULL",
      "category": "NULL",
      "product": "EQ",
      "productName": "equity",
      "isOpen": true,
      "sessionHours": {
        "preMarket": [
          {
            "start": "2021-02-11T07:00:00-05:00",
            "end": "2021-02-11T09:30:00-05:00"
          }
        ],
        "regularMarket": [
          {
            "start": "2021-02-11T09:30:00-05:00",
            "end": "2021-02-11T16:00:00-05:00"
          }
        ],
        "postMarket": [
          {
            "start": "2021-02-11T16:00:00-05:00",
            "end": "2021-02-11T20:00:00-05:00"
          }
        ]
      }
    }
  }
}

Actual Behavior

{
    "timestamp": "2021-02-11",
    "status": 400,
    "error": "Bad Request",
    "message": "Input date is not acceptable.",
    "path": "/markethours-v1/markets/EQUITY"
}
SunnyRaj commented 3 years ago

This seems to be working now. The error is most likely a timing issue on the server.