What This Example Shows
- A reasoning agent on
claude-opus-4-8withreasoning_effort: "high"setting the load-bearing inputs: revenue growth, margin trajectory, terminal growth, WACC - A four-stage
SequentialWorkflowthat turns the reasoned assumptions into an audited DCF, sensitivity grids, and an analyst-grade memo - Per-agent function tools that pull income statement, balance sheet, cash flow, consensus estimates, and run the actual DCF math
- A 50-name overnight refresh fired as one POST to
/v1/swarm/batch/completions, scheduled in the night-mode window for a 50% discount - A structured one-pager memo per ticker — exec summary, fair value bands, sensitivity tables, key assumptions, risks — sitting in the database before 6am Pacific
reasoning_effort: "high" and /v1/swarm/batch/completions are Premium-tier features. Pair them with the Night-Mode Pricing Strategy — overnight execution between 9pm and 6am Pacific is billed at a 50% discount, which is what makes a 50-name nightly DCF refresh land under $80 of compute.Why This Matters
The DCF is the load-bearing instrument of fundamental investing. Every BUY thesis at a long-only fund eventually reduces to a sheet that says “I think this company’s free cash flow ramps from X to Y, discounted at Z, gives me a fair value of W per share.” Refreshing one DCF properly — pulling the latest statements, re-reasoning the assumptions against the most recent quarter, rerunning sensitivities, and writing the memo — is half a day of associate work. A 50-name portfolio refresh through earnings season is a team of associates working for weeks. The job here is to do that work overnight, mechanically, with the reasoning step handled by Opus at high effort so the assumptions are actually defensible — and the math handled by cheaper mechanical models because the math is just math. Every morning at 6am Pacific, fifty fresh DCFs are sitting in the DB — assumptions reasoned by Opus, math run mechanically, memos written like an associate did them, for under $80 of overnight compute.The Architecture
One reasoning pass per ticker sets the assumptions. A four-stage Sequential pipeline turns those assumptions into a model, runs the sensitivity tables, and writes the memo. The whole thing fans out 50-wide as a single batch POST.Step 1: Setup
Install dependencies and set the two env vars.FMP_API_KEY is Financial Modeling Prep — any equivalent statements provider works; the function-tool schemas below are the contract, not the vendor.
Step 2: Define the Function Tools
These are OpenAI-format function schemas the agents call to pull data and run mechanical math. Define them once; attach viatools_dictionary to whichever agent needs them.
The tool schemas are the contract — your backend resolves them against whatever data vendor you use. For a self-contained walkthrough, the Reasoning agent and the DCF Model worker can both make the function calls; the orchestrator delivers the resolved tool outputs back into the conversation. The math tools (
build_dcf, sensitivity_table) are mechanical — wire them to a pure-Python DCF library, not an LLM.Step 3: The Reasoning Assumption Agent
This is the only step where you spend real model dollars. Opus 4.8 atreasoning_effort: "high" reads the last five years of financials, the consensus, and the company’s own guidance, and produces a defensible set of assumptions — not a wishlist. Everything downstream is mechanical.
reasoning_effort: "high" is what makes the assumptions defensible. On medium effort, the agent will frequently anchor on consensus without questioning the path; on high effort, it interrogates margin trajectory and capex against actual historical patterns. This is the one place to spend.Step 4: The SequentialWorkflow Pipeline
Four workers, each cheap, each doing one well-defined job. The Assumptions Builder ingests the reasoned output and emits a strict JSON spec the math layer can consume. The DCF Model and Sensitivity Tables are mechanical — they callbuild_dcf and sensitivity_table and report results. The Memo Writer is the only stage that needs prose quality, and Sonnet handles that cheaply.
Step 5: Run One Ticker End-to-End
Run the reasoning pass first, hand its output to the Sequential pipeline, print the memo. This is the loop you will scale.Step 6: Overnight Portfolio Refresh
The whole point. Fan the same per-ticker pipeline across 50 names as a single batch POST. Schedule the cron at 9pm Pacific so the entire batch runs inside the night-mode window and bills at 50% off.The batch lands in the database by ~5am Pacific. See Night-Mode Pricing Strategy for why scheduling between 9pm and 6am Pacific cuts the bill in half — the same workload at 11am Pacific is twice as expensive for identical output.
Step 7: The Memo Output Format
Every memo lands in the database with the same skeleton. The PM reads the executive summary on every name in five minutes; they drill into the sensitivity tables only on names where the call is close.Real Cost vs. IB Associate Time
The hero number — and it isn’t subtle.| Approach | Per-ticker cost | Nightly (50 names) | Annualized | Refresh latency |
|---|---|---|---|---|
| This pipeline (Opus reasoning + Sequential math + night-mode) | ~$1.50 | ~$75 | ~$19,000 | Overnight, every name |
| One IB associate, fully loaded $250k | — | ~$1,000 of their day | ~$250,000 | 5 names/day before burnout |
| Three-associate coverage pod | — | ~$3,000 of their day | ~$750,000 | 12-15 names/day |
Next Steps
- Build an AI Hedge Fund Research Pipeline — the HierarchicalSwarm pattern for buy/sell/hold calls upstream of the DCF refresh
- Reasoning Agents for Hard Analytical Problems — the standalone primitive for the Opus reasoning pass, with the full
swarm_typecatalog - Night-Mode Pricing Strategy — why scheduling the batch between 9pm and 6am Pacific is what makes the 50-name refresh land under $80