Commit Graph
223 Commits
Author SHA1 Message Date
wshy 89bb60bdaf Merge pull request #133 from dunmin1980-ux/cursor/tickflow-pro-rate-limit-p0
TickFlow Pro: process-local 80% RPM safety + Phase 1 probe scaffold
2026-07-31 19:08:11 +08:00
wshy ceb53735b5 Merge pull request #134 from CJ0Hn/fix/numba-parallel-serialize
fix: 串行化 Numba parallel 内核,避免策略页并发崩溃
2026-07-31 19:08:07 +08:00
wshy 16077bb13e Merge pull request #148 from im47cn/fix/test-time-bomb-live-enriched
fix(test): 修复 test_live_enriched_metadata 硬编码日期导致的 time-bomb 失败
2026-07-31 19:04:57 +08:00
shy3130 f8fca96f42 修复停复牌股票实时涨跌停漏算 2026-07-30 13:09:07 +08:00
im47cn 5f1c1cf0bb fix(test): replace hardcoded dates with cn_today() in test_live_enriched_metadata
test_history_strategy_monitor_keeps_live_row_with_exclude_st_enabled used
date(2026,7,20) as the "today" value, but MonitorRuleEngine.evaluate()
calls cn_today() internally. The date mismatch caused the basic_filter
+ history filter to produce 0 rows, making the test fail 8 days after
it was written.

Also fixes test_live_enriched_cache_keeps_instrument_metadata_without_persisting_it
which used the same hardcoded date — would break on any future run.

Replace all hardcoded dates with cn_today() / cn_today()-timedelta(days=3)
so the tests are timeless.
2026-07-28 09:46:51 +08:00
shy3130 b43b177899 feat(monitor): add strategy signal event controls 2026-07-26 16:08:42 +08:00
CJohn 33921fcc51 fix: 串行化 Numba parallel 内核,避免策略页并发崩溃
并发 run_all 会触发 workqueue Concurrent access,导致后端进程中断。
为 matrix parallel 内核加进程锁,前端对 run_all 做 pending 去重。
2026-07-26 11:56:10 +08:00
shy3130 6d7092089c fix(data-source): harden custom source testing 2026-07-25 22:51:27 +08:00
shy3130 96fcbe4fff fix(data-source): validate custom request settings 2026-07-25 22:13:38 +08:00
wshy fffd89fce0 Merge pull request #138 from intfoo/feat/custom-source-timeout-param-ui
自定义数据源超时与请求参数名支持前端配置
2026-07-25 22:01:11 +08:00
intfoo 99b0c6cb35 fix(index-quotes): compute change_pct for custom data source
Custom data source realtime quotes were missing change_pct because _build_index_quotes only kept pre-existing columns. TickFlow path computes it in _fetch_full_market_quotes, but custom source path bypasses that computation.

- _build_index_quotes computes change_pct/change_amount from last_price/prev_close when not provided by the source
- guards prev_close=0 (Polars produces inf, invalid JSON)
- aligns with TickFlow path and _fallback_index_quotes_from_daily
2026-07-24 11:35:19 +08:00
intfoo a15d0468cc feat(data-source): expose custom source timeout & request param names in UI
- backend: pass timeout through DatasetConfigIn / _config_to_dict / _sanitize_dataset
  (previously a hand-set YAML timeout was silently wiped on UI save, resetting to 30s)
- frontend: add per-dataset timeout input; collapsible 请求参数字段映射 with
  symbols/start/end_param (non-realtime) + asset_type/freq_param (minute);
  rename 字段映射 -> 响应参数字段映射; chevron at title end; realtime empty-state hint
