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
/v1/agent/batch/completions and /v1/swarm/batch/completions are Premium-tier features, and claude-opus-4-8 is a premium-only model — the free tier rejects it with suggested alternatives such as claude-sonnet-5. Note the night-mode discount applies only to /v1/swarm/completions and /v1/swarm/batch/completions — the Assumption Reasoner’s /v1/agent/batch/completions call is billed at the standard rate regardless of time of day. Pair the SequentialWorkflow stage (Step 6, below) with the Night-Mode Pricing Strategy — running it between 8pm and 6am Pacific halves its token cost, which is part of what keeps a 50-name nightly DCF refresh under roughly $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_list_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 batch. Schedule the cron at 9pm Pacific so the run lands inside the night-mode window — the SequentialWorkflow stage (/v1/swarm/batch/completions) bills its tokens at 50% off in that window; the /v1/agent/batch/completions reasoning stage bills at the standard rate either way.
The batch lands in the database by ~5am Pacific. See Night-Mode Pricing Strategy for how the off-peak discount works — it halves the token cost of the SequentialWorkflow stage specifically (
/v1/swarm/batch/completions), not the Opus reasoning stage, so scheduling overnight still lowers the total bill versus running the same workload at, say, 11am Pacific.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.
A single associate covers maybe five names a day before quality degrades. Three associates cover fifteen. The portfolio has fifty. The math has never worked — every fundamental shop either ships stale DCFs or ships none. This pipeline ships fifty fresh DCFs every morning before the desk arrives, for less than 8% of one associate’s salary and roughly 3% of the three-associate pod’s cost. The associate isn’t replaced — they spend their day on the names the memo flagged as conviction-changing, instead of grinding through statement updates that didn’t move the call.
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 — how the off-peak discount on
/v1/swarm/completionsand/v1/swarm/batch/completionsfactors into the 50-name refresh’s total cost