Hi Brian,
I've been getting this error almost every day for the last few weeks and am unable to complete the daily collection of my IBKR minute-level history database.
2022-01-03 19:25:48 quantrocket.history: INFO [ibkr-minute-db] Expected remaining runtime to collect ibkr-minute-db history based on IBKR response times so far: 5:10:56 (15830 more requests for 7836 securities @ 4.71s/request across 4 gateways)
2022-01-03 19:30:25 quantrocket.history: ERROR Traceback (most recent call last):
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1245, in _execute_context
2022-01-03 19:30:25 quantrocket.history: ERROR self.dialect.do_execute(
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
2022-01-03 19:30:25 quantrocket.history: ERROR cursor.execute(statement, parameters)
2022-01-03 19:30:25 quantrocket.history: ERROR sqlite3.OperationalError: no such table: Price
2022-01-03 19:30:25 quantrocket.history: ERROR
2022-01-03 19:30:25 quantrocket.history: ERROR The above exception was the direct cause of the following exception:
2022-01-03 19:30:25 quantrocket.history: ERROR
2022-01-03 19:30:25 quantrocket.history: ERROR Traceback (most recent call last):
2022-01-03 19:30:25 quantrocket.history: ERROR File "sym://qrocket_history_collect_ibkr_workers_py", line 28, in wrapped
2022-01-03 19:30:25 quantrocket.history: ERROR File "sym://qrocket_history_collect_ibkr_storage_py", line 57, in run
2022-01-03 19:30:25 quantrocket.history: ERROR File "sym://qrocket_history_collect_ibkr_storage_py", line 131, in _handle_adjustments_detected
2022-01-03 19:30:25 quantrocket.history: ERROR File "sym://qrocket_history_collect_backends_base_py", line 43, in delete_by_sid
2022-01-03 19:30:25 quantrocket.history: ERROR File "sym://qrocket_history_collect_backends_shard_py", line 132, in execute
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2182, in execute
2022-01-03 19:30:25 quantrocket.history: ERROR return connection.execute(statement, *multiparams, **params)
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 976, in execute
2022-01-03 19:30:25 quantrocket.history: ERROR return self._execute_text(object_, multiparams, params)
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1143, in _execute_text
2022-01-03 19:30:25 quantrocket.history: ERROR ret = self._execute_context(
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
2022-01-03 19:30:25 quantrocket.history: ERROR self._handle_dbapi_exception(
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception
2022-01-03 19:30:25 quantrocket.history: ERROR util.raise_from_cause(sqlalchemy_exception, exc_info)
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
2022-01-03 19:30:25 quantrocket.history: ERROR reraise(type(exception), exception, tb=exc_tb, cause=cause)
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
2022-01-03 19:30:25 quantrocket.history: ERROR raise value.with_traceback(tb)
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1245, in _execute_context
2022-01-03 19:30:25 quantrocket.history: ERROR self.dialect.do_execute(
2022-01-03 19:30:25 quantrocket.history: ERROR File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
2022-01-03 19:30:25 quantrocket.history: ERROR cursor.execute(statement, parameters)
2022-01-03 19:30:25 quantrocket.history: ERROR sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: Price
2022-01-03 19:30:25 quantrocket.history: ERROR [SQL:
2022-01-03 19:30:25 quantrocket.history: ERROR DELETE
2022-01-03 19:30:25 quantrocket.history: ERROR FROM Price
2022-01-03 19:30:25 quantrocket.history: ERROR WHERE Sid IN (?)
2022-01-03 19:30:25 quantrocket.history: ERROR ]
2022-01-03 19:30:25 quantrocket.history: ERROR [parameters: ('FIBBG000Q0BPZ4',)]
2022-01-03 19:30:25 quantrocket.history: ERROR (Background on this error at: http://sqlalche.me/e/e3q8)
2022-01-03 19:30:25 quantrocket.history: ERROR
2022-01-03 19:30:28 quantrocket.history: INFO [ibkr-minute-db] Exiting due to errors
The SID referenced in the fourth line from the bottom is different each time I restart the collection. There is something about "_handle_adjustments_detected" in the traceback, so perhaps this happens only with SIDs that require adjustments on a particular day?
I can't give you SIDs to reproduce the error with, because they change with every attempt to collect.
I've gone into the sqlite file of the referenced SIDs to check for the Price table, and it does exist. For example:
jupyter:/var/lib/quantrocket/quantrocket.v2.history.ibkr-minute-db.sqlite/sid $ sqlite3 quantrocket.v2.history.ibkr-minute-db.FIBBG000Q0BPZ4.sqlite
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> .schema
CREATE TABLE Price (
Sid VARCHAR(20) NOT NULL,
Date DATETIME PRIMARY KEY NOT NULL, -- Date alone is PK, since only 1 Sid per shard
Open DOUBLE DEFAULT NULL,
High DOUBLE DEFAULT NULL,
Low DOUBLE DEFAULT NULL,
Close DOUBLE DEFAULT NULL,
Volume INT DEFAULT NULL,
Wap DOUBLE DEFAULT NULL,
TradeCount INT DEFAULT NULL,
DayHigh DOUBLE DEFAULT NULL,
DayLow DOUBLE DEFAULT NULL,
DayVolume INT DEFAULT NULL
);
CREATE INDEX PriceTimeDateIndex ON Price(SUBSTR("Date",12,8),Date);
sqlite> .tables
Price
sqlite> SELECT * FROM Price;
sqlite>
Any thoughts on how to fix? I cannot reliably complete history IBKR collection and don't know how to debug further, since I can't access the code behind collect_history()
.