fix(screening): 最新期间无数值时不再回退到最旧期间财报 - #139
Merged
Merged
Conversation
helsome
approved these changes
Sep 21, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
核心筛选修复可以批准:statementAccounts 先用 toFiniteNumber 过滤非有限值,再由 latestAccountValue 按 newest-first 顺序取第一个有值的期间,因此不会再把数组尾部最旧期间当作“最新”;新增用例同时钉住 ROE=12 与 high-roe 不应误产出候选。Issue #136 的 /claim 与 Closes #136 范围一致,当前 head 的 Focused tests / Typecheck / Secret scan / advisory full suite 也均为 success。
当前暂不合并:PR 相对最新 main 有实际冲突,且 experiment-service.ts 的 runtimeUnusable: false 已经在 main,已经不是本 PR 的必要增量。请 rebase/解决冲突,让该冗余 hunk 消失,只保留 screening 策略与测试;更新后的 head 跑 screening focused tests + typecheck/basic CI 即可,无需额外桌面 E2E 或截图。
财务指标按最新期间优先(values[0])读取,但当该期间没有可用数值时, latestAccountValue 会回退到数组最后一个元素,也就是最旧期间, 把多年前的 ROE / 毛利率当作"最新"参与 high-roe、quality-growth 评选。 现在改为取最新一个真正有数值的期间(find 第一个有效 value),既保留 "最新已披露数值"的语义,也绝不会跳到最旧期间。extractFinancialMetrics 的 ROE / 毛利率 / 净利率与依赖它们的策略同时修正。 新增回归测试:最新期间只有 yoy、无数值时,ROE 取次新期间 12 而不是 最旧期间 30;修复前该测试失败。revenueGrowth 的 yoy 计算路径不变。
wxrbyte
force-pushed
the
codex/fix-latest-account-value
branch
from
September 22, 2026 02:07
95ce975 to
692ec07
Compare
helsome
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与修复
财报账户期间数组为最新在前(values[0] = 最新期间)。原
latestAccountValue在最新期间没有可用数值时,回退到values[values.length - 1],也就是最旧期间,把多年前的 ROE / 毛利率当作"最新"参与 high-roe、quality-growth 等策略的阈值判断与评分。现在改为取最新一个真正有数值的期间:
保留"最新已披露数值"的语义,同时保证绝不跳到最旧期间。各期间数值齐全时结果与之前一致。
Closes #136
范围仅 financial statement 账户取值路径(ROE / GrossMgn / NetProfitMargin 及其下游策略),不改动 revenueGrowth 的 yoy 计算、其他报表逻辑与 UI。
可复现测试报告
Windows 11 / Bun 1.4.2 (744846f84),基于 main ff3ed3d,分支
codex/fix-latest-account-value(4271188)。bun test packages/shared/src/screening/strategies.test.ts:新增回归测试(ROE values = [{Q1 2027 无数值, yoy: '20'}, {Q4 2026: 12}, {Q3 2026: 30}])修复前 25 pass / 1 fail(Expected 12 / Received 30);修复后 26 pass / 0 fail。bun test packages/shared/src/screening:40 pass / 0 fail。bun test packages/shared --isolate:993 pass / 3 fail;3 项(ResearchService ×2、langfuse ×1)已在干净 main(ff3ed3d)上复现为 17 pass / 3 fail,属基线失败,与本改动无关。bun run typecheck:core/uiExited with code 0;shared/i18n/electron 报 main 现有src/evaluation/experiment-service.ts(534,7) TS2741(main 同样复现,PR fix(eval): separate live execution validity from quality and propagat… #122 已包含补全),本 PR 不涉及该文件。git diff --check:通过。新增用例同时断言 high-roe 在 ROE=12% 时不产生候选,避免仅修数值而不修下游行为。未运行桌面端 E2E 与全仓
bun test。UI 变化
无可见 UI 变化:仅修正后台财报指标取值,候选列表的渲染与样式未改。
2026-09-20 类型检查修复复验
补齐 experiment-service.ts 配置应用失败返回值的 runtimeUnusable: false。此时尚未启动运行任务,因此不应标记运行时不可用。该主分支遗漏也是旧版 CI 的 TS2741 根因。本 PR 增加此最小修复以解除检查阻塞(与在审 #122 对此字段的修正一致,无需引入其余改动)。无可见 UI 变化。
环境:Windows / Bun 1.4.2。实际执行:
996 pass
0 fail
3940 expect() calls
Ran 996 tests across 91 files. [24.57s]
上述结果替代此前测试报告中类型检查失败的状态;远端检查以本次提交的 CI 为准。未额外运行桌面 E2E。