Skip to content

Commit dfdb9bd

Browse files
committed
Add free source configuration pack
1 parent 9222ce5 commit dfdb9bd

10 files changed

Lines changed: 186 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ python scripts/import_truthsocial_export.py \
9999
uploads `source_events.csv` plus `source_tracker.csv` as a GitHub Actions
100100
artifact. It is intentionally artifact-only and does not publish recommendations.
101101

102+
Free-source setup notes are in
103+
[`docs/free_source_setup.zh-CN.md`](docs/free_source_setup.zh-CN.md).
104+
102105
Run the synthetic event study:
103106

104107
```bash

README.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,5 @@ python -m pytest -q
121121
3. **点名后是否有可交易的统计优势**:需要事件研究和样本外验证,不能只看少数轶事案例。
122122

123123
本仓库先解决前两步的数据结构和复盘框架;第三步需要更多点位和真实行情输入。后续如果需要 LLM 处理长文本,只能作为可替换的抽取工具,不能把模型判断结果写成核心信号合同。
124+
125+
免费数据源配置见 [docs/free_source_setup.zh-CN.md](docs/free_source_setup.zh-CN.md)

config/core_us_equity_aliases.csv

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
symbol,name,aliases
2+
AAPL,Apple,Apple|AAPL|iPhone|iPad|Mac|Tim Cook
3+
AMD,Advanced Micro Devices,AMD|Advanced Micro Devices|Radeon|EPYC|Instinct
4+
AMZN,Amazon,Amazon|AMZN|AWS|Amazon Web Services|Project Kuiper
5+
AVGO,Broadcom,Broadcom|AVGO|VMware
6+
BA,Boeing,Boeing|BA|737 MAX|Starliner
7+
COIN,Coinbase,Coinbase|COIN|crypto exchange
8+
CRWD,CrowdStrike,CrowdStrike|CRWD|Falcon cybersecurity
9+
CVX,Chevron,Chevron|CVX
10+
ENPH,Enphase Energy,Enphase|ENPH|solar inverter
11+
F,Ford,Ford|F|F-150|Mustang Mach-E
12+
GE,GE Aerospace,GE Aerospace|General Electric|GE|jet engine
13+
GME,GameStop,GameStop|GME
14+
GOOGL,Alphabet,Alphabet|Google|GOOGL|GOOG|Gemini|Waymo
15+
INTC,Intel,Intel|INTC|foundry|CHIPS Act
16+
IONQ,IonQ,IonQ|IONQ|quantum computing
17+
JPM,JPMorgan Chase,JPMorgan|JPMorgan Chase|JPM|Jamie Dimon
18+
LMT,Lockheed Martin,Lockheed Martin|LMT|F-35|missile defense
19+
META,Meta Platforms,Meta|META|Facebook|Instagram|WhatsApp|Llama
20+
MSFT,Microsoft,Microsoft|MSFT|Azure|OpenAI|Copilot
21+
MSTR,Strategy,Strategy|MicroStrategy|MSTR|Michael Saylor|Bitcoin treasury
22+
MU,Micron Technology,Micron|MU|HBM|DRAM|NAND
23+
NEE,NextEra Energy,NextEra|NEE|renewable energy
24+
NOC,Northrop Grumman,Northrop Grumman|NOC|B-21
25+
NVDA,NVIDIA,NVIDIA|Nvidia|NVDA|Blackwell|CUDA|GPU
26+
OKLO,Oklo,Oklo|OKLO|nuclear reactor|advanced nuclear
27+
ORCL,Oracle,Oracle|ORCL|cloud infrastructure
28+
PANW,Palo Alto Networks,Palo Alto Networks|PANW|cybersecurity
29+
PLTR,Palantir,Palantir|PLTR|Gotham|Foundry|AIP
30+
QCOM,Qualcomm,Qualcomm|QCOM|Snapdragon
31+
RBLX,Roblox,Roblox|RBLX
32+
RTX,RTX,RTX|Raytheon|Pratt Whitney|missile
33+
SMCI,Super Micro Computer,Supermicro|Super Micro|SMCI|AI server
34+
SMR,NuScale Power,NuScale|SMR|small modular reactor
35+
SOFI,SoFi Technologies,SoFi|SOFI
36+
TSLA,Tesla,Tesla|TSLA|Elon Musk|Cybertruck|FSD|Optimus|xAI
37+
TSM,Taiwan Semiconductor,TSMC|Taiwan Semiconductor|TSM|foundry
38+
UNH,UnitedHealth Group,UnitedHealth|UNH|UnitedHealthcare
39+
VRT,Vertiv,Vertiv|VRT|data center power|liquid cooling
40+
XOM,Exxon Mobil,Exxon|ExxonMobil|XOM

config/free_rss_feeds.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
feed_id,feed_url,source_type,author
2+
whitehouse-presidential-actions,https://www.whitehouse.gov/presidential-actions/feed/,official_remarks,White House
3+
sec-press-releases,https://www.sec.gov/news/pressreleases.rss,regulatory_action,SEC
4+
sec-speeches-statements,https://www.sec.gov/news/speeches-statements.rss,regulatory_action,SEC

config/free_x_queries.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
query_id,query,source_type,author_label
2+
trump-ai-defense-energy,from:realDonaldTrump (NVIDIA OR NVDA OR Tesla OR TSLA OR Intel OR INTC OR Boeing OR Lockheed OR nuclear OR energy OR chip OR tariff OR defense) -is:retweet,verified_social_post,Donald Trump
3+
official-sec-company,from:SECGov (NVIDIA OR Tesla OR Intel OR Microsoft OR Amazon OR Coinbase OR crypto OR AI) -is:retweet,verified_social_post,SEC

data/live/political_events.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
event_id,event_date,symbol,event_type,direction,confidence,source_url,notes

data/live/political_watchlist.csv

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
symbol,name,bucket,research_status,thesis,source_url
2+
AAPL,Apple,named_mentioned,watchlist,"AI devices, supply-chain, tariff, antitrust, and platform-policy watch.",https://www.apple.com/investor-relations/
3+
AMD,Advanced Micro Devices,named_mentioned,watchlist,"AI accelerator and semiconductor export-control watch.",https://ir.amd.com/
4+
AMZN,Amazon,named_mentioned,watchlist,"Cloud AI, government procurement, logistics, and antitrust watch.",https://ir.aboutamazon.com/
5+
AVGO,Broadcom,named_mentioned,watchlist,"AI networking, VMware, and semiconductor policy watch.",https://investors.broadcom.com/
6+
BA,Boeing,policy_capital,watchlist,"Aerospace, defense procurement, export, and safety-regulatory watch.",https://investors.boeing.com/
7+
COIN,Coinbase,named_mentioned,watchlist,"Crypto policy, SEC enforcement, and market-structure watch.",https://investor.coinbase.com/
8+
CRWD,CrowdStrike,policy_capital,watchlist,"Cybersecurity and government security-spend watch.",https://ir.crowdstrike.com/
9+
CVX,Chevron,policy_capital,watchlist,"Energy policy, permitting, oil/gas, and geopolitical-risk watch.",https://chevroncorp.gcs-web.com/
10+
ENPH,Enphase Energy,policy_capital,watchlist,"Solar, tariff, tax-credit, and grid policy watch.",https://investor.enphase.com/
11+
F,Ford,policy_capital,watchlist,"EV subsidy, tariff, labor, and industrial-policy watch.",https://shareholder.ford.com/
12+
GE,GE Aerospace,policy_capital,watchlist,"Aerospace procurement and export-control watch.",https://www.geaerospace.com/investor-relations
13+
GOOGL,Alphabet,named_mentioned,watchlist,"AI, antitrust, cloud, search, and autonomous-driving policy watch.",https://abc.xyz/investor/
14+
INTC,Intel,policy_capital,watchlist,"CHIPS Act, foundry, export-control, and domestic semiconductor policy watch.",https://www.intc.com/
15+
IONQ,IonQ,named_mentioned,watchlist,"Quantum computing and government research funding watch.",https://investors.ionq.com/
16+
JPM,JPMorgan Chase,named_mentioned,watchlist,"Bank regulation, rates, credit, and market-structure watch.",https://www.jpmorganchase.com/ir
17+
LMT,Lockheed Martin,policy_capital,watchlist,"Defense procurement, missile defense, and geopolitics watch.",https://investors.lockheedmartin.com/
18+
META,Meta Platforms,named_mentioned,watchlist,"AI, social regulation, privacy, antitrust, and metaverse watch.",https://investor.fb.com/
19+
MSFT,Microsoft,named_mentioned,watchlist,"AI, cloud procurement, antitrust, and cybersecurity watch.",https://www.microsoft.com/en-us/Investor
20+
MSTR,Strategy,named_mentioned,watchlist,"Bitcoin treasury, crypto regulation, and capital-market sentiment watch.",https://www.strategy.com/investor-relations
21+
MU,Micron Technology,policy_capital,watchlist,"Memory, HBM, export-control, and domestic semiconductor policy watch.",https://investors.micron.com/
22+
NEE,NextEra Energy,policy_capital,watchlist,"Power demand, renewable policy, grid, and data-center energy watch.",https://www.investor.nexteraenergy.com/
23+
NOC,Northrop Grumman,policy_capital,watchlist,"Defense procurement, drone/space, and geopolitical-risk watch.",https://investor.northropgrumman.com/
24+
NVDA,NVIDIA,policy_capital,watchlist,"AI accelerator, export-control, data-center, and sovereign AI policy watch.",https://investor.nvidia.com/
25+
OKLO,Oklo,policy_capital,watchlist,"Advanced nuclear, data-center power, and DOE/NRC policy watch.",https://oklo.com/investors/
26+
ORCL,Oracle,named_mentioned,watchlist,"Cloud infrastructure, sovereign cloud, and AI data-center watch.",https://investor.oracle.com/
27+
PANW,Palo Alto Networks,policy_capital,watchlist,"Cybersecurity, federal spend, and breach-response watch.",https://investors.paloaltonetworks.com/
28+
PLTR,Palantir,policy_capital,watchlist,"Defense AI, government procurement, and public-sector software watch.",https://investors.palantir.com/
29+
QCOM,Qualcomm,named_mentioned,watchlist,"Mobile AI, China exposure, export-control, and auto-chip watch.",https://investor.qualcomm.com/
30+
RBLX,Roblox,named_mentioned,watchlist,"Youth safety, platform policy, and gaming/metaverse watch.",https://ir.roblox.com/
31+
RTX,RTX,policy_capital,watchlist,"Defense procurement, aerospace supply chain, and missile-demand watch.",https://investors.rtx.com/
32+
SMCI,Super Micro Computer,named_mentioned,watchlist,"AI server, data-center supply chain, and governance watch.",https://ir.supermicro.com/
33+
SMR,NuScale Power,policy_capital,watchlist,"Small modular reactor, nuclear policy, and DOE/NRC watch.",https://www.nuscalepower.com/en/investors
34+
SOFI,SoFi Technologies,named_mentioned,watchlist,"Fintech, bank regulation, student-loan policy, and consumer-credit watch.",https://investors.sofi.com/
35+
TSLA,Tesla,named_mentioned,watchlist,"EV, autonomy, energy storage, tariff, safety, and Elon Musk social signal watch.",https://ir.tesla.com/
36+
TSM,Taiwan Semiconductor,policy_capital,watchlist,"Semiconductor foundry, export-control, Taiwan risk, and CHIPS policy watch.",https://investor.tsmc.com/
37+
UNH,UnitedHealth Group,named_mentioned,watchlist,"Healthcare policy, Medicare, antitrust, and regulatory watch.",https://www.unitedhealthgroup.com/investors.html
38+
VRT,Vertiv,policy_capital,watchlist,"Data-center power, cooling, AI infrastructure, and grid constraints watch.",https://investors.vertiv.com/
39+
XOM,Exxon Mobil,policy_capital,watchlist,"Energy policy, drilling, LNG, and geopolitical-risk watch.",https://corporate.exxonmobil.com/investors

docs/free_source_setup.zh-CN.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# 免费数据源配置
2+
3+
## 已落地文件
4+
5+
- `config/free_rss_feeds.csv`:无需账号的官方 RSS 源。
6+
- `config/core_us_equity_aliases.csv`:核心美股观察池别名。
7+
- `config/free_x_queries.csv`:X recent-search 查询模板,需要 `X_BEARER_TOKEN` 后才能运行。
8+
- `data/live/political_watchlist.csv`:真实发布链路的初始观察池。
9+
- `data/live/political_events.csv`:人工核验后的真实事件输入,初始为空表头。
10+
11+
## 免费且无需注册
12+
13+
当前可直接跑:
14+
15+
- White House presidential actions RSS。
16+
- SEC press releases RSS。
17+
- SEC speeches/statements RSS。
18+
- Federal Register API:无需 API key,适合作为下一步 API adapter。
19+
- USAspending API:公开 endpoints 当前不需要 authorization,适合做政府合同/资金流 adapter。
20+
21+
运行 RSS:
22+
23+
```bash
24+
gh workflow run "RSS Source Pipeline" \
25+
--repo QuantStrategyLab/PoliticalEventTrackingResearch \
26+
-f feeds_path=config/free_rss_feeds.csv \
27+
-f aliases_path=config/core_us_equity_aliases.csv \
28+
-f max_items_per_feed=25
29+
```
30+
31+
## 免费但需要注册 key
32+
33+
- X API Recent Search:需要 X Developer / App Bearer Token。免费层是否够用取决于 X 当前政策和额度。
34+
- Congress.gov API:需要 api.data.gov key,通常可免费申请。
35+
36+
配置 X:
37+
38+
```bash
39+
gh secret set X_BEARER_TOKEN \
40+
--repo QuantStrategyLab/PoliticalEventTrackingResearch
41+
```
42+
43+
运行 X:
44+
45+
```bash
46+
gh workflow run "X Recent Search Pipeline" \
47+
--repo QuantStrategyLab/PoliticalEventTrackingResearch \
48+
-f queries_path=config/free_x_queries.csv \
49+
-f aliases_path=config/core_us_equity_aliases.csv \
50+
-f max_results=10
51+
```
52+
53+
## 免费但建议谨慎
54+
55+
- Truth Social 没有稳定官方公开开发者接口。当前建议先用导出 JSON 或经确认合规的第三方工具,再导入 `source_items.csv`
56+
- 开源 `truthbrush` 可作为候选工具,但应先做合规和稳定性验证,不能直接作为高置信来源。
57+
58+
## 开源项目候选
59+
60+
- Federal Register 官方 API core:`usnationalarchives/federalregister-api-core`
61+
- USAspending 官方 API:`fedspendingtransparency/usaspending-api`
62+
- SEC EDGAR downloader:`jadchaar/sec-edgar-downloader`
63+
- SEC EDGAR package:`sec-edgar/sec-edgar`
64+
- Truth Social candidate:`w2rc/truthbrush`
65+
66+
这些项目只作为 adapter 参考,不直接引入依赖。当前仓库优先用标准库和 CSV artifact,降低 VPS 与供应链风险。
67+
68+
## 推荐运营流程
69+
70+
1. RSS/X/Truth Social 先生成 `source_items.csv``source_events.csv`
71+
2. 人工核验后,把确认事件写入 `data/live/political_events.csv`
72+
3. 发布 Advisor 时使用:
73+
74+
```bash
75+
gh workflow run "Publish Model Recommendations Site" \
76+
--repo QuantStrategyLab/QuantAdvisorResearch \
77+
-f as_of=2026-05-30 \
78+
-f political_events_path=data/live/political_events.csv \
79+
-f political_watchlist_path=data/live/political_watchlist.csv \
80+
-f ai_signal_path=data/output/latest_signal.json
81+
```
82+
83+
如果 `political_events_path` / `political_watchlist_path` 不在 `examples/` 下,Advisor 输出会标记为 `source_mode=operator_supplied`

src/political_event_tracking_research/source_mention_extract.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def load_aliases(path: str | Path) -> list[MentionAlias]:
6060

6161
def alias_pattern(alias: str) -> re.Pattern[str]:
6262
escaped = re.escape(alias)
63+
if re.fullmatch(r"[A-Za-z]", alias):
64+
return re.compile(rf"(?<![A-Za-z0-9])\${escaped}(?![A-Za-z0-9])", re.IGNORECASE)
6365
if re.fullmatch(r"[A-Za-z][A-Za-z0-9.\-]{0,9}", alias):
6466
return re.compile(rf"(?<![A-Za-z0-9$])\$?{escaped}(?![A-Za-z0-9])", re.IGNORECASE)
6567
return re.compile(escaped, re.IGNORECASE)
@@ -145,4 +147,3 @@ def main(argv: list[str] | None = None) -> None:
145147

146148
if __name__ == "__main__":
147149
main()
148-

tests/test_source_mention_extract.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ def test_match_symbols_supports_ticker_and_name_aliases() -> None:
1717
assert match_symbols("PREVT1 should not match.", aliases) == []
1818

1919

20+
def test_single_letter_ticker_requires_cash_tag_or_name_alias() -> None:
21+
aliases = [MentionAlias(symbol="F", aliases=("F", "Ford", "F-150"))]
22+
23+
assert match_symbols("5 C.F.R. mentions investment workforce.", aliases) == []
24+
assert match_symbols("$F is mentioned.", aliases) == ["F"]
25+
assert match_symbols("Ford is mentioned.", aliases) == ["F"]
26+
assert match_symbols("F-150 policy is mentioned.", aliases) == ["F"]
27+
28+
2029
def test_extract_source_records_outputs_confidence_by_source_type(tmp_path: Path) -> None:
2130
output = tmp_path / "source_events.csv"
2231

@@ -32,4 +41,3 @@ def test_extract_source_records_outputs_confidence_by_source_type(tmp_path: Path
3241
assert by_symbol["EVT3"]["confidence"] == "low"
3342
assert by_symbol["EVT4"]["event_type"] == "procurement"
3443
assert output.exists()
35-

0 commit comments

Comments
 (0)