中
Back to notes

Starting at zero cost: free market data and free model quotas

Part 2 of the quant series: CCXT and yfinance carry the free data layer for crypto and US stocks, while tiered routing across free LLM quotas with failover carries the compute — both sides of the system, zero budget.

[Part 1](/blog/quant-not-a-gambling-machine) set the positioning: self-use first, dual engines, decision memory. This post answers a cruder question: where does the money come from? The answer: at validation stage, almost nowhere. Free market data plus free model quotas, orchestrated properly, run the whole system.

Data layer: free, but abstract it

On crypto the workhorse is CCXT: one library unifying 100+ exchanges (Binance, Coinbase, Kraken, OKX…) over free REST and WebSocket — candles, order books, trades, no paid keys. Market-cap rankings and the dynamic universe come from CoinGecko / CoinCap free tiers.

On US stocks it is yfinance: historical candles (minute to daily), financials, options chains, fundamentals — free and stable enough to be the de facto standard for US-equity backtesting. Alpha Vantage, Polygon, and FMP free tiers fill in the text side: news and macro prints (FED rate, CPI, unemployment).

The one engineering decision that matters: a BaseDataProvider abstraction. Unified `fetch_klines()` / `fetch_financials()` interfaces, one implementation each for AKShare, yfinance, CCXT, switchable from the console in one click. Sources will rotate; the interface should not. This pays for itself the first time a source breaks.

Compute layer: freeloading, methodically

On the model side the pattern is tiered routing with failover. Tasks split into classes, each with its own pool:

Lightweight preprocessing (news summaries, first-pass sentiment) and synthesis (Market Context) go to the free general-model pool — Zhipu GLM, NVIDIA NIM, Groq, SiliconFlow, Gemini free tier; whoever has quota, serves. Dense decisions (structured signal output, memory-case matching, factor evaluation) go to the self-hosted decision model on a free GPU instance — no rate limits, quant logic only.

Three orchestration pieces: a fallback chain — call priority defined in the router; a 429 or exhausted quota silently fails over to the next provider. Token discipline — never send full context: extract key sentences locally, pass the API a refined prompt under 500 characters. Cache and async — non-realtime analyses (macro reads) cache in Redis for 1–4 hours; every model call is a background job so the UI never waits.

TASKS Lightweight preprocessing news summary · sentiment Synthesis Market Context Dense decisions signals · factor eval Unified LLMClient OpenAI format base_url + api_key POOLS Free general pool GLM · NIM · Groq SiliconFlow · Gemini 429 → silent failover Self-hosted model free GPU instance no rate limits Redis cache 1–4 hours every model call is a background job — the UI never waits
Three task classes, three pools, one interface — whose key it is does not matter.

All calls go through one `LLMClient` speaking the OpenAI API format — local deployments (vLLM / Ollama) and commercial clouds differ only by `base_url` and `api_key`. Same philosophy as AeoX's BYOK: unify the interface; whose key it is does not matter.

What factors can free data mine

No expensive Level-2 feeds, no paid research — the high-value factors concentrate in four families. Price-volume: momentum, volatility, turnover anomalies, Bollinger squeeze — computable from daily or 15-minute candles, milliseconds in local pandas, zero cost. Fundamental: EP/BP valuation, free-cash-flow yield, revenue surprises — quarterly reports parsed with an LLM reading the footnotes. Sentiment: news scored −1 to 1, the scalar fed straight into the strategy; announcements scraped free and cleaned by the local model. LLM-driven factor mining: borrow the RD-Agent / Qlib idea — hand the model the base column names and let it write its own Pandas expressions (say, `rank(close / delay(close, 5)) * std(volume, 20)`), auto-compile, auto-backtest, keep factors by IC. Factors stop being hand-enumerated; they become generate-and-filter.

Three teachers from open source

No wheel reinvention, no direct adoption either: qlib (Microsoft) for AI factor mining and RD-Agent automation; freqtrade for mature event-driven architecture; QuantMuse for the FastAPI + frontend shape. Steal the ideas, write the skeleton.

[Part 3](/blog/quant-roadmap-and-console) closes the series: the four-phase roadmap, strategy versioning, and why a beautiful console is not vanity — it is explainability itself.

Comments

Comments are powered by GitHub Discussions. Sign in with GitHub to leave one.

More in this category

EngineeringOct 12, 20266 min

Built for my own use first: the quant system I am building

EngineeringOct 12, 20266 min

Roadmap and console: four phases, micro-capital, ship it

← PreviousBuilt for my own use first: the quant system I am buildingNext →Roadmap and console: four phases, micro-capital, ship it