Skip to content

feat(trading): rebuild as autonomous trading operator - #10

Open
lyeka wants to merge 1 commit into
masterfrom
feat/autonomous-trading-operator
Open

feat(trading): rebuild as autonomous trading operator#10
lyeka wants to merge 1 commit into
masterfrom
feat/autonomous-trading-operator

Conversation

@lyeka

@lyeka lyeka commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • 拍扁交易执行:trade_plan/trade_apply 二段式合并为单个 trade_execute,删除 TTL 令牌、confirm_textrequest_confirm——自主交易操作员范式,LLM 决策后一次调用完成校验+preview+风控裁决+下单/撤单+状态回读
  • 新增 RiskGuard seam(trading/policy.py):RiskAction(ALLOW/DENY/ESCALATE) / RiskContext(operation/env/automation/intent) / RiskDecision,这期唯一实现 AllowAllGuard 恒 ALLOW,占位 + TODO,真实风控是独立后续专题
  • 确认(human-in-the-loop)与风控(risk control)解耦:交易链路彻底不依赖 request_confirm;程序化护栏是唯一安全边界
  • 富途实时行情快照工具 market_snapshotFutuAdapter.snapshot(),走 get_market_snapshot,无需 subscribe)
  • REAL 账户锁定(TRADE_LOCKED)报错改为明确指向 Futu OpenD 手工解锁——代码侧零密码,不调用 unlock_trade()
  • automation carve-out:trade_execute 对自动化任务放行(RiskContext.automation 字段已预留裁决挂钩,当前未强制)
  • 清理死代码:TradePlanStore/TradePlan 及相关 TTL/plan-id 流转逻辑
  • 文档全面同步:docs/trading.md(权威规格重写)、docs/tools.mddocs/agent-design.mddocs/automation.md.env.examplepyproject.tomlfutu extra)、GEB 分形文档(新建 trading/CLAUDE.md,更新 athenaclaw/CLAUDE.md

Test plan

  • pytest tests/unit tests/integration -q → 90 passed
  • pytest tests/bdd -v → 183 passed
  • 全仓 grep trade_plan|trade_apply|TradePlanStore|plan_store|PLAN_NOT_FOUND|PLAN_EXPIRED|PLAN_ALREADY_APPLIED|ATHENACLAW_TRADE_MODE → 0 处残留
  • 端到端冒烟(OpenD + simulate):market_snapshottrade_execute 一步下单无确认弹窗 → real 账户返回手工解锁提示

🤖 Generated with Claude Code

Merge plan/apply two-stage execution into a single trade_execute
tool — no TTL token, no confirm_text, no request_confirm in the
trading path. Confirmation (human-in-the-loop) and risk control
are distinct concerns: the trading path drops HITL entirely and
relies solely on a new RiskGuard seam (AllowAllGuard, no-op this
phase) as the programmatic safety boundary, with automation/env
context wired through for a future risk-control implementation.

Also adds a real-time Futu market_snapshot tool, and hardens the
REAL-account TRADE_LOCKED error to point at manual OpenD unlock
since the codebase intentionally carries zero trade passwords.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant