refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.

This commit is contained in:
Your Name
2026-08-12 10:19:19 +09:00
parent cb7e5037a0
commit c6bd62a25f
218 changed files with 31613 additions and 759 deletions

View File

@@ -0,0 +1,19 @@
import sys
sys.path.append('.')
from database import TradeDB
from datetime import timedelta
db = TradeDB()
try:
res = db.conn.execute("SELECT code, buy_date, pnl FROM trade_history WHERE strategy='MOMENTUM' AND pnl > 0 ORDER BY buy_date DESC LIMIT 1").fetchone()
if res:
code, buy_dt = dict(res)["code"], dict(res)["buy_date"]
start_time = (buy_dt - timedelta(seconds=180)).strftime("%Y%m%d%H%M%S")
end_time = buy_dt.strftime("%Y%m%d%H%M%S")
print(f"Fetching ticks for {code} from {start_time} to {end_time}")
ticks = db.get_ws_ticks(code, market="KR", start_tick_time=start_time, end_tick_time=end_time)
print(f"Found {len(ticks)} ticks")
else:
print("No trades found")
finally:
db.close()