What This Example Shows
- A
HierarchicalSwarmwith a News Director coordinating four per-sector workers — Tech, Energy, Healthcare, Financials — running in parallel on each article - A continuous webhook ingestion path that accepts Bloomberg, Reuters, and AP feeds straight into a FastAPI endpoint
- Function tools that hit your portfolio database for entity-to-ticker resolution, position-size lookup, and the only-fire-when-relevant overlap gate
- A cheap Python pre-filter that runs before the swarm so 96% of the firehose never costs a token
- A Trade Idea Synthesizer that emits a structured thesis straight to Slack — ticker, position size, sentiment, suggested action, time horizon, confidence
- Sustained high-volume throughput with the observability needed to track a missed-news SLA
This pipeline runs continuously against a 24/7 news firehose at sustained volume. Upgrade to Premium at https://swarms.world/platform/account for the throughput headroom, priority processing, and the observability dashboard needed to monitor the missed-news SLA. See the Production Observability Guide for the metrics that matter when news latency is the product.
Why This Matters
Most PMs are drowning in a news firehose where 99% of articles are irrelevant to their book — a tariff print on a name you don’t hold is just noise, and by the time the analyst pod has read enough of the daily clip file to find the one piece that matters, the move has already happened. The alpha is in the 1% of articles that overlap a position you actually hold and carry a real signal, and that 1% needs to be in front of the PM in Slack within 60 seconds of the article publishing — not in the 8:30 AM morning meeting, not in the afternoon clip review, but now, before the desk you’re competing against has finished reading the headline. This engine is the portfolio-aware filter that turns the firehose into exactly that: a Slack channel that only pings when something on your book just moved.The Architecture
Step 1: Setup
Install dependencies and pull your API key from https://swarms.world/platform/api-keys.Step 2: Define the Function Tools
The workers and the synthesizer share a toolbox that resolves entities to tickers, checks your actual book, scores sentiment, and posts the final thesis. Every tool follows the OpenAI function-call schema.Step 3: Define the Hierarchical Swarm
The News Director runs onclaude-sonnet-4.5 because synthesizing multi-sector takes into a single coherent dispatch needs strong reasoning. The four sector workers run on gpt-4.1-mini — they are doing tight, scoped, per-sector reasoning over a single article, which is exactly the workload that cheap fast models eat for breakfast. The Trade Idea Synthesizer goes back to claude-sonnet-4.5 because the final thesis is the artifact that lands in front of the PM.
Step 4: The FastAPI Webhook Endpoint
The vendor (Bloomberg, Reuters, AP) POSTs every article to/webhook/news. The webhook does the cheap work first: extract entities, resolve to tickers, intersect with the live book. Only if the overlap is non-empty does the swarm fire. This is the single most important cost lever in the entire pipeline.
The overlap gate is the cost-control layer. At a full feed of ~2,000 articles/day, roughly 4% will mention something on the book — call it 80 articles. Every article that fails the gate costs you a few milliseconds of Python and zero tokens. Skip the gate and you’re paying for 2,000 swarm runs to discover 1,920 of them weren’t relevant.
Step 5: The Per-Article Swarm Call
When the gate passes, POST the article into the swarm. Theswarm_type is HierarchicalSwarm — the News Director fans out to the four sector workers, collects their takes, and the Trade Idea Synthesizer calls post_trade_thesis_to_slack once per overlapping ticker.
Step 6: The Trade Thesis Output Schema
Every thesis the synthesizer posts to Slack is a structured object. This is what your PM sees and what gets persisted into the research database for audit.| Field | Type | Notes |
|---|---|---|
ticker | string | Must be a ticker currently in the book |
position_size_usd | int | Pulled live via lookup_position_size |
article_url | string | Source link, always preserved for audit |
sentiment | float | [-1.0, 1.0] toward this specific ticker |
suggested_action | enum | HOLD / ADD / REDUCE / EXIT |
thesis_one_liner | string | One sentence. The PM reads 20 of these a day. |
time_horizon | string | e.g. "intraday", "2-6 weeks", "1-2 quarters" |
confidence | enum | LOW / MEDIUM / HIGH |
Step 7: Production Observability
At sustained continuous volume, observability is not optional — it is the SLA. The Premium observability dashboard tracks the metrics that matter when news latency is the product: articles ingested per minute, articles passing the overlap gate, swarm calls fired, theses posted to Slack, p50/p99 article-to-Slack latency, and — most importantly — the missed-news SLA: any article that overlapped the book but failed to produce a thesis within the 60-second budget. The dashboard, the priority processing queue that keeps the missed-news SLA inside the budget at peak earnings-week volume, and the per-route throughput headroom are Premium-tier features. See the Production Observability Guide for the full set of metrics and alerting recipes.Real Cost vs. Bloomberg + Headcount
The engine doesn’t replace humans — it captures the 90% of relevance their day misses. At a full feed of ~2,000 articles/day, the overlap gate filters to ~80 swarm calls/day.| Line item | Volume | Cost |
|---|---|---|
| Articles ingested (gate only, no LLM) | ~2,000/day | ~$0/day |
| Swarm runs (post-gate, full hierarchical) | ~80/day | ~$80/day |
| Engine total | ||
| Bloomberg terminal × 5 PMs | $24K/seat/yr | $120K/yr |
| Sector-rotation analyst (fully loaded) | 1 FTE | $200K/yr |
| Human stack total | $320K/yr |
Next Steps
- See the AI Hedge Fund Research Pipeline for the morning-meeting batch variant of the same hierarchical pattern
- Read the Production Observability Guide for the missed-news SLA dashboard and Premium-tier throughput configuration