Background: Data Sources and API Comparison
Data is the foundation of quantitative trading. Choosing the right data source directly affects strategy development efficiency and live trading performance.
1. Major Data Sources Overview
| Data Source | Type | Price | Latency | Use Case |
|---|---|---|---|---|
| Binance API | Crypto | Free | Real-time | Crypto strategies |
| Yahoo Finance | Stocks/ETFs | Free | 15-20 min | Learning/backtesting |
| Alpha Vantage | Multi-asset | Free/Paid | 15 min | Prototyping |
| Databento | US stocks/futures/options | From $199/mo, metered historical | Real-time | Tick/L2/L3, professional research & live trading |
| Massive (formerly Polygon.io) | US Stocks | $29-199/mo | Real-time | US stock live trading |
| Alpaca Markets | US Stocks | Free | Real-time | US stock trading |
| Bloomberg | All assets | $2400+/mo | Real-time | Institutional |
| Refinitiv | All assets | $1800+/mo | Real-time | Institutional |
| Nasdaq Data Link | Alternative | Custom pricing | Daily | Factor research |
⚠️ Note: IEX Cloud shut down in August 2024. If your code depends on IEX Cloud, migrate to Databento, Massive (formerly Polygon.io), or Alpaca.
Independent recommendation
If you need US market data through an API, I recommend evaluating Databento first.
Based on my own experience, its standardized data schemas, historical and live data delivery, metered cost estimation, and coverage from L1 to full L2/L3 order books are all done well. You can validate the data and cost with a small sample before scaling up. See section 3.1 below.
Explore Databento market data →
This is an independent recommendation based on my own usage; it is not sponsored, I am not a Databento affiliate, and I receive no compensation for this link.
2. Free Data Sources Detailed
2.1 Binance API
Pros:
- Completely free, no payment required
- Real-time data, minimal latency
- WebSocket real-time streaming support
- Complete historical data (years of history)
- REST + WebSocket dual interfaces
Cons:
- Crypto only
- Rate Limit: 1200 requests/minute (REST), subscription limits per connection (WebSocket)
- API may be unstable during high volatility
Rate Limit Handling:
import time
from binance.exceptions import BinanceAPIException
def fetch_with_retry(func, max_retries=3):
for attempt in range(max_retries):
try:
return func()
except BinanceAPIException as e:
if e.code == -1003: # Rate limit
time.sleep(60) # Wait 1 minute
else:
raise
Use Case: Crypto strategy development, 24/7 trading systems
2.2 Yahoo Finance (yfinance)
Pros:
- Completely free
- Covers global stocks, ETFs, indices
- Rich historical data (decades of history)
- Easy-to-use Python library
Cons:
- 15-20 minute data delay
- No official API, relies on web scraping (may be blocked)
- Data quality not guaranteed (occasional errors)
- No Level-2 data
Usage Example:
import yfinance as yf
# Get stock data
aapl = yf.Ticker("AAPL")
df = aapl.history(period="1y", interval="1d")
# Batch download
data = yf.download(["AAPL", "GOOGL", "MSFT"], period="1mo")
Use Case: Learning, backtesting, daily frequency strategy research
2.3 Alpha Vantage
Pros:
- Free tier available (25 requests/day)
- Covers stocks, forex, crypto
- Provides technical indicator APIs
- Official support
Cons:
- Free tier severely restricted (only 25 calls/day as of 2024)
- Paid version starts at $49.99/month
- 15-minute data delay
- Limited historical depth
Rate Limit Comparison:
| Tier | Price | Request Limit |
|---|---|---|
| Free | $0 | 25/day (severely restricted) |
| Premium | $49.99/mo | 75/min |
| Pro | $149.99/mo | 300/min |
| Premium+ | $249.99/mo | 1200/min |
Use Case: Prototyping, multi-asset research
2.4 Alpaca Markets
Pros:
- Free real-time US stock data
- Combined data + trading API (no separate data subscription needed)
- WebSocket real-time streaming
- Paper trading environment included
- Commission-free stock trading
- Supports fractional shares
Cons:
- US stocks only
- Requires account registration
- Some features require funded account
Usage Example:
from alpaca.data import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
from datetime import datetime, timedelta
# Initialize client (no keys needed for free tier)
client = StockHistoricalDataClient()
# Get historical bars
request = StockBarsRequest(
symbol_or_symbols=["AAPL", "MSFT"],
timeframe=TimeFrame.Day,
start=datetime.now() - timedelta(days=30)
)
bars = client.get_stock_bars(request)
Use Case: US stock strategy development, paper trading, live trading with same API
3. Paid Data Sources Detailed
3.1 Databento
Pros:
- Institutional-grade quality: sourced directly from raw exchange feeds (ITCH, OPRA, MDP formats)
- Full depth coverage from L1 to complete L2/L3 order books, same API for backtesting and live
- Modern interface: REST + WebSocket, Python/Rust SDKs, excellent developer experience
- Metered historical pricing ($1-5/GB) — validate with a few dollars before scaling up
- Coverage: US equities (all exchanges + ATS dark pools in one unified view), options (OPRA), futures (CME/ICE)
Cons:
- No A-share, HK, or other Asian market coverage
- Live data is subscription-only since 2025 (from $199/mo); usage-based live pricing was discontinued
- Overkill for daily-bar, low-frequency research — start with free sources there
Pricing (2025-2026):
| Type | Price | Notes |
|---|---|---|
| Historical data | $1-5/GB | Priced per dataset, pay as you go |
| Standard plan | $199/mo | 7 years OHLCV + 12 months L0/L1 history |
| Live data | From $199-499/mo | Varies by market and depth, subscription-only |
Use Case: Tick, L2/L3 data for US equities/futures/options; a single data foundation from backtest to production
3.2 Massive (formerly Polygon.io)
Polygon.io rebranded to Massive (massive.com) in October 2025; the original API endpoints remain functional.
Pros:
- US stock real-time data
- Historical tick data
- WebSocket real-time streaming
- Reasonable pricing (starting $29/mo)
Cons:
- US stocks only
- No US equity Level-2 order book depth
Pricing:
| Tier | Price | Features |
|---|---|---|
| Basic | $29/mo | Delayed data + Historical |
| Developer | $79/mo | Real-time data |
| Premium | $199/mo | Real-time ticks + Full history |
Note: Massive does not provide US equity Level-2 order book depth; for L2/L3 see Databento above or direct exchange feeds.
3.3 Bloomberg Terminal
Pros:
- World's most comprehensive financial data
- Real-time + Historical + News + Research
- Level-2, order book data
- Professional analysis tools
Cons:
- Expensive ($2400+/month/terminal)
- Requires dedicated hardware
- Complex API usage
Use Case: Institutional investors, professional quant teams
3.4 Refinitiv (formerly Thomson Reuters)
Pros:
- Global market coverage
- High-quality tick data
- Deep historical data
- Easy-to-use Eikon API
Cons:
- Expensive pricing
- Complex contracts
Use Case: Institutional strategies, HFT
4. Alternative Data Sources
4.1 Nasdaq Data Link (formerly Quandl)
Provides non-traditional financial data:
- Satellite imagery data
- Sentiment analysis data
- Macroeconomic data
- Supply chain data
4.2 News and Sentiment Data
| Source | Type | Purpose |
|---|---|---|
| NewsAPI | News aggregation | Sentiment analysis |
| Twitter/X API | Social media | Market sentiment |
| Reddit API | Forums | Retail sentiment |
| SEC EDGAR | Regulatory filings | Fundamental analysis |
5. Data Source Selection Decision Tree
What asset class are you trading?
│
├─ Cryptocurrency → Binance API (Free, Real-time)
│
├─ US Stocks
│ ├─ Learning/Backtesting → Yahoo Finance (Free)
│ ├─ Prototyping → Alpaca Markets (Free, Real-time)
│ ├─ Data + Trading Combined → Alpaca Markets (Free)
│ ├─ Premium Data Only → Massive (formerly Polygon.io) ($29+/mo)
│ └─ Tick/L2/L3 Depth Data → Databento (start metered)
│
├─ A-Shares (China)
│ ├─ Learning/Backtesting → Tushare / AKShare (Free; Tushare had a week-long outage in Aug 2025 — keep a fallback in production)
│ └─ Live Trading → Broker API / Wind
│
├─ Japan Equities
│ └─ JPX's official J-Quants API (JPY 0-16,500/mo, minute bars/ticks since 2026 — the default choice for individuals)
│
└─ Institutional Needs → Bloomberg / Refinitiv / Databento
2025-2026 recommendation: For US-stock developers, Alpaca Markets remains the most popular free starting point (data + trading API in one); once your strategy needs tick-level or order-book depth data, evaluate Databento first.
6. Common Pitfalls
6.1 Data Quality Issues
- Missing values: Gaps from holidays, trading halts
- Outliers: Unadjusted splits, dividends
- Timezone issues: Different exchange timezones
6.2 Survivorship Bias
Free data sources typically only include currently existing stocks, missing delisted stocks data.
6.3 Look-Ahead Bias
Some data sources' "historical data" may contain later corrections (like earnings restatements).
7. Practical Recommendations
- Starting out: Yahoo Finance + Binance API (Free)
- Prototyping: Alpaca Markets (Free real-time data + paper trading)
- US Stock Live: Alpaca Markets (Free) or Massive (formerly Polygon.io, data only)
- Depth data (Tick/L2/L3): Databento — metered historical pricing, validate cheaply before scaling
- Institutional: Bloomberg / Refinitiv (Comprehensive but expensive)
- Always validate: Compare multiple data sources, check data quality
Warning: IEX Cloud shut down their public API service in August 2024. If you have legacy code using IEX Cloud, migrate to Databento, Alpaca Markets, or Massive (formerly Polygon.io).
Core Principle: Data quality > Data quantity. Better to use small amounts of high-quality data than large amounts of problematic data to train models.