Skip to content

fix: always run short horizon only (medium is redundant)#136

Open
yunchat wants to merge 1 commit into
KylinMountain:mainfrom
yunchat:fix/force-short-horizon-with-chunk-logging
Open

fix: always run short horizon only (medium is redundant)#136
yunchat wants to merge 1 commit into
KylinMountain:mainfrom
yunchat:fix/force-short-horizon-with-chunk-logging

Conversation

@yunchat

@yunchat yunchat commented Apr 8, 2026

Copy link
Copy Markdown

medium 和 short 的区别只是 prompt 里的"视角描述",流程完全一样

每个 analyst 都硬编码了自己的 horizon,不受传入的 state["horizon"] 影响:

  • market/social/news/volume_price → 永远用 "short" 视角
  • fundamentals/macro → 永远用 "medium" 视角
  • bull/bear researcher → 读 state.get("horizon", "medium")

所以不管你传 horizons=["short"] 还是 ["short","medium"],每个 analyst 的行为完全一样。

跑2次的原因:

horizons=["short","medium"] 时,代码在 asyncio.gather 里并行跑两个完整的 graph:

results = await asyncio.gather(
*[_process_horizon(h) for h in request.horizons], # 跑2遍
)

每遍都是完整的 6个analysts + bull/bear + trader + 风控,两遍产出的内容几乎一模一样,最后只取 short 的结果,medium
的只保留 traces。

结论:

  • medium 不是"不同模型",也不是"不同流程"
  • 就是多跑一遍一样的东西,纯粹浪费时间
  • 用户说"中线"触发 dual_horizon,执行时间直接翻倍

如果你想真正支持中线分析,需要让 fundamentals/macro analyst 根据传入的 horizon 动态调整数据窗口和
prompt,而不是硬编码。目前的实现 dual_horizon 没有实际意义。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the mountaintop's projects Team on Vercel.

A member of the Team first needs to authorize it.

@KylinMountain

Copy link
Copy Markdown
Owner

@yunchat 每个analyst之所以使用固定视角,是因为他们其实只适用短线分析。

比如这些market/social/news,长线不需要看主力,不需要看当前新闻,只看基本面等信息就差不多了了。量价分析可能要考虑一下允许中长期视角。

@KylinMountain

Copy link
Copy Markdown
Owner

我同意dual horizon没有意义

@KylinMountain

Copy link
Copy Markdown
Owner

Code review

Found 2 issues:

  1. Unconditional override silently discards user-provided horizons -- The PR replaces a conditional default (if not request.horizons) with an unconditional request.horizons = ["short"]. Any caller explicitly passing horizons=["medium"] will have their input silently overridden with no error or warning, breaking the API contract documented in the AnalyzeRequest field description ("分析周期列表,如 ['short'] 或 ['short','medium']").

config=config,
)
final_state: Optional[Dict[str, Any]] = None

  1. Stale base branch -- change regresses an existing fix -- The current main branch already has a more nuanced guard at lines 1899-1903 that solves the same dual-horizon performance problem while preserving the user's first choice:
if not request.horizons:
    request.horizons = ["short"]
elif len(request.horizons) > 1:
    request.horizons = [request.horizons[0]]

The PR's unconditional assignment would regress this by hardcoding ["short"] regardless of user intent. The PR should be rebased onto current main, or closed in favor of the existing fix.

config=config,
)
final_state: Optional[Dict[str, Any]] = None

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

hezhongtang added a commit to hezhongtang/TradingAgents-AShare that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants