feat: 事件影响力分析——快讯内容深度获取 + LLM 影响推断 + 个股推荐卡(购入区间/预计收益/推荐指数)+ WS 推送

This commit is contained in:
lookt
2026-09-15 20:42:08 +08:00
parent 3fafd08545
commit ea5577fa6f
5 changed files with 399 additions and 3 deletions
+8
View File
@@ -16,6 +16,7 @@ import sys
sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent))
from src.realtime.collector import TimelineCollector # noqa: E402
from src.analysis.event_impact import EventImpactService # noqa: E402
PORT = int(os.environ.get('PORT', '8100'))
ROOT = Path(__file__).resolve().parent.parent.parent
@@ -57,6 +58,7 @@ async def collector_task(_app):
await asyncio.sleep(60)
task = asyncio.create_task(poll())
_app['impact'] = collector.impact
# 启动即推最近历史(从 jsonl 恢复)
feed = ROOT / 'data' / 'realtime_feed.jsonl'
if feed.exists():
@@ -81,6 +83,11 @@ async def recent_events(_request):
return web.json_response({'events': list(recent)})
async def impact_history(_request):
collector = _request.app['impact']
return web.json_response({'events': collector.history(20)})
async def stats(_request):
return web.json_response({'clients': len(clients), 'buffered': len(recent)})
@@ -106,6 +113,7 @@ def build_app():
app.router.add_get('/', index)
app.router.add_get('/api/recent', recent_events)
app.router.add_get('/api/stats', stats)
app.router.add_get('/api/impact', impact_history)
app.router.add_get('/ws', ws_handler)
app.cleanup_ctx.append(collector_task)
return app