auto_trade_sys/update_strategy_config.py
薇薇安 b4b001833f 1
2026-02-06 08:31:10 +08:00

35 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
import os
from pathlib import Path
# Add project root to sys.path
project_root = Path(__file__).resolve().parent
sys.path.insert(0, str(project_root))
sys.path.insert(0, str(project_root / 'backend'))
try:
from backend.database.models import GlobalStrategyConfig
updates = [
('ATR_STOP_LOSS_MULTIPLIER', 1.5, 'float', 'risk', 'ATR止损倍数优化后1.5'),
('TAKE_PROFIT_1_PERCENT', 0.25, 'float', 'strategy', '第一目标止盈25%(优化后)'),
('ATR_TAKE_PROFIT_MULTIPLIER', 2.0, 'float', 'risk', 'ATR止盈倍数'),
# Also ensure USE_ATR_STOP_LOSS is True
('USE_ATR_STOP_LOSS', True, 'bool', 'risk', '开启ATR止损'),
# 2026-02-06 Optimization: Increase candidate pool
('TOP_N_SYMBOLS', 20, 'int', 'scanner', '候选池大小优化后20'),
('SCAN_EXTRA_SYMBOLS_FOR_SUPPLEMENT', 15, 'int', 'scanner', '补单候选池优化后15'),
('MAX_SCAN_SYMBOLS', 500, 'int', 'scanner', '最大扫描数量优化后500'),
]
print("Updating Global Strategy Config...")
for key, value, type_, category, desc in updates:
print(f"Setting {key} = {value}")
GlobalStrategyConfig.set(key, value, type_, category, description=desc, updated_by='system_optimizer')
print("Done.")
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()