event-driven
它能做什么
这项技能让智能体把新闻、公告和政策更新转化为有评分的事件数据,用于交易。适合希望对事件做出反应、并将其与价格信号结合的交易者。
适用场景
- ✓当你想为某家公司或某个行业的近期新闻进行情绪评分的时候。
- ✓当你想把公告和政策更新中的事件信号加入策略的时候。
- ✓当你希望把事件数据保存在一张简单的表格中,与交易逻辑分开的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/event-driven/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请收集本周关于这家公司的新闻,为每条新闻的情绪和影响评分,并将其与我们的价格信号结合。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会获取新闻和公告的全文,让 AI 将每条内容在从极度看跌到极度看涨的范围内评分,并把结果保存到表格中。然后一个信号文件会应用时间衰减,并将事件得分与技术信号融合。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Event-Driven Strategy
Purpose
Uses event information such as news, announcements, and macro policy updates. The LLM analyzes sentiment and impact magnitude to generate event-driven trading signals. Event data is managed in CSV format, and technical signals are combined with event signals through weighted aggregation to form the final trading decision.
Workflow
- Data collection: use the
read_urltool to fetch the full text of news and announcements - LLM analysis: the LLM reads the news and scores it from
-1.0to1.0with a standardized prompt (extremely bearish to extremely bullish) - Generate the event CSV: write data in the
date,event_type,score,source,summaryschema - Signal aggregation:
signal_engine.pyreads the event CSV, applies time decay, and combines it with the technical signal
Key principle: the event CSV is the data layer, and signal_engine.py is the logic layer. Keep them decoupled.
Event CSV Schema
date,event_type,score,source,summary
2024-01-15,earnings,0.8,read_url,Q4 revenue beat expectations by 30%
2024-01-20,macro,-0.5,read_url,Central bank raised rates by 25bp
2024-02-01,policy,0.3,read_url,New-energy subsidies extended
2024-02-10,sentiment,-0.7,read_url,Bearish sentiment surged on social media
2024-03-05,insider,0.4,read_url,CEO bought 5 million shares
Field descriptions:
| Field | Type | Description |
|---|---|---|
| date | str (YYYY-MM-DD) |
Date when the event became knowable (publication date, not occurrence date. If released after market close → use the next trading day) |
| event_type | str | earnings / macro / policy / sentiment / insider / technical_break |
| score | float | -1.0 ~ 1.0 (standardized LLM score) |
| source | str | Data-source tag (such as read_url) |
| summary | str | Event summary (one sentence, no commas) |
Event Type Details
| Type | Meaning | Typical Impact | Duration |
|---|---|---|---|
| earnings | Earnings release | Short-term shock | 1-5 days |
| macro | Macro data / central-bank policy | Medium-term impact | 5-20 days |
| policy | Industry policy / regulatory change | Long-term impact | 20-60 days |
| sentiment | Market sentiment / public opinion | Short-term shock | 1-3 days |
| insider | Insider trading / block trade | Medium-term signal | 5-10 days |
| technical_break | Break of a key technical level | Short-term catalyst | 1-5 days |
Signal Aggregation
Time Decay of Event Signals
Event impact decays exponentially over time:
import numpy as np
import pandas as pd
def compute_event_signal(event_df: pd.DataFrame, dates: pd.DatetimeIndex,
decay_lambda: float = 0.1,
min_score_threshold: float = 0.2,
event_lookback: int = 30) -> pd.Series:
"""Compute an event-driven signal with time decay.
Args:
event_df: DataFrame loaded from the event CSV, with date/event_type/score/source/summary columns.
dates: Backtest date sequence (DatetimeIndex).
decay_lambda: Decay coefficient. Higher values decay faster. Default 0.1 (decays to ~37% in about 10 days).
min_score_threshold: Minimum score threshold. Events with |score| below this value are ignored.
event_lookback: Event lookback window in days. Events older than this are excluded.
Returns:
Event signal Series aligned with dates, with value range [-1.0, 1.0].
"""
event_df = event_df[event_df["score"].abs() >= min_score_threshold].copy()
event_df["date"] = pd.to_datetime(event_df["date"])
signal = pd.Series(0.0, index=dates)
for trade_date in dates:
# Only consider events published on or before trade_date (avoid look-ahead)
mask = (event_df["date"] <= trade_date) & \
(event_df["date"] >= trade_date - pd.Timedelta(days=event_lookback))
relevant = event_df[mask]
if relevant.empty:
continue
days_since = (trade_date - relevant["date"]).dt.days.values
scores = relevant["score"].values
# Exponential decay: score * exp(-lambda * days)
decayed = scores * np.exp(-decay_lambda * days_since)
# Sum multiple events and clip to [-1, 1]
signal[trade_date] = np.clip(decayed.sum(), -1.0, 1.0)
return signal
Weighted Combination of Technical and Event Signals
def combine_signals(tech_signal: pd.Series, event_signal: pd.Series,
常见问题
分数范围是什么意思?
分数从负一(极度看跌)到正一(极度看涨)。
为什么要把事件数据保存在单独的文件中?
这样可以把数据和交易逻辑分开,使两者都更容易检查和修改。
旧新闻还算数吗?
算,但它的影响会随着时间衰减而逐渐减弱。
详情
作者的原始描述
Event-driven strategy based on sentiment-scored signals from news, announcements, and macro events. The LLM acts as the NLP engine, and event data follows a CSV schema.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7517
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …