The refresh budget
One cockpit, several panels, one allowance. This lesson turns that into arithmetic you can defend.
The formula
calls per refresh = sum over visible panels of (their dataNeeds, priced)
calls per day = calls per refresh x refreshes per day
The union from unit 2 is the first line. The price list from course 1 turns needs into calls, and the two rows that dominate a cockpit are /real-time at 1 per symbol and /fundamentals at 10 per request.
A worked example, using the measured prices:
| Panel | Needs | Calls |
|---|---|---|
| Watchlist | 12 live quotes | 12 |
| Screener result | 1 screen | 5 |
| Quote detail | 1 live quote (already in the 12) | 0 |
| Chart | 1 EOD series | 1 |
| Per refresh | 18 |
Refreshing every 5 minutes for 6.5 hours is 78 × 18 = 1,404 calls a day.
Note the zero. The quote panel costs nothing because the watchlist already needed that symbol, and that saving exists only because the data layer unions before fetching. Without unit 1's architecture the same cockpit costs 19, and the gap widens with every panel.
Not all panels need the same rate
A single global interval is the wasteful default. Panels have honest, different needs:
- Live quotes — as fast as the data actually changes.
- A screener result — the market has not re-screened itself in thirty seconds; minutes or on demand.
- A daily chart — once a day, plus on demand.
- A backtest result — never, unless you press run. It is a computation over history, and history did not change.
Per-panel intervals with sensible defaults, and one of those defaults is manual. Most of what looks like it needs refreshing does not.
Four rules that cost nothing
Pause when hidden. document.visibilityState and the Page Visibility API. A cockpit in a background tab should do nothing.
Pause when the market is closed. No new trades, no reason to ask.
Never refresh a backtest automatically. The rule cannot change, and the only thing that can is the adjusted series itself, which is rewritten on every dividend and split — so re-pull on a schedule you choose and re-run then, rather than letting a timer do it behind you.
Refresh on focus, not only on a timer. Coming back to the tab is the moment a person wants current data, and it is one event rather than a poll.
Show the budget, do not hide it
Put it in the interface: calls used today, the daily limit, and the projected total at the current refresh rate.
The projection is what makes it useful. "You have used 340 of 1,000" prompts nothing. "At this rate you will hit your limit at 14:20" turns an abstract number into a decision, and it is one multiplication.
The finance behind it
The account endpoint's own vocabulary trips people up before the arithmetic does: Why does the account endpoint call your daily quota a rate limit?
Try it now
Compute your own cockpit's calls per refresh by hand, then measure it against the meter over ten refreshes. If the measured number is higher, something is fetching outside the data layer — and finding that is worth more than the arithmetic.