- test: timeout config round-trip (custom value persists, default 30 not emitted)
- docs: document timeout in custom-data-source.md
2026-07-23 16:22:18 +08:00
shy3130 60fe9e6fa6 修复回测指标数据缺失提示问题 2026-07-22 13:30:02 +08:00
shy3130 2d9fe4a4af 修复策略文件无法删除问题 2026-07-22 11:21:13 +08:00
shy3130 2c14fde788 完善个股点位提醒并发布0.1.87 2026-07-21 22:14:07 +08:00
shy3130 72918fe602 优化策略卡片结果加载性能 2026-07-20 13:01:03 +08:00
shy3130 0635698a08 修复策略监控开启后结果归零 2026-07-20 11:12:19 +08:00
shy3130 e1dbd1cafb 修复监控中心涨跌停信号误报 2026-07-20 10:33:06 +08:00
shy3130 4df3062002 fix: 完善自定义分钟数据源配置与异常处理
- 补齐资产类型和周期参数在 API、YAML 与前端编辑器中的保存回读

- 权限判断和分时监控统一复用安全的数据源解析边界

- 增加配置往返及解析异常回归测试
2026-07-19 17:01:33 +08:00
shy3130 b1b2494db9 merge: 合并 PR #128 自定义分钟数据源支持 2026-07-19 16:52:52 +08:00
shy3130 b17c882e27 feat: 完善历史换手率重算入口
- 财务数据统计纳入历史股本,并在数据页提供分批重算入口

- 缺少股本历史时阻止重算,并接入现有任务进度

- 财务分析卡片使用更新图标,明确数据拉取语义
2026-07-19 16:42:03 +08:00
intfoo d9a77a534a fix(minute): 承接 #122 review 三处阻断问题整改 + resolver 异常边界加固 2026-07-19 16:00:22 +08:00
intfoo 4c85f99633 fix(minute): 自定义分钟数据源用户单股补拉/监控页整改 (承接 #121 review) 2026-07-19 13:35:35 +08:00
intfooandshy3130 e2ffde99d5 fix(minute,monitoring): 自定义数据源用户单股补拉/监控页打通 (#121)
承接 #126: 能力探测已补 KLINE_MINUTE_BATCH, 但两处取数/UI 仍按 TickFlow
档位拦截, 配了自定义分钟/实时源的 None 档用户依旧被挡。

- kline_sync.fetch_minute_single: 与 sync_minute_batch 一致, 先查
  preferences.get_minute_data_provider(), 非 tickflow 且自定义源有
  minute dataset 时走 custom provider, 避免分时图首次打开(本地无数据)
  补拉返回空。
- Monitoring.tsx: None 档但配了自定义实时源时, 后端
  is_realtime_allowed(realtime_mode=full_market) 仍返回 True。
  以 quoteStatus.realtime_allowed 作为最终判据, 不再用 isNoneTier
  一刀切拦截实时监控页。

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-19 13:26:52 +08:00
dunmin1980andCursor 431550859f fix: align Phase 1 probe with TickFlow SDK namespaces
Use klines.batch/quotes.get, rename dry-run status to DRY_RUN_OK, document
first-batch burst limits, and cover run_live with a fake client.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-19 10:06:26 +08:00
dunmin1980andCursor 6cb7f9f50c chore: drop probe debug instrumentation and ignore probe artifacts
Keep the Phase 1 CLI production-clean; local probe reports and debug NDJSON stay out of git.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-19 09:36:55 +08:00
dunmin1980andCursor cafa03fb52 feat: add TickFlow Pro Phase 1 probe scaffold with off-peak gate
Dry-run by default; live calls require a key and wait until 16:00 Asia/Shanghai unless --force, so Stage A off-peak probing stays intentional.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-19 09:36:55 +08:00
dunmin1980andCursor 0745fdbb7d fix: apply process-local 80% TickFlow rpm safety budget
Scale resolve_limit rpm by SAFETY_RPM_FACTOR and document that the
in-process slot limiter is not a cross-container account budget.
Keep Stage A isolation via off-peak A-share usage guidance.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-19 09:36:55 +08:00
shy3130 8e4258cf20 feat: support historical price limits and share capital 2026-07-18 23:37:54 +08:00
shy3130 e462c63b45 fix: align AI strategy prompt constraints 2026-07-18 18:31:02 +08:00
shy3130 44ab51e65d feat: improve strategy scoring and backtest execution 2026-07-18 16:59:53 +08:00
shy3130 a1e8be58db feat: release v0.1.86 2026-07-18 00:49:28 +08:00
shy3130 34eaba3010 fix: handle uncovered walk-forward folds 2026-07-17 14:00:16 +08:00
shy3130 c763a6970f fix: restore strategy and data compatibility 2026-07-16 14:34:07 +08:00
lytem28 b6cf0495e1 feat: complete matrix-native backtest engine
Unify strategy execution across backtest, screener, and monitoring; isolate backtest workloads in spawn workers; and add shared matrix caching plus valid-bar indicator acceleration.
2026-07-16 12:17:27 +08:00
ChenJunheng 0d6b341945 fix(watchlist): 采纳 #94 审查 — 防大图 OOM、OCR 不阻塞事件循环、收紧图片类型
为截图预处理增加像素上限与长边降采样;import-image 将 OCR 放入线程池;
去掉任意 image/* 放行,仅允许白名单 MIME/扩展名。
2026-07-15 23:28:30 +08:00
ChenJunheng 6f084e1b29 feat(watchlist): 支持从券商自选截图批量导入
基于 Tesseract OCR 识别六位代码并校验证券主数据,前端提供导入确认弹窗;
修复批量添加后 enriched 缓存未刷新导致需手动刷新页面的问题。
2026-07-15 23:25:46 +08:00
shy3130 77876c7ee4 fix(data): avoid destructive enriched rebuild cleanup 2026-07-15 21:34:44 +08:00
shy3130 f317377bef fix(strategy): apply saved params to builtin screeners 2026-07-15 20:06:11 +08:00
shy3130 89115e6f73 fix(strategy): apply saved parameters during execution 2026-07-15 19:03:48 +08:00
wshyandshy3130 963092384f fix(capabilities): 自定义分钟数据源补 KLINE_MINUTE_BATCH 能力 (#126)
issue #121: 用户配了自定义分钟数据源, 但分时图/自动同步/回测等功能
仍提示"需 Pro+"。根因: 能力探测(detect_capabilities)只探测 TickFlow
API Key 档位, 不感知用户本地配的自定义数据源。

修复:
- capabilities.py: CapabilitySet 加 grant() 方法 (不覆盖已有能力)
- policy.py: detect_capabilities 拆成 _detect_tickflow_caps (原逻辑不动)
  + _augment_custom_sources (探测完检查自定义分钟源, 有的话补能力)

补能力后所有 capset.has(KLINE_MINUTE_BATCH) 检查自动通过; 取数函数
内部仍按 preferences.get_minute_data_provider() 分流到自定义源,
不会错误调用 TickFlow。前端读后端返回的 capabilities, 无需改动。

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 22:27:03 +08:00
wshyandshy3130 2f762b3bcc fix(strategy): import 白名单加 datetime + date 参数处理补进文档 (#123)
问题: ai_single_yang_unbroken 策略用 from datetime import date 做
date 类型参数转换, 被安全修复的 import 白名单(只允许 polars)拦截,
策略加载失败消失。同时 date 列(Polars Date)与字符串参数直接比较
报 InvalidOperationError 导致 500。

修复:
- ai_generator.py: import 白名单加入 datetime (纯日期运算, 无文件/
  网络/进程能力, 安全)。验证 os/sys/subprocess 仍被拦。
- strategy-guide.md: params type 补全(float/int/bool/select/date);
  filter_history 要点新增 date 参数必须 fromisoformat 转换的代码示例
- strategy-guide-compact.md: 同步补充 (AI 运行时实际用的文档)

从源头避免 AI 生成的 date 类型参数策略再犯字符串 vs Date 列比较错误。

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 21:47:26 +08:00
wshyandshy3130 f470e46f2b fix(security): 策略代码 RCE 漏洞三层修复 (#122)
漏洞链 (安全研究员 Aeon 报告):
1. StrategyCodeSaveRequest.strict 由客户端控制, 传 false 完全跳过安全校验
2. AST 名单只拦 ast.Name 直接调用, dunder 遍历可绕过
   ((lambda:0).__globals__["__builtins__"]["__import__"]("os"))
3. _load_file 用 exec_module 执行策略文件, 执行侧零校验
   => 未认证局域网用户可写入任意代码并立即执行 (RCE)

修复:
- strategy.py: 移除 strict 字段, 安全校验无条件执行 (第1层)
- ai_generator.py: _validate_safety 加固, 拦截 dunder 属性访问
  (__globals__/__builtins__/__class__/__subclasses__ 等) 和字符串下标
  访问 (第2层)
- engine.py: _load_file 在 exec_module 前读文件内容跑一次 _validate_safety,
  防止策略文件被直接篡改绕过 API 校验 (第3层 纵深防御)

前端: api.ts 移除 strict 参数, StrategyBuilderDialog/StrategyPoolDialog
移除 strict:true 传参 (前端本就全部传 true, 行为不变)

验证: PoC 三种攻击 payload 全部拦截, 正常策略(只import polars)无误杀

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 21:32:39 +08:00
wshyandshy3130 0fba9eb57b chore: 版本号升至 0.1.85 (#119)
Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 18:54:17 +08:00
wshyandshy3130 70a4aad010 feat(monitor): 个股通知带行业/概念 ext 标签 + 全局配置 (#118)
监控中心顶部加全局配置(齿轮), 选择要在个股通知里展示的 ext 字段
(默认概念 ext_gn_ths + 行业 ext_hy_ths)。开启后触发记录卡片和推送
toast 统一显示行业(蓝)/概念(橙)标签。

架构: 源头富化 — 后端 SSE 推送前 (_enrich_alerts_ext) 用
_load_ext_value_maps (带 mtime 缓存) 按 symbol 富化; GET /api/alerts
读取时同样富化。前端零额外请求。

配置支持细粒度裁剪:
- 字段下拉按扩展表分组 (optgroup)
- 显示前N个 (maxTags), 留空=全部
- 隐藏指定位置 (hiddenIndices), 点数字划掉

数据结构 {field, maxTags, hiddenIndices} 向后兼容旧字符串格式。

后端:
- preferences.py: get_monitor_ext_fields + _normalize_ext_field
- settings.py: RealtimeMonitorConfigIn + get_preferences 加字段
- quote_service.py: _enrich_alerts_ext SSE 推送前富化
- alerts.py: list_alerts 加 ext_columns 参数

前端:
- api.ts: MonitorExtFieldItem 类型 + alertsList extColumns 参数
- Monitor.tsx: 齿轮入口 + 配置弹窗 + 卡片标签行
- AlertToast.tsx: toast 底行加标签

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 18:49:23 +08:00
wshy 644cf8648d Docker 环境支持 Codex CLI (#116)
解决 Docker 容器内无法读取 codex 命令的问题:多阶段构建提取原生二进制 + 只读挂载主机登录态 + 适配 loopback local-access provider。
2026-07-14 18:07:38 +08:00
wshyandshy3130 d8c2081679 fix(quote): 最后获取时间持久化, 关闭开关/重启后仍显示 (#115)
_fetched_at 原为纯内存变量 (init 0.0), 进程重启即归零 → last_fetch_ms
变 null → 数据页"最后获取"显示"—"。用户关闭实时开关若伴随重启
(开发热重载/部署), 就看不到上次拉取时刻。

改为持久化到 preferences.json:
- __init__ 启动时读回 last_fetch_ms 作为 _fetched_at 初始值
- _fetch_quotes 成功后 (全市场 + 自选股两处) 写入 preferences
- 放锁外调用, 失败不影响主流程 (内存值已更新)

前端 QuoteConfigCard 本就无条件渲染该行, 无需改动。

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 16:46:23 +08:00
wshyandshy3130 d99112c160 分时图实时刷新: 日期修复 + 间隔可配 + 对话框实时 + 自选刷新图标 (#114)
* fix(kline): 分时图盘中显示昨天而非今天

get_minute_batch 的日期选择存在死循环: trade_date=date.today() 后立即
if trade_date==date.today() (恒真), 无条件用 latest_minute_date_global()
覆盖今天; 但批量实时补拉不落库, 该值盘中恒返回昨天 -> 永远回退到昨天 ->
expected=240 判定昨日完整 -> 不触发今天补拉。

改为仅在真正非交易日回退 (周末 + 收盘后无今日日K 的节假日), 盘中保持
今天让 completeness 检查触发实时补拉。同时全量 date.today()/datetime.now()
改用北京时间 cn_today()/cn_now(), 与 quote_service/monitor 等一致。

影响: 自选列表分时列 + 单股详情分时图。

* feat(settings): 分时图刷新间隔可配置 (默认6s, 范围3-60s)

原写死 15s 轮询, 现可在 实时监控设置 -> 分时图刷新 卡片用滑块调节。
复用 minute_intraday_refresh 偏好链路, 新增 minute_intraday_refresh_interval
字段 (preferences + settings API + 前端 Preferences 接口)。

- preferences.py: getter 默认6s clamp[3,60] + set/get config 接入
- settings.py: RealtimeMonitorConfigIn 字段 + get_preferences 返回
- Monitoring.tsx: 滑块控件 (参考行情轮询滑块, 2s 防抖保存)
- Watchlist/Screener: 15_000 -> interval*1000, fallback ?? 6

* feat(dialog): 个股对话框日K/分时实时刷新

日K走 SSE 精准刷新: 对话框打开时注册焦点股票, quotes_updated 推送时
invalidate ['kline', symbol], 后端 _maybe_inject_live_candle 只读内存
不调 TickFlow, 秒级零成本。关闭/切股自动注销焦点。

分时走轮询: 复用分时刷新开关 + 间隔偏好, 经 StockPanel.refetchIntervalMs
透传到 StockIntradayChart。分时端点数据不完整会调 TickFlow, 不接 SSE
避免打爆限流。

不影响回测弹窗 (不注册焦点、不传间隔)。

* feat(watchlist): 分时列表头加刷新图标 (与策略列表一致)

分时列可见 + 未自动刷新时显示手动刷新按钮 (点击 refetch, 加载旋转);
自动刷新中显示持续旋转小图标提示。逻辑/样式对齐 ScreenerTable。

* fix(badge): 真假涨停修正弹层被父级裁剪遮挡

弹出层原用 absolute 定位, 被看板卡片父级的 overflow-hidden +
backdrop-blur containing block 裁剪/遮挡。改用 createPortal 渲染到 body,
基于徽章 getBoundingClientRect 计算弹层坐标, 脱离父级裁剪。

---------

Co-authored-by: shy3130 <shy3130@users.noreply.github.com>
2026-07-14 15:46:18 +08:00
zhang,zhao 46338f4435 修复:适配 Docker Codex 本地访问服务 2026-07-14 11:51:35 +08:00
shy3130 590de5d694 fix(monitor): 分时图刷新开关不生效 + Pro+ 默认开启 + 刷新条件统一
三处问题:

1. 后端 API 漏接线 (settings.py):
   - 入参模型 RealtimeMonitorConfigIn 缺 minute_intraday_refresh →
     PUT 时 Pydantic 静默丢弃, 开关拨了也不存
   - GET /preferences 响应没返回该字段 → 前端永远读 undefined→false,
     开关拨完弹回 OFF
   服务层 (preferences.py) 本就有 get/set, 纯 API 层漏接。

2. 默认值 (preferences.py):
   get_minute_intraday_refresh 原默认 False。改为三态: 未设置过的
   key 按 Pro+ 权限定默认 (有权限=开, 无=关); 用户主动设置过的
   (含 False) 以用户选择为准。用 'in data' 区分 未设置 vs 设为 False。

3. 刷新条件不一致 (Watchlist.tsx):
   Watchlist 用 || (开关或实时行情任一即刷新), Screener 用 && (两者都要)。
   与设置卡片描述「需 Pro+ 权限 + 实时行情运行」对齐, 统一成 &&。

后端 216 测试通过; 前端 tsc 通过。
2026-07-13 22:28:04 +08:00