Skip to main content
Two thousand articles cross the wire today. Eighty actually overlap your book. The engine posts a thesis on each of those eighty in Slack — and ignores the rest.

What This Example Shows

  • A HierarchicalSwarm with 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. The Free tier’s request-rate ceiling (100/minute, 350/hour, 1,200/day) is easy to hit once the overlap gate is firing dozens of swarm calls a day on top of your other traffic; Premium raises that to 2,000/minute, 10,000/hour, 100,000/day. Upgrade at https://cloud.swarms.world/settings. 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

HierarchicalSwarm supplies its own director agent — set via the SwarmSpec-level director_model_name field, not as an entry in agents — so every agent you list below is a worker the director can route to. The director runs on claude-sonnet-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-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. The swarm_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.

Step 7: Production Observability

At sustained continuous volume, observability is not optional — it is the SLA. Track the metrics that matter when news latency is the product in your own logging layer: 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. GET /v1/account/logs gives you the request-level audit trail and GET /v1/rate/limits gives you the live rate-limit window, both of which feed straight into that dashboard; Premium’s higher per-minute/hour/day ceiling (see above) is what keeps the missed-news SLA inside budget at peak earnings-week volume. 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. The math isn’t “fire the analyst.” The math is: your sector-rotation analyst reads maybe 200 articles end-to-end on a heavy day and writes up the three they think matter. The engine reads all 2,000, identifies all 80 that overlap the book, and posts a structured thesis on each — for $80/day. The analyst gets to spend their day on the five names that need real human judgement, and the desk stops missing the other 75.

Next Steps