merge and kill task fixes

This commit is contained in:
Dobromir Popov
2025-11-22 21:10:09 +02:00
parent 3f7404ad39
commit 30db9d722e
5 changed files with 92 additions and 9 deletions

View File

@@ -206,11 +206,11 @@ class DuckDBStorage:
# Insert data directly into DuckDB (ignore duplicates)
# Note: id column is auto-generated, so we don't include it
# Using INSERT OR IGNORE for better DuckDB compatibility
self.conn.execute("""
INSERT INTO ohlcv_data (symbol, timeframe, timestamp, open, high, low, close, volume, created_at)
INSERT OR IGNORE INTO ohlcv_data (symbol, timeframe, timestamp, open, high, low, close, volume, created_at)
SELECT symbol, timeframe, timestamp, open, high, low, close, volume, created_at
FROM df_insert
ON CONFLICT DO NOTHING
""")
# Update metadata
@@ -223,7 +223,11 @@ class DuckDBStorage:
WHERE symbol = ? AND timeframe = ?
""", (symbol, timeframe)).fetchone()
first_ts, last_ts, count = result
# Handle case where no data exists yet
if result is None or result[0] is None:
first_ts, last_ts, count = 0, 0, 0
else:
first_ts, last_ts, count = result
now_ts = int(datetime.now().timestamp() * 1000)
self.conn.execute("""