import sys sys.path.insert(0, "/home/hoon/kis_bot") from database import TradeDB from kis_trader.utils.env import invalidate_merged_env_cache db = TradeDB() try: snap = dict(db.get_merged_env_snapshot() or {}) changed = False print("=== 전략별 CAND_LIMIT 20 으로 변경 (수정) ===") strategies = ["SCALP", "BREAKOUT", "MOMENTUM", "TAIL", "SHORT", "RANGE_BREAK", "UPDOW", "DBBAND", "HOLDING", "US_MOMENTUM", "US_BREAKOUT"] for sid in strategies: # 삭제할 잘못된 키 bad_key = f"{sid}_cand_limit" if bad_key in snap: print(f" 잘못된 키 삭제: {bad_key}") del snap[bad_key] changed = True # 올바른 키 key = f"{sid}_CAND_LIMIT" current_val = snap.get(key) if current_val is not None and str(current_val).strip() != "": if int(current_val) != 20: print(f" {key}: {current_val} -> 20") snap[key] = 20 changed = True else: print(f" {key}: None -> 20 (새로 추가)") snap[key] = 20 changed = True if changed: db.insert_env_snapshot(snap) invalidate_merged_env_cache() print("\n✅ DB 업데이트 및 캐시 무효화 완료!") else: print("\n✅ 이미 설정되어 있습니다.") finally: db.close()