- OKX交易自动化 (okx-auto-position, okx-crypto, okx-exchange) - 交易信号处理 (signal-confirmation-templates, trading-signal-aggregator) - 量化因子挖掘 (quant-factor-mining) - 长桥集成 (longbridge-cli, longbridge-python-sdk) - 六合彩分析 (lottery-hk) - 股息投资 (dividend-investing, dividend-scanner) - 日内交易 (intraday-trading) - 同花顺 (tonghuashun)
28 lines
601 B
Python
28 lines
601 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Trading config loader
|
|
从 config.json 读取所有交易参数,消除硬编码
|
|
"""
|
|
|
|
import json, os
|
|
|
|
CONFIG_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'config.json')
|
|
|
|
def load_config():
|
|
with open(CONFIG_PATH) as f:
|
|
return json.load(f)
|
|
|
|
# Singleton
|
|
_config = None
|
|
|
|
def get_config():
|
|
global _config
|
|
if _config is None:
|
|
_config = load_config()
|
|
return _config
|
|
|
|
def get(section, key, default=None):
|
|
"""获取配置值: get('atr', 'multiplier')"""
|
|
cfg = get_config()
|
|
return cfg.get(section, {}).get(key, default)
|