Contents Lesson 2 of 18

10 min read · practitioner

Read the universe, and find out what is in it

By the end of this lesson you will have a Universe section in PLAN.md with the instrument types of one exchange, counted from a single request you approved, and one sentence naming which types your screens include and why.

"All US stocks" is a phrase that feels precise and is not. This lesson makes you look at what is actually behind it, because every screen you ever write inherits whatever you got wrong here.

Ask for the list

One call returns every instrument on an exchange:

/exchange-symbol-list/US

Run on 2026-08-25 it returned 51,215 rows. Here is the first one, exactly as it came back:

{"Code": "^MGTN", "Name": "CBOE MAGNIFICENT 10 INDEX", "Country": "USA",
 "Exchange": "US", "Currency": "USD", "Type": "INDEX", "Isin": null}

Read it twice. The first row of "all US stocks" is not a stock. It is an index, and an index has no shares, no earnings and no market cap. Screen it on a P/E and you will get either nothing or nonsense.

What 51,215 is actually made of

Counted from the same response:

Type Count
FUND 20,884
Common Stock 18,012
ETF 5,801
Mutual Fund 5,154
Preferred Stock 699
Warrant 355
Unit 166
Notes 138
INDEX and a few smaller types 6

Barely a third of "the US market" is common stock. The largest single group is funds. If your screen quietly includes them, your "cheapest companies" list contains things that are not companies, and you will not notice, because they have codes and names and prices like everything else.

This is the single most common way a screener produces confidently wrong output. Not a bug in the code — a universe nobody looked at.

Filter the universe before you filter the fundamentals

Two decisions, made explicitly and written into the plan:

const TRADEABLE = new Set(["Common Stock"]);   // your call, stated

Whether preferred stock belongs is a real question with a real answer for your purposes. What is not acceptable is not having decided. Write the choice down; your future self will want to know whether the absence of ETFs was a decision or an accident.

Do not fetch 51,215 rows to show 40

Pulling the whole list into your app and filtering it in JavaScript is the instinct, and it is wrong twice over: it is a large response for no reason, and the fields you want to filter on are not in it. Notice what the row above does not contain — no price, no market cap, no sector, no earnings. It is an index of what exists, not data about it.

Filtering happens server-side at the /screener endpoint, which is the next lesson. Fetch the symbol list when you need to know what exists; screen when you need to know which ones match.

Exchanges are not countries

/exchange-symbol-list/{CODE} takes an exchange code, and the list of them comes from /exchanges-list. US is a convenience covering the American venues; LSE, XETRA and the rest are individual exchanges. A screen across two exchanges is a screen across two currencies and two sets of accounting conventions, and the habit of doubting a number that looks right is the subject of Reviewing for numbers that lie.

The finance behind it

An index in a stock screen is the same mistake from the data side, and the API domain walks through why the endpoint answers at all: Why does an index have no financial statements?

Try it now

Pull the symbol list for the exchange you care about and count it by Type yourself. Then answer one question in your PLAN.md: which types are in your universe, and why. If your answer is "stocks", go back and decide about preferred stock, ETFs and units — because the API will not decide for you and something will end up in your results.

The prompt

This needs live data once: a fixture would only count itself. It needs your own free key from your EODHD account: the shared demo key answers 403 Forbidden on the symbol list, the screener, SPY and delisted tickers. Put your key in .env.local, remove the EODHD_MOCK line, run npm run dev in one terminal and the agent in another, and paste:

I want to know what the US symbol list is made of. Before you fetch
anything, tell me the request you will make and its price from
estimateCalls() in src/lib/cost.ts, and wait for my yes. Then fetch
exchange-symbol-list/US once, through the dev server's proxy at
localhost:3000/api/proxy/, count the rows by Type without saving the
response in the repository, and print the counts largest first with
the total. Change no code. Add a "Universe" section to PLAN.md with
the date, the table, and a line "In my universe:" for me to finish.
If the request answers 403 or 402, make no other request and write
the section from these counts instead, saying they are a lesson's
from 2026-08-25 and not mine: FUND 20,884; Common Stock 18,012; ETF
5,801; Mutual Fund 5,154; Preferred Stock 699; Warrant 355; Unit
166; Notes 138; INDEX and a few smaller types 6; total 51,215.

A good answer prices the request at one call and stops. After your yes: one request, a table of eight or more types, and one changed file, PLAN.md. If the request answers 403 or 402, your key's plan does not cover the symbol list, and the agent writes the section from the lesson's counts, marked as such.

Check it yourself

  1. The price came before the request, and it was one call.
  2. Read the meter with curl -s localhost:3000/api/usage before and, a few seconds after, again: used rose by one. On the shared demo key the counter moves with other people's requests, so skip this check there.
  3. The counts in the table add up to the total the agent printed.
  4. Common Stock is one row of that table, not most of it.
  5. git status shows PLAN.md modified and no new data file.
Compare with ours
## Universe
US symbol list on 2026-08-25, one call: 51,215 rows, 18,012 Common Stock.
In my universe: Common Stock.
Out: Preferred Stock (priced on its dividend, not on earnings);
FUND, ETF, Mutual Fund (they hold companies, they are not one);
Warrant, Unit, Notes, INDEX (no earnings to screen on).

The full state at the end of this unit is on the starter's branch ref/build-a-screener/u1.

Checkpoint

git status   # PLAN.md, and no data file
git add PLAN.md
git commit -m "Universe: count the US list by type, keep common stock, say why"

Then answer this lesson's questions.