Trading Intelligence Agent NGX Equity Research
An autonomous AI research agent I designed and shipped end-to-end: from pipeline architecture and agentic prompting strategy to 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–10 fundamental equity picks with a structured Slack briefing as output. Built to be reliable, bounded in cost, and honest about what the model can and cannot be trusted to do.
Agentic system design
Multi-step pipeline where Claude handles reasoning and deterministic code handles data truth: a deliberate separation most builders skip.
Reliability engineering
Every step has a fallback. Prices are reconciled post-analysis. Unverified figures are labelled estimates. The run never fails silently.
Cost discipline
Hard token ceilings, compact cross-week memory, and a single weekly run replace an unbounded daily schedule, same insight at 80% lower cost.
8–10
Equity picks per run, each with thesis and broker conviction
Weekly
Fully autonomous: fires every Sunday at 7am WAT, zero manual input
$0.43
Average cost per full run, bounded by design, not open-ended
7
Structured Slack thread sections, posted and persisted automatically
The 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
Architecture and System Design
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
The Sunday Deep-Dive Pipeline
Step 1: Trigger
A 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.
Step 2: Parallel Research Phase
Four 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 loaded from the Slack store. Running them in parallel keeps the overall wall-clock time under the serverless budget.
Step 3: NGX Deep Analysis
Claude 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.
Step 4: Historical Backtest
Each pick is tested against historical All-Share Index performance to ground the week's selections in how similar setups have behaved.
Step 5: Week-over-Week Comparison
A structural diff against last Sunday: which picks were retained, added, or removed, plus price moves on retained names measured against the weekly ASI return.
Step 6: Next-Week Outlook
A forward-looking synthesis of catalysts, risks, and key events (CBN and MPC meetings, earnings, auctions, macro releases) for the week ahead.
Step 7: Delivery and Persistence
A 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.
Research Sources
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.
Ensuring Report Accuracy
A language model will state a stale or wrong price with total confidence. The whole design treats the model as an analyst, not a data feed: it decides what to buy and why, but the numbers behind those decisions are verified, not taken on trust.
The core principle
Separate judgment from facts. The model 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.
Week-over-Week Intelligence
Each run is compared against the previous Sunday so the briefing reads as a continuing story rather than a fresh snapshot every 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
The Slack Analyst Briefing
The output is a single Slack thread: a header card followed by seven threaded sections, each posted as its own message to stay within Slack block limits and keep the report scannable.
Technical Stack
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 monetary policy rate, 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
Sample Output: The Live Slack Briefing
Actual screenshots from a weekly run, posted to the Slack watchlist channel. Use the ‹ and › arrows to browse, or tap any image to expand. They load lazily as you scroll, so they never slow the page down.
Token Economics and the Search Trade-Off
The most expensive part of any research agent is the agentic loop. With web search enabled, the model runs in turns: it searches, reads the results, and decides whether to search again. The catch is that every turn resends the entire conversation so far, including all prior search results, as input tokens. Left unbounded, a thorough run keeps re-paying for its own growing context on every turn, and cost climbs faster than quality does.
The deliberate trade-off
Cap the loop. The deep analysis runs with a hard ceiling of five web searches across at most eight turns. An unbounded agent would chase marginally more sources; the capped agent gathers enough breadth to cross-check every price against multiple sources, then commits to writing. That one decision turns an open-ended research task into a predictable line item.
- ›Two-tier calls: only 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 memory: the snapshot saved for next week's comparison stores only the picks and key metrics as a small JSON, not the full analysis. Carrying context between weeks costs a few hundred input tokens instead of tens of thousands.
- ›One run, not five: a single Sunday deep-dive replaced a daily Monday-to-Friday schedule, cutting the number of expensive agentic runs roughly fivefold for the same weekly insight.
- ›Fail fast inside the budget: a rate-limit retry that would exceed the function's time budget aborts immediately and falls back, rather than burning the clock and tokens on a doomed call.
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.
Built as a personal research tool. It gathers, cross-checks, and structures publicly available information into a weekly briefing. It is not investment advice, and it makes no claim of trading performance.
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.