Off the clock · Mar 2026
Multi-agent equity research for Indian stocks
A local research desk that started as one Claude agent with one prompt and grew into eleven specialists, 150+ sector skill files and a Gemini-graded eval loop, all reading one database of Indian (and now US) market data.
How do I actually grade a stock?
I wanted to invest, and I didn't know how to grade a stock. The evidence for any one company in India is spread across a dozen places: fund flows and shareholding on NSE, financials on Screener.in, concall transcripts and annual reports as PDFs on BSE, and the macro picture buried in RBI reports and the Union Budget. Looking at one of these gave me a story. Looking at all of them was a weekend per stock.
TODO(tarang): a line on what tipped you from reading about it to building it.
Not having enough understanding of how to grade stocks, I started building tools to help me invest. Today it is a tool that collects all of that into one database on my laptop, with a team of Claude agents on top that each look at the company from one angle, get their numbers checked and get combined into a thesis. It writes reports, it doesn't place trades. We started with one naive agent and one long prompt, then broke it down into specialists, sectors and so many sub-skills that most of this post is the story of that breaking apart.
How it works today
flowchart TD
A["Market data: NSE, BSE, Screener, RBI, US filings"] --> B[("One local database")]
C["Concall transcripts, annual reports, investor decks"] --> D["Read and summarised by Claude"]
D --> B
B --> E["Eleven specialists, one angle each"]
F["Sector skill files"] --> E
E --> G["Number checker"]
G --> H["Web research for open questions"]
H --> I["Rules that flag known traps"]
I --> J["Synthesis writes the verdict"]
J --> K["Report, plus a beginner-friendly version"]
K -.-> L["Gemini grades the report"]
L -.-> M["Edit a prompt or a skill file"]
M -.-> F
I give it a stock symbol and it refreshes the company's data and its peers', reads its concalls, annual reports and investor decks, runs the specialists, checks their numbers, chases open questions on the web and writes a verdict, with a beginner-friendly version alongside. It now runs on US stocks too.
Data first, and agents stay offline
Everything lands in one local database of about 90 tables, with the units fixed at the door after I got burned by them.
The rule I care about most is that agents read the database and never the internet (except the news, macro and web research agents, on purpose). The data is refreshed before any agent starts. I wanted that because a run can then be reproduced, and every number an agent quotes came out of a lookup I can log, which is what makes checking it possible. The maths is done in plain Python, so the model interprets numbers rather than producing them.
Eleven specialists and their skill files
The specialists are business, financials, ownership, valuation, risk, technical, sector, news, macro, historical analogs and F&O positioning, all on Claude Sonnet 4.6, each with its own small set of tools and a budget. If risk, financials or valuation fails, the verdict caps its confidence. I'd rather get a clearly weaker report than a confident one built on half the evidence.
I thought a bank shouldn't be graded like a telecom company, and that's what the skill files are for. There are 150+ of them across 30 sectors, plain Markdown, picked by the company's sector. A bank's valuation file talks about price-to-book and credit costs; a telecom's talks about revenue per user and spectrum. Above them sit the habits I care about most: every number needs context against peers or history, and an agent can't claim "no insider activity" without having looked.
Checking, rules and the verdict
As soon as a specialist finishes, Claude Haiku checks five to eight of its numbers against what the tools actually returned. It is told it is strictly a number checker and not to judge the reasoning. Wrong numbers are patched, and missing data becomes an open question for the web research agent.
Some traps are well known, and I'd rather force the verdict to deal with them than hope the model notices, so a few plain rules read all the summaries first. If valuation says cheap and the charts say bearish, that's a falling knife; if quality is declining and the stock looks cheap, it may be a value trap; if governance flags fire, the verdict can't go above HOLD. Claude Opus then writes the thesis, has to address every flag, marks each statement as fact or view, and checks whether management's story survives the analysts' questions on the concall.
The historical analog agent is the one whose output can be checked against reality. It finds the most similar past setups in the same industry and size bucket and reports what happened 3, 6 and 12 months later.
The eval loop
When I change a prompt or a skill file, Gemini 3.1 Pro grades the full report from A+ to F on six things, from analytical depth to data sourcing, against a test set of stocks that stress each sector's edge cases, like SBIN for a public sector bank and VEDL for a cyclical with pledged promoters. It is told not to judge whether the numbers are right, because its training data is older than my database. The bar is an A-. I chose Claude to write and Gemini to grade on purpose, so the writer and the grader come from different vendors.
How I got here
1. A data tool, no AI
It began in March as a data tool with no AI in it at all. It fetched fund flows and shareholding, kept itself fresh on a schedule, and within a week had ten years of fundamentals, macro data, insider trades and a screener. I hit my first data bugs here (the filings parser was double-counting domestic institutions) and had to decide which source owned which number.
I could now collect the evidence. I still had to read all of it.
2. One naive agent
The obvious next thought was to let Claude read it for me. What I'd now call the naive version was one Claude agent with every data lookup as a tool, 26 of them, and one prompt that did everything: it was an analyst writing for a beginner, it had a nine-step order for pulling data, my own heuristics as bullet points (foreign funds selling while mutual funds buy is a handoff, rising pledges plus insider selling is a red flag) and a fixed report template.
It grew to 39 tools in five days. When I planned its replacement, I wanted each angle runnable on its own, a cost cap per agent and an independent check, because a single agent writing and checking its own work is like a student grading their own exam.
TODO(tarang): what did the single-agent reports actually get wrong when you read them?
3. Splitting into specialists
At the end of March I replaced it with six specialists (business, financials, ownership, valuation, risk and technical), each with its own slice of tools, its own report and a structured summary. Haiku checked their numbers, a verdict writer combined them, and the heuristics from the old prompt moved into plain rules. A sector specialist made seven.
It was getting big enough that I wanted a second opinion, so I asked Gemini to review the whole thing. Its summary was "Ferrari engine, confusing steering wheel". The financials agent alone had 33 tools, which it called tool paralysis, the prompts were so long the agent "forgets writing rules by turn 15", and I was asking for institutional-quality analysis written for a beginner, which is a contradiction.
4. Fewer tools, narrower jobs
Most of it rang true, and I acted on almost all of it within three days. The maths moved into Python. 71 tools became 16 broad ones, and the prompts shrank from 36,000 words to 7,000. Haiku's job narrowed to checking numbers only. For the contradiction, the specialists now write for a professional and a separate explainer agent annotates the finished report for a beginner. A web research agent and a news specialist joined too.
Sector knowledge took its first form here, as code: the review said to give a bank only the banking framework, so I wrote functions that injected sector text into prompts, fifteen sectors within days.
5. Skills as files, and a grader in the loop
I was already grading agents with Gemini by hand, and in April that became a program. Inspired by Karpathy's autoresearch, I set up a fixed Gemini grader, a test set with one stock for each of 14 sectors, and a manual for a Claude Code session to follow while improving the agents. The idea was that a fix for one sector goes in that sector's file and only that sector needs re-running.
I realised that only works if sector knowledge isn't code. Skills were still very new then - Anthropic had only introduced them a few months earlier - and skills picked at run time, a different set for each company depending on its sector, were newer still. So the same day I moved all fifteen sector functions into 20 Markdown files, with identical content, so the loop could edit one sector without touching Python. That was the real pivot, from one prompt that knew everything to skills that each know one thing.
Two days later I rewrote the files themselves. They were full of capitalised orders like "CRITICAL", "DO NOT" and "MUST", and I wanted them to explain the why instead, because models given good reasoning go beyond rote instructions. In the financials files the orders went from 21 to zero, and the core prompt's rules went from 26 to 12, with sector-specific ones pushed down into the sector files.
TODO(tarang): did the "explain why" rewrite measurably change grades?
From there it fanned out: on the busiest day of the project fifteen parallel changes added files for every sector, ending at 120+ files across 24 sectors. A macro agent and the historical analog agent joined in the same stretch. I added the analogs because the verdict was assigning bull, base and bear probabilities from pure reasoning, when a human fund manager would just ask "when has this setup worked before?"
6. Letting an agent run the loop
At the end of April I handed the loop itself to a Claude Code session, modelled on a project called autoagent. It reads the latest grades, edits one layer of instructions, re-runs the test stocks, and keeps or reverts the change by how many pass. It can't touch the grader, and it stops after three failed attempts in a row.
Within two days six of the agents passed all 16 test stocks; valuation plateaued at 13 or 14.
It also showed me what didn't work. Two attempts to make agents use fewer turns made the grades worse, and I found out why: the rubric was rewarding cost efficiency, and chasing it made TCS drop to an F with a fabricated citation. Agents were citing their turn budget as a reason to skip work. So cost came out of the rubric.
The grader's complaints also pointed at the data, 120+ issues of it, and some were embarrassing. The bond parser had been reading a bond's coupon (6.33%) instead of its yield (6.85%), close enough that it never looked wrong, and HDFC Bank's auditor's report had been extracted as a couple of hundred characters of an annexure header. No prompt edit could fix that.
Around then I lost Gemini access, and the project went quiet for about four weeks.
TODO(tarang): what happened in that gap?
7. Data push and clean-up
When I came back at the end of May the first few days were almost all data, with backfills to about 2,000 stocks. Cash flow had been stuck at 49 stocks because yfinance returns nothing for most Indian small caps, and switching to Screener took it to about 1,500. I also made the refresh never serve missing data.
Then I realised the grader was still sitting inside the prompts. The rubric no longer scored cost, but the prompts still said things like "12 turns or fewer is an A", and the valuation agent was guessing peers "from sector knowledge" when its budget ran low. I stripped about 47 places of grading and cost language, reframed each rule by the mistake it prevents, and raised every agent's limits.
8. A second market and six more sectors
In the last stretch I wanted it to be less India-only, so market became something the system explicitly knows about, and a US path went in over two days, using SEC filings and US macro data.
TODO(tarang): why add the US market at this point?
The sector layer got its last push from an audit: 38% of stocks had no skill file, so their agents ran on the generic instructions alone. I added six sectors (textiles, building materials, packaging, media, hospitality and logistics) with files drafted by Gemini, which took coverage from 62% to 91% of stocks and the layer to 150+ files across 30 sectors.
Looking back
When I started, I thought one good prompt would get me there. It never got better, only longer. What changed things was making every piece small enough to be graded on its own: an agent per angle, a file per sector, a checker that only checks numbers, and a grader from a different vendor. Once that existed, improving it was mostly me reading grades, and a lot of what the grades pointed at was bad data rather than a bad prompt.
The other thing that stayed with me is that whatever I graded on leaked into the work. The moment the rubric or the prompts mentioned cost, agents started cutting corners and quoting their budget as the reason. Telling them why a step matters worked far better than shouting at them in capitals.
Most of it was written with Claude Code: about 500 of the 700 commits carry its name.
TODO(tarang): have you used a thesis from this to make an actual investment decision?