Skip to content

fix: WebSocket推送管理页面核心功能修复#9

Merged
henrylin99 merged 2 commits into
masterfrom
fix/websocket-management-page
Jun 6, 2026
Merged

fix: WebSocket推送管理页面核心功能修复#9
henrylin99 merged 2 commits into
masterfrom
fix/websocket-management-page

Conversation

@henrylin99

Copy link
Copy Markdown
Owner

问题

/realtime-analysis/websocket 页面存在多个阻断性问题,导致核心功能完全不可用:

  1. 前端连接地址硬编码 127.0.0.1:5001,服务器运行在 5000,"连接"按钮永远无法成功
  2. 推送服务调用 4 个不存在的方法,推送循环空转无实际数据
  3. 推送线程使用 threading.Thread 在 eventlet 模式下无法 emit 到客户端

修复内容

P0 — 阻断性修复

文件 修复
websocket_management.html Socket.IO 连接地址改为 window.location.origin
websocket_push_service.py get_active_stocks()get_available_minute_stocks()
websocket_push_service.py get_latest_data()get_minute_latest_data() + DataFrame 访问方式
websocket_push_service.py get_top_movers() 删除,用 detect_anomalies() 替代
websocket_push_service.py calculate_market_sentiment()get_market_sentiment()
websocket_push_service.py get_market_overview() 从 monitor_service 改到 data_manager
websocket_push_service.py threading.Threadsocketio.start_background_task + socketio.sleep

P1 — 功能改进

文件 修复
websocket_push_service.py 添加周期 fallback (1min→5min→15min→30min→60min) 应对数据缺失
websocket_api.py test-connection 返回 ISO 时间戳而非 connection_stats 字典

P2 — 小修复

文件 修复
websocket_push_service.py 涨跌幅计算取 2 条记录,用前一条 close 作为 prev_close
websocket_management.html 实时数据展示条件显示省略号后缀

验证

  • ✅ 332 tests passed, 0 regressions
  • ✅ REST API: 全部 7 个端点返回 200 + success: true
  • ✅ Socket.IO: connect/ping/subscribe/unsubscribe/get_status 全部正常
  • ✅ 推送数据: 启动推送后客户端成功收到 market_data (8条) 和 monitor (1条)

🤖 Generated with Claude Code

henrylin99 and others added 2 commits June 6, 2026 23:13
- 前端Socket.IO连接地址从硬编码127.0.0.1:5001改为window.location.origin
- 修复推送服务调用4个不存在的方法:
  - get_active_stocks() → get_available_minute_stocks()
  - get_latest_data() → get_minute_latest_data() + DataFrame访问
  - get_top_movers() → 用detect_anomalies()替代
  - calculate_market_sentiment() → get_market_sentiment()
- 修复get_market_overview()在错误的service上调用(monitor→data_manager)
- 推送线程从threading.Thread改为socketio.start_background_task,
  解决eventlet模式下无法emit到客户端的问题
- 添加周期fallback(1min→5min→15min→30min→60min)应对数据缺失
- test-connection API返回正确的ISO时间戳而非connection_stats字典
- 涨跌幅计算取2条记录用前一条close作为prev_close
- 实时数据展示条件显示省略号后缀

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- 移除废弃的 self.push_thread 和 stop_push_service 中的 join 调用
- 移除重复的 log line
- detect_anomalies 返回值解包为 anomalies 列表,不再传包装 dict
- detect_anomalies 失败时降级为空列表
- 新增 9 个生命周期与合约测试

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@henrylin99 henrylin99 merged commit 34b1c35 into master Jun 6, 2026
0 of 16 checks passed
@henrylin99 henrylin99 deleted the fix/websocket-management-page branch June 6, 2026 15:29
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