refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.
This commit is contained in:
22
scratch/update_optuna_jobs.py
Normal file
22
scratch/update_optuna_jobs.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from database import TradeDB
|
||||
import json
|
||||
|
||||
db = TradeDB()
|
||||
try:
|
||||
for strat in ['MOMENTUM', 'BREAKOUT', 'SCALP', 'TAIL']:
|
||||
row = db.conn.execute("SELECT id, out_data FROM optuna_jobs WHERE strategy=%s ORDER BY id DESC LIMIT 1", (strat,)).fetchone()
|
||||
if not row: continue
|
||||
|
||||
job_id = row['id']
|
||||
out_data = json.loads(row['out_data'] or '{}')
|
||||
|
||||
# Get latest whipsaw result
|
||||
# Actually I can just run attach_whipsaw_recommend on this out_data
|
||||
from kis_trader.backtest.optuna_whipsaw_recommend import attach_whipsaw_recommend
|
||||
out_data = attach_whipsaw_recommend(out_data)
|
||||
|
||||
db.conn.execute("UPDATE optuna_jobs SET out_data=%s WHERE id=%s", (json.dumps(out_data, ensure_ascii=False), job_id))
|
||||
db.conn.commit()
|
||||
print(f"Updated job {job_id} for {strat}")
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user