Skip to content

fix(paper): 修复A股下单取价与人民币计价 - #155

Merged
mirror29 merged 12 commits into
mainfrom
fix/a-share-order-pricing
Aug 14, 2026
Merged

fix(paper): 修复A股下单取价与人民币计价#155
mirror29 merged 12 commits into
mainfrom
fix/a-share-order-pricing

Conversation

@mirror29

Copy link
Copy Markdown
Owner

Summary

  • 修复 paper 交易执行遗漏 fresh=true 的跨服务契约,避免 A 股 K 线可用但下单因 DB-only ticker 返回 NO_PRICE_AVAILABLE
  • 直接订单与 trade plan 都改为从 data-service 的实时 ticker capability 获取参考价;报价失败仍保留审批 token,可恢复后重试。
  • 兼容 sh.600519 / 600519.SH 与 legacy akshare A 股身份,避免 data 按人民币行情取价而 paper 回退为 USD 记账。
  • 更新 data OpenAPI 与 orchestrator 市场能力说明。

Test Coverage

  • 新增 fresh 参数序列化、直接下单取价、A 股 plan 报价失败重试回归。
  • 补充 A 股前缀/后缀 symbol 的币种和交易日历解析用例。

Verification

  • services/paper: 937 tests passed
  • 聚焦回归:57 tests passed
  • packages/orchestration: typecheck passed
  • packages/orchestration: 478 tests passed
  • Ruff passed
  • scripts/check-consistency.sh: 10 passed, 0 failed
  • git diff --check: passed

Scope

  • 仅包含两个 A 股修复提交;未包含工作树中的 evolution/dashboard 等 WIP。
  • 未修改 VERSION 或 CHANGELOG。

🤖 Generated with Claude Code

mirror29 and others added 2 commits August 13, 2026 16:35
显式请求 data-service fresh ticker,保留报价失败后的审批 token 重试语义,并补齐跨服务回归测试与能力说明。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
让 paper 的交易日历与币种解析同时识别 sh.600519 和 600519.SH,避免 data 按A股取价而 paper 回退到美元记账。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review base: bba4128

🤖 DeepSeek V4 Pro PR Review

[medium] services/data/src/inalpha_data/connectors/baostock.py:70-138 — _throttled_to_thread 超时后由后台 task 持锁直到 asyncio.to_thread worker 退出;若 _fetch_sync / _fetch_tencent_ticker_sync 内部 HTTP 请求没有自己的超时,线程可能永久挂起,_FETCH_LOCK 永不释放,后续所有 A 股 K 线 / ticker 请求都会在等锁 30s 后超时,导致 data-service 的 baostock 通道整体不可用 — 依据:通用原则:资源/性能 + 错误处理。需确认两个同步源站函数具备明确的底层超时,否则这是比“短暂取价失败”更严重的可用性故障。

[medium] services/data/src/inalpha_data/schemas.py:90 — data-service /tickerbaostockfresh=True 支持只在 query schema 描述里声明为支持,但本 PR diff 中未看到路由层实际调用 baostock fetch_ticker 的实现变更;若路由仍按旧白名单返回 422 FRESH_NOT_SUPPORTED_FOR_VENUE,paper 侧 get_execution_ticker 会失败,A 股下单自动取价仍不可用 — 依据:CLAUDE.md §4(实现文件未同步 add / 改描述不改行为)+ 通用原则:正确性。本 PR 主要目标是修复 A 股下单取价,若不确认这一跨服务契约,存在主要功能未真正落地的风险。

交易执行统一请求 fresh ticker,并对 is_stale=true 或缺少 freshness 标记 fail-closed;报价恢复前不消费 plan approval token。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying inalpha-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: a25ed4a
Status: ✅  Deploy successful!
Preview URL: https://e27a1c62.inalpha-web.pages.dev
Branch Preview URL: https://fix-a-share-order-pricing.inalpha-web.pages.dev

View logs

mirror29 and others added 9 commits August 14, 2026 10:22
订单与 plan 入站统一把后缀代码和 legacy akshare 规范为 baostock/sh|sz 前缀,避免同一证券形成重复仓位或无法跨格式平仓。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
让腾讯 ticker 与 K 线共用进程锁和最小请求间隔,避免并发下单突发触发公开源站限流或封禁。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
只向 agent 声明已贯通 fresh ticker 的 spot 计划市场,明确排除 FRED,并禁止尚未持久化 tradingMode/leverage 的 perp plan。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
交易事务首次访问单个 legacy A 股仓位时原子迁到 canonical key;重复 active identity fail-closed。旧 plan 执行前同样规范化,确保升级后仍可平仓。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
shield 无法终止的 to_thread,并在 caller 取消后等待后台线程退出再释放锁,防止慢请求与下一次 ticker 并发。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mirror29
mirror29 merged commit 5188658 into main Aug 14, 2026
12 checks passed
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