[ Case Study · Autonomous AI Agent ]
An equity analyst that never misses a Sunday
01[ Context ]
This is an autonomous AI research agent I designed and shipped end-to-end: pipeline architecture, agentic prompting strategy, cost engineering, and production deployment. It runs every Sunday without any manual input, fetching Cowry Asset research, live NGX prices, and CBN macro data, then using Claude to produce 8 to 10 fundamental equity picks delivered as a structured Slack briefing.
It was built to be reliable, bounded in cost, and honest about what the model can and cannot be trusted to do. It is a personal research tool, not investment advice, and it makes no claim of trading performance.
02[ Business Problem ]
NGX equity research is scattered. Broker research notes arrive by email, fundamentals and prices live across several sites that do not always agree, analyst houses publish target prices on their own schedules, and macro signals come from the CBN and NBS separately again. Pulling all of that into one coherent weekly view by hand is slow, inconsistent, and easy to skip when the week gets busy.
- Research spread across broker emails, PDFs, analyst houses, and macro feeds
- Prices that disagree between sources, with no built-in cross-checking
- No single synthesised briefing that tracks how the picture changes week to week
- Manual effort that does not scale and quietly gets dropped on busy weekends
03[ Constraints ]
- A 300-second serverless budgetThe whole run executes inside one Vercel function invocation. Fetches run in parallel and a rate-limit retry that would exceed the time budget aborts immediately and falls back, rather than burning the clock on a doomed call.
- Cost must be bounded, not hoped forAn agentic search loop resends its entire growing context every turn. Left uncapped, cost climbs faster than quality. Every expensive step needed a hard ceiling before the first run.
- The model cannot be the source of a numberA language model will state a stale or wrong price with total confidence. For a briefing about money, every figure had to be verifiable in code against an authoritative feed.
- Slack is the mediumThe briefing has to live within Slack block limits and read well as a thread, which shaped the seven-section structure with each section posted as its own message.
04[ Stakeholders ]
This is a solo build with a deliberately small audience: me as the primary user, and the Slack community that follows the agent's development and receives the weekly briefing. The external landscape is the data providers the agent depends on, Cowry Asset Management for research and the authoritative price board, the CBN for macro indicators, and the Nigerian analyst houses whose ratings feed conviction weighting, all publicly available and cited with source and date in every report.
05[ Research ]
The foundational work was source curation: identifying which of the 20+ NGX price, fundamentals, analyst, and macro sources could be trusted for what, and establishing a hierarchy of truth. The Cowry price board became the authoritative price source. The CBN indicators feed became the macro source of truth. Everything else is cross-checked against at least two sources before use.
Price and Fundamentals
End-of-day NGX prices, 52-week ranges, and core ratios, cross-checked across multiple independent sources before use.
Analyst Research
Target prices and buy/sell ratings from Nigerian research houses, each cited with source and date.
Cowry Price Board
Live end-of-week NGX price list from Cowry Asset Management, used as the authoritative price source that overwrites any figure the model proposes.
Macro and Regulatory
CBN policy (MPR, CRR, FX), NBS data (CPI, GDP, trade), and NGX-level announcements and index moves.
Sentiment
Market commentary and index-level narrative to read the mood around names and sectors.
06[ Strategy ]
Separate judgment from facts. The model is treated as an analyst, not a data feed: it may reason, value a company, and argue a thesis, but it is never the source of a number. Every price, index level, fundamental, and macro figure is reconciled in code against an authoritative feed after the model responds. Anything that cannot be confirmed is labelled an estimate rather than presented as fact.
- Live price board is authoritative: after the model proposes picks, code overwrites every current price from the live Cowry price list. The model is never trusted to transcribe a price.
- Unconfirmed prices are flagged, never faked: a ticker missing from the board keeps the model's figure but is tagged an estimate and rendered as "≈ est." in the report, so a guess is never shown as a live quote.
- Fundamentals come from the report, not memory: P/E, ROE, yields and the rest are overwritten with Cowry-reported figures and tagged with their source, replacing the model's stale recall.
- CBN is the macro source of truth: MPR, USD/NGN, and inflation are set from live CBN indicators in code, not lifted from the model's text.
- The outlook invents nothing: the next-week section runs with no web search and is instructed to use only the provided run-time data, citing a date only if it appears there.
- Every report shows its work: the actual data sources used are listed in the Slack footer, and picks are backtested against historical ASI performance.
07[ Options Considered ]
- option 01Daily runs vs a single Sunday deep-diveThe original design ran Monday to Friday. The weekly deep-dive replaced it, cutting the number of expensive agentic runs roughly fivefold for the same weekly insight, and matching how the research is actually consumed.
- option 02Unbounded agentic search vs a capped loopAn unbounded agent would chase marginally more sources while re-paying for its own growing context every turn. The deep analysis instead runs with a hard ceiling of five web searches across at most eight turns: enough breadth to cross-check every price, then commit to writing.
- option 03Trusting the model's numbers vs reconciling in codeLetting the model report prices is simpler and wrong. The chosen design overwrites every figure from authoritative feeds after the model responds, and tags anything unconfirmable as an estimate.
- option 04A dedicated datastore vs Slack as memoryThe weekly snapshot could live in a database. Storing it as compact JSON in a private Slack channel keeps the stack at zero extra infrastructure, and carrying context between weeks costs a few hundred input tokens instead of tens of thousands.
08[ Trade-offs ]
The most expensive part of any research agent is the agentic loop: every turn resends the entire conversation so far as input tokens. The deliberate trade-off is to cap the loop and accept slightly less breadth in exchange for a predictable line item.
- Two-tier callsOnly the NGX analysis pays for the agentic search loop. The week-over-week comparison and next-week outlook use single-shot calls with no tools and tight ceilings (roughly 800 to 1,200 output tokens each), so cheap steps never carry agentic overhead.
- Compact memoryThe snapshot saved for next week stores only the picks and key metrics as small JSON, not the full analysis. Continuity costs hundreds of tokens, not tens of thousands.
- Fail fast inside the budgetA retry that would exceed the function's time budget aborts immediately and falls back, trading a marginally less complete run for one that always finishes.
The numbers behind it: at Sonnet pricing of $3 per million input tokens and $15 per million output, a full Sunday run lands around 48,000 input and 19,000 output tokens, or about $0.43. Four Sundays a month is roughly $1.72. The cap is the reason that figure is stable: the worst case is bounded, not open-ended.
09[ The Weekly Run ]
Every Sunday the agent delivers end to end with zero manual input, in seven steps:
- 01. TriggerA Vercel Cron job fires every Sunday at 06:00 UTC (07:00 WAT), starting the weekly run inside a serverless function with a 300-second budget.
- 02. Parallel research phaseFour I/O-bound fetches run concurrently: the latest Cowry Asset PDF report, the live Cowry price board, the CBN macro indicators feed, and the previous Sunday's snapshot from the Slack store. Parallelism keeps wall-clock time under the serverless budget.
- 03. NGX deep analysisClaude Sonnet runs in-depth equity research across 20+ curated sources with live web search. Every price is cross-checked against at least two sources and cited with its date.
- 04. Historical backtestEach pick is tested against historical All-Share Index performance to ground the week's selections in how similar setups have behaved.
- 05. Week-over-week comparisonA structural diff against last Sunday: which picks were retained, added, or removed, plus price moves on retained names measured against the weekly ASI return.
- 06. Next-week outlookA forward-looking synthesis of catalysts, risks, and key events (CBN and MPC meetings, earnings, auctions, macro releases) for the week ahead.
- 07. Delivery and persistenceA structured seven-section thread is posted to the Slack watchlist channel, and the run snapshot is saved back to a private Slack channel to seed next week's comparison.
10[ Technical Architecture ]
The two diagrams below were mapped out in FigJam. The first traces the Sunday pipeline from trigger to delivery, including the weekly persistence loop. The second shows the components and external integrations behind it.
Architectural Flow: the Sunday weekly deep-dive pipeline
System Design: components and external integrations
Node.js
The agent runtime, deployed as a Vercel serverless function with a 300-second max duration
Claude Sonnet
NGX equity analysis, the week-over-week narrative, and the next-week outlook synthesis
Vercel Cron
Schedules the single Sunday 06:00 UTC deep-dive run
CBN Macro API
Live MPR, USD/NGN, and inflation figures, overwritten in code after the model responds, never taken from model memory
Slack API
Posts the threaded briefing and doubles as the weekly snapshot datastore
Web Search
Live retrieval across 20+ curated NGX price, fundamentals, analyst, and macro sources
The seven-section briefing
11[ Outcomes ]
The agent is live and has been delivering its briefing every Sunday since launch. Each run reads as a continuing story rather than a fresh snapshot, because every report is compared against the previous week:
- Structural diff: picks retained, added, and removed, compared by ticker against the previous Sunday
- Price moves: percentage change on each retained pick measured against the weekly ASI return
- Conviction weighting: two or more brokers rating the same ticker a buy raises conviction; any sell or underperform flag is recorded as a risk on that pick
- Macro shift: MPR, USD/NGN, and inflation compared week over week to frame the backdrop
Below are actual screenshots from a weekly run, posted to the Slack watchlist channel. Use the arrows to browse, or tap any image to expand; they load lazily as you scroll.
12[ Metrics ]
13[ Lessons Learned ]
- Cap the loop before the first run, not after the first bill. In an agentic system, cost climbs faster than quality; the five-search, eight-turn ceiling is the single decision that turned an open-ended task into a predictable line item.
- Treat the model as an analyst, never as a data feed. The reconciliation layer that overwrites every number in code is what makes the reasoning trustworthy; without it, the most eloquent briefing is built on unverified figures.
- Design memory for what the next run needs, not what this run produced. Persisting a compact JSON of picks and metrics, rather than the full analysis, is why week-over-week continuity costs almost nothing.
Disclaimer: All analysis produced by this system is AI-generated and automated. It does not constitute financial or investment advice. Independent due diligence is required before acting on any output. Past signals are not indicative of future results.
Join the Slack channel to follow development, ask questions, and share feedback on the Trading Intelligence Agent.