Dados B3 › Guides › Spreadsheet
Guide · Spreadsheet
Graham number in Google Sheets, pulling EPS and book value per share from the CVM
Benjamin Graham's "Graham number" uses two figures from the balance sheet — earnings per share (EPS, LPA) and book value per share (BVPS, VPA). This guide brings both into Google Sheets straight from the API, with no hand-copied numbers, and says what the formula does not tell you.
The formula
Graham number = √(22.5 × EPS × BVPS)
22.5 is the product of Graham's two limits for a "defensive" stock: P/E up to 15 and P/B up to 1.5. The square root gives the price at which both limits meet. It is the yardstick from The Intelligent Investor for a stable, profitable company — not a price target.
Step 1 — the fetching function
In Google Sheets, open Extensions → Apps Script, clear it and paste:
function DADOSB3(ticker) {
var key = PropertiesService.getScriptProperties().getProperty('DADOSB3_CHAVE');
var options = {muteHttpExceptions: true};
if (key) options.headers = {'X-API-Key': key};
var r = UrlFetchApp.fetch('https://dadosb3.com/empresas/' + ticker + '/multiplos', options);
if (r.getResponseCode() !== 200) return 'error ' + r.getResponseCode();
var v = JSON.parse(r.getContentText()).valuation;
return [[v.lpa, v.vpa, v.preco, v.data_preco, v.ano]];
}
The key does not go in the code: under Project settings → Script properties, add DADOSB3_CHAVE with your key. Without a key only WEGE3 answers (the open sample); the free key gives 200 queries a day, no card.
Step 2 — the sheet
Column A holds tickers (WEGE3, ITUB4…). In B2, =DADOSB3(A2) — it fills five columns: EPS, BVPS, price, price date and statement year. In G2, the Graham number:
=IF(AND(B2>0,C2>0),SQRT(22.5*B2*C2),"n/a")
(With a Portuguese-locale sheet: =SE(E(B2>0; C2>0); RAIZ(22,5*B2*C2); "não se aplica").)
Three caveats
- Losses are out. With negative EPS the root does not exist — not a sheet error: the formula does not apply to a company that does not make money. Hence the
IF. - EPS is from the last annual statement. The "year" column says which. A year with a one-off gain inflates EPS and the Graham number with it; check the series on the company page before trusting a single year.
- Every call spends a query. Google recalculates custom functions when the sheet opens. With 50 tickers, one opening spends 50 of the 200 daily free queries. For a long list, paste as values after updating.
Where each number comes from
EPS and BVPS come from the last annual statement filed with the CVM; price is the last session's close (B3 daily file). The calculation of each is open in the methodology. If a number looks wrong, the company page shows the source account — and a reported error becomes a public correction at /o-que-erramos.
Sources: CVM (open data, ODbL) and B3 (COTAHIST). Not affiliated with B3 or the CVM. Not investment advice.
Numbers on this page are live. Data version 2026-09-14-etfs · page generated 2026-09-23 00:40 UTC. If this does not match /saude, you are reading a cached copy.