feat: AlphaSift disabled by default (ALPHASIFT_ENABLED=false), add --enable flag
This commit is contained in:
@@ -29,6 +29,9 @@ MAX_ADD = 5
|
||||
POLL_INTERVAL = 5
|
||||
POLL_TIMEOUT = 300
|
||||
|
||||
# 全局开关: ALPHASIFT_ENABLED=true 才执行选股
|
||||
ALPHASIFT_ENABLED = os.environ.get("ALPHASIFT_ENABLED", "false").lower() == "true"
|
||||
|
||||
|
||||
def load_json(path):
|
||||
try: return json.loads(path.read_text(encoding="utf-8"))
|
||||
@@ -107,6 +110,9 @@ def run_one_strategy(strategy, market, max_results):
|
||||
|
||||
def run_all(strategies_str, market, max_results, dry_run=False):
|
||||
"""多策略并行 → 合并去重 → MoFin 自选池"""
|
||||
if not ALPHASIFT_ENABLED and not dry_run:
|
||||
print("AlphaSift 已禁用。设置 ALPHASIFT_ENABLED=true 或 --enable 启用。")
|
||||
return
|
||||
strategies = [s.strip() for s in strategies_str.split(",") if s.strip()]
|
||||
now = datetime.now()
|
||||
date_str = now.strftime("%Y-%m-%d")
|
||||
@@ -231,9 +237,13 @@ def main():
|
||||
p.add_argument("--market", default=DEFAULT_MARKET)
|
||||
p.add_argument("--max", type=int, default=DEFAULT_MAX)
|
||||
p.add_argument("--min-score", type=int, default=MIN_SCORE)
|
||||
p.add_argument("--enable", action="store_true", help="覆盖 ALPHASIFT_ENABLED 开关")
|
||||
p.add_argument("--dry-run", action="store_true")
|
||||
args = p.parse_args()
|
||||
MIN_SCORE = args.min_score
|
||||
if args.enable:
|
||||
global ALPHASIFT_ENABLED
|
||||
ALPHASIFT_ENABLED = True
|
||||
if args.strategy == "list": list_strategies()
|
||||
else: run_all(args.strategy, args.market, args.max, args.dry_run)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user