From ae5692cde4421c9cc857e1fe0e2aeafe3da44d14 Mon Sep 17 00:00:00 2001 From: 21in7 Date: Thu, 5 Mar 2026 23:14:38 +0900 Subject: [PATCH] feat: MLFilter falls back to models/ root if symbol-specific dir not found Co-Authored-By: Claude Opus 4.6 --- src/bot.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bot.py b/src/bot.py index 474e536..12a01d8 100644 --- a/src/bot.py +++ b/src/bot.py @@ -1,5 +1,6 @@ import asyncio from collections import deque +from pathlib import Path import pandas as pd from loguru import logger from src.config import Config @@ -20,7 +21,19 @@ class TradingBot: self.exchange = BinanceFuturesClient(config, symbol=self.symbol) self.notifier = DiscordNotifier(config.discord_webhook_url) self.risk = risk or RiskManager(config) - self.ml_filter = MLFilter(threshold=config.ml_threshold) + # 심볼별 모델 디렉토리. 없으면 기존 models/ 루트로 폴백 + symbol_model_dir = Path(f"models/{self.symbol.lower()}") + if symbol_model_dir.exists(): + onnx_path = str(symbol_model_dir / "mlx_filter.weights.onnx") + lgbm_path = str(symbol_model_dir / "lgbm_filter.pkl") + else: + onnx_path = "models/mlx_filter.weights.onnx" + lgbm_path = "models/lgbm_filter.pkl" + self.ml_filter = MLFilter( + onnx_path=onnx_path, + lgbm_path=lgbm_path, + threshold=config.ml_threshold, + ) self.current_trade_side: str | None = None # "LONG" | "SHORT" self._entry_price: float | None = None self._entry_quantity: float | None = None