mirror of
https://github.com/simonlin1212/TradingAgents-astock.git
synced 2026-08-31 01:23:38 +00:00
🔴 裸跑 tradingagents 被 v0.5.2 打断(升级即破坏)
Typer 只有一个命令时是"单命令模式",加了 performance 子命令后切换成命令组
模式,裸跑直接报 Missing command 退出——而 README 和所有文档写的都是裸跑,
每个现有用户升级后第一条命令就失败。加 invoke_without_command callback 保住
默认路径,--checkpoint 等原参数照常可用。
时区误判
_is_historical 用主机本地日期。主机在 UTC+9 以东(如新西兰)时当地已过零点
而上海还在前一天,当天分析被判成"复盘历史":实时资金流被略去、快照工具打出
莫须有的未来函数警告。改为固定按 Asia/Shanghai 市场时区计算。
README 口径与实际输出不符
v0.5.6 已把指标改名为 direction_accuracy / up_rate / outperform_rate,README
仍写"胜率 / alpha 胜率"——而这恰恰是 v0.5.6 要纠正的误导。中英文已同步。
测试:新增 5 例(含一例断言 callback 注释写明了后果,防止重构时被误删),
334 passed / 13 skipped / 0 failed。版本 → v0.5.9
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""裸跑 `tradingagents` 必须仍然直接开始分析(codex 第四轮)。
|
|
|
|
Typer 在只注册一个命令时用"单命令模式",裸跑就等于跑那个命令;一旦注册第二个
|
|
子命令(v0.5.2 加的 `performance`),它切换成"命令组模式",裸跑直接报
|
|
`Missing command` 退出——而 README 和所有文档写的都是裸跑。这是升级即破坏。
|
|
"""
|
|
import inspect
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.main import app
|
|
|
|
|
|
def test_bare_invocation_does_not_error_with_missing_command(monkeypatch):
|
|
called = {}
|
|
|
|
import cli.main as m
|
|
monkeypatch.setattr(m, "run_analysis", lambda **kw: called.update(kw))
|
|
|
|
result = CliRunner().invoke(app, [])
|
|
|
|
assert "Missing command" not in (result.output or "")
|
|
assert result.exit_code == 0
|
|
assert called == {"checkpoint": False}, "裸跑应当直接进入分析流程"
|
|
|
|
|
|
def test_bare_invocation_still_accepts_original_flags(monkeypatch):
|
|
called = {}
|
|
|
|
import cli.main as m
|
|
monkeypatch.setattr(m, "run_analysis", lambda **kw: called.update(kw))
|
|
|
|
result = CliRunner().invoke(app, ["--checkpoint"])
|
|
|
|
assert result.exit_code == 0
|
|
assert called == {"checkpoint": True}
|
|
|
|
|
|
def test_subcommands_are_still_registered():
|
|
names = {c.name or c.callback.__name__ for c in app.registered_commands}
|
|
assert "analyze" in names
|
|
assert "performance" in names
|
|
|
|
|
|
def test_callback_explains_why_it_exists():
|
|
"""这个 callback 很容易在重构时被当成多余删掉——注释必须说清后果。"""
|
|
src = inspect.getsource(app.registered_callback.callback)
|
|
assert "Missing command" in src
|