No trading hours available for IDEALPRO before requested datetime

When I run this command in the crontab or in the notebook:

quantrocket master isopen 'IDEALPRO' 

I get the following the error:

Traceback (most recent call last):
  File "/opt/conda/bin/quantrocket", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.9/site-packages/quantrocket/_cli/commands.py", line 97, in main
    result, exit_code = func(**args)
  File "/opt/conda/lib/python3.9/site-packages/quantrocket/master.py", line 1596, in _cli_isopen
    statuses = list_calendar_statuses(exchanges, sec_type=sec_type, in_=in_, ago=ago, outside_rth=outside_rth)
  File "/opt/conda/lib/python3.9/site-packages/quantrocket/master.py", line 1527, in list_calendar_statuses
    houston.raise_for_status_with_json(response)
  File "/opt/conda/lib/python3.9/site-packages/quantrocket/houston.py", line 225, in raise_for_status_with_json
    raise e
  File "/opt/conda/lib/python3.9/site-packages/quantrocket/houston.py", line 217, in raise_for_status_with_json
    response.raise_for_status()
  File "/opt/conda/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: ('400 Client Error: BAD REQUEST for url: http://houston/master/calendar?exchanges=IDEALPRO', {'status': 'error', 'msg': 'no trading hours available for IDEALPRO before requested datetime'})

Please help!

For IDEALPRO, you need to first collect the trading hours from IBKR:

quantrocket master collect-ibkr-calendar -e IDEALPRO

IBKR only provides calendar information a few days into the future, so you should schedule that to run on your crontab, I would suggest every day.

Alternatively, you can use the 24/5 calendar which is built-in and doesn't have to be collected. It should approximate the IDEALPRO calendar but I don't know if it's identical.

quantrocket master isopen '24/5'

For some reason, I still get the same error. Here's what I have tried:

quantrocket master collect-ibkr-calendar -e IDEALPRO

Logs:

2023-12-16 12:55:22 quantrocket.master: INFO Collecting IBKR trading hours for IDEALPRO
2023-12-16 12:55:24 quantrocket.master: INFO Saved 20 total IBKR calendar records for IDEALPRO
quantrocket master collect-ibkr-calendar

Logs:

2023-12-16 13:18:55 quantrocket.master: INFO Collecting IBKR trading hours for NYSE, IDEALPRO
2023-12-16 13:19:02 quantrocket.master: WARNING ibg1 client 122197 got IBKR message code 504: Not connected
2023-12-16 13:19:02 quantrocket.master: WARNING [ibg1] Attempting reconnect due to error code 504
2023-12-16 13:19:03 quantrocket.master: WARNING [ibg1] Reconnect succeeded
2023-12-16 13:19:04 quantrocket.master: INFO Saved 36 total IBKR calendar records for NYSE, IDEALPRO
2023-12-16 13:19:11 quantrocket.moonshot: INFO status: success
...

Then I run:

quantrocket master isopen IDEALPRO

Error:

Traceback (most recent call last):
  File "/codeload/sigma/bin/quantrocket", line 8, in <module>
    sys.exit(main())
  File "/codeload/sigma/lib/python3.9/site-packages/quantrocket/_cli/commands.py", line 97, in main
    result, exit_code = func(**args)
  File "/codeload/sigma/lib/python3.9/site-packages/quantrocket/master.py", line 1596, in _cli_isopen
    statuses = list_calendar_statuses(exchanges, sec_type=sec_type, in_=in_, ago=ago, outside_rth=outside_rth)
  File "/codeload/sigma/lib/python3.9/site-packages/quantrocket/master.py", line 1527, in list_calendar_statuses
    houston.raise_for_status_with_json(response)
  File "/codeload/sigma/lib/python3.9/site-packages/quantrocket/houston.py", line 225, in raise_for_status_with_json
    raise e
  File "/codeload/sigma/lib/python3.9/site-packages/quantrocket/houston.py", line 217, in raise_for_status_with_json
    response.raise_for_status()
  File "/codeload/sigma/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: ('400 Client Error: BAD REQUEST for url: http://houston/master/calendar?exchanges=IDEALPRO', {'status': 'error', 'msg': 'no trading hours available for IDEALPRO before requested datetime'})

This is a one-time issue because it's your first time collecting that data and IBKR only returns trading hours for the future, so QuantRocket can't yet determine the open/closed status. You can directly query the database like this to see what was collected:

sqlite3 /var/lib/quantrocket/quantrocket.v2.master.main.sqlite 'select * from IBKRTradingHours where exchange = "IDEALPRO"'
IDEALPRO|CASH|2023-12-17T17:15:00|1|0
IDEALPRO|CASH|2023-12-18T17:00:00|0|0
IDEALPRO|CASH|2023-12-18T17:15:00|1|0
IDEALPRO|CASH|2023-12-19T17:00:00|0|0
...

The issue will resolve on its own once 2023-12-17 at 17:15 arrives.