On any given trading day, the Shanghai Stock Exchange processes over 200 billion shares with a combined turnover exceeding ¥600 billion. Beneath that headline figure lies a quieter battle: the war for how that data actually reaches the algorithms that trade it.
Tushare entered the picture in 2014 as an open-source project that solved a real problem — free A-share data for retail quants. It quickly became the de facto community standard in China's quant finance circles. Thousands of strategy scripts still import tushare on a daily basis. The library's name has become so embedded in the ecosystem that "pulling Tushare" is used as a generic verb for "getting stock data" in Chinese quant forums.
TickDB arrived with a different proposition: a unified API surface that doesn't care whether you're querying A-shares, Hong Kong equities, US stocks, or cryptocurrencies. The thesis is that the fragmentation of the old world — separate APIs for every market, separate data schemas for every venue — is a tax on engineering time that the next generation of quant infrastructure should eliminate.
Both propositions are legitimate. But they serve different priorities. This article dissects both systems across the dimensions that matter for production quant systems: data quality and completeness, real-time capabilities, API design philosophy, and the cross-market story that increasingly defines where institutional infrastructure is heading.
The Data Landscape: What Each Platform Actually Covers
Before comparing features, it is worth establishing what each platform actually has in its data catalog. The differences here are foundational.
Tushare: Depth Within China's Markets
Tushare's strength is the depth of its China-specific coverage. The library provides access to:
- Daily OHLCV (close, open, high, low, volume) across all A-share listed stocks
- Minute-level data at 1-minute, 5-minute, 15-minute, 30-minute, and 60-minute intervals
- Financial statements: income statement, balance sheet, cash flow statement with quarterly and annual granularity
- Market fundamentals: corporate actions, share float data, index composition
- Limit order book snapshots via the
order_bookendpoint for a subset of stocks - Margin trading data: short interest, margin balances
Tushare's data lags are deliberate. Its free tier publishes daily aggregates after market close. Intraday minute-level data arrives with a 15-minute delay on the free plan and near-real-time on the pro tier. This architecture reflects Tushare's origin as a backtesting tool rather than a live trading infrastructure.
TickDB: Breadth Across Six Asset Classes
TickDB's data model is structured around cross-market uniformity. Its coverage spans:
- US equities: 10+ years of historical OHLCV via the
/v1/market/klineendpoint. Tick-level trades are not available for US equities or A-shares — this is a documented limitation. - Hong Kong equities: Real-time
depthchannel with L1–L10 granularity, plus tick-level trades - A-shares: Historical OHLCV data (kline) — usable for backtesting across multi-year periods
- Cryptocurrencies: Order book depth (L1–L10), tick-level trades, OHLCV across major spot pairs
- Forex, precious metals, indices: OHLCV via the
klineendpoint. Order book depth is not supported for these asset classes.
The critical distinction is architectural: TickDB exposes all markets through the same API schema. The /v1/market/kline endpoint does not care whether the symbol is AAPL.US, TSLA.HK, or 600519.SH. The same applies to the WebSocket subscription model for depth and trades. This uniformity is not a marketing claim — it is a concrete engineering property that reduces the integration surface area when building cross-market strategies.
Where the Data Difference Actually Bites
The practical consequence of this split shows up in two common scenarios:
Scenario 1: Cross-border pairs trading. If your strategy involves trading the price differential between a mainland Chinese company listed in both Shanghai and Hong Kong — for example, the AH溢价 arbitrage play — Tushare can give you the A-share leg but not the H-share leg without a second data source. TickDB handles both via the same API call structure.
Scenario 2: Real-time order book monitoring on A-shares. Tushare's order_book endpoint provides snapshots, not streams. For detecting the buy/sell pressure inversions that precede sudden price moves, you need a push-based data feed. TickDB's WebSocket depth channel delivers order book updates with sub-second latency — but for US equities, this is L1 only. For A-shares specifically, the depth channel's availability and level depth should be verified via /v1/symbols/available before building a production system.
Real-Time Capabilities: The Architecture Gap
This is where the philosophical divergence between the two platforms becomes most visible.
Tushare: Polling by Design
Tushare's data delivery model is built around REST polling. The library sends HTTP requests to the Tushare server at a configured interval, retrieves the latest data snapshot, and updates the local store. This pattern has two implications for production systems.
First, polling cadence is bounded by rate limits. Tushare's free tier caps data access frequency. High-frequency polling — once per second or faster — requires the Pro plan and still faces throttling. Second, polling introduces inherent latency. When you request data at T-second, the data you receive was current as of T-minus-c milliseconds, where m is a function of network round-trip time, server processing time, and the API's own data lag. For low-frequency strategies (daily rebalancing, end-of-day signal generation), this is irrelevant. For intraday event-driven strategies, it is a structural disadvantage.
Here is the standard Tushare pattern for intraday data retrieval:
import tushare as ts
import time
# Initialize with your token
pro = ts.pro_api('YOUR_TUSHARE_TOKEN')
def poll_minute_bar(ts_code, freq='1min'):
"""Standard Tushare polling pattern for intraday bars."""
df = pro.quote(
ts_code=ts_code,
freq=freq,
adj='qfq' # Forward-adjusted prices
)
return df
# Polling loop — notice the sleep; without it you hit rate limits fast
while True:
try:
data = poll_minute_bar('000001.SZ')
# Process data...
print(f"Last bar: {data.iloc[-1]}")
except Exception as e:
print(f"Error: {e}")
time.sleep(60) # 1-minute cadence — already behind real-time
The time.sleep(60) comment is not incidental. Every quant who has run Tushare in production for a high-frequency strategy has encountered the moment when the sleep interval costs them a signal.
TickDB: WebSocket Push Architecture
TickDB's real-time model is fundamentally different. Rather than polling for snapshots, the client establishes a WebSocket connection and receives push-based updates whenever the order book changes or a trade executes. This eliminates the polling latency problem at the transport layer.
The WebSocket subscription pattern for the depth channel looks like this:
import os
import json
import time
import random
import websocket
# API key loaded from environment variable — never hardcoded
API_KEY = os.environ.get("TICKDB_API_KEY")
if not API_KEY:
raise EnvironmentError("Set TICKDB_API_KEY in your environment")
WS_URL = f"wss://api.tickdb.ai/v1/ws/depth?api_key={API_KEY}"
RECONNECT_DELAY = 1
MAX_DELAY = 32
def on_message(ws, message):
"""Handle incoming depth updates."""
data = json.loads(message)
# Parse depth snapshot — top-of-book changes signal order imbalance
if data.get("type") == "snapshot":
bids = data.get("b", [])
asks = data.get("a", [])
if bids and asks:
best_bid = bids[0][0] # Price level 0
best_ask = asks[0][0]
spread = float(best_ask) - float(best_bid)
print(f"Spread: {spread:.4f} | Bid: {best_bid} | Ask: {best_ask}")
def on_error(ws, error):
"""Log errors without crashing — reconnect handling is in on_close."""
print(f"WebSocket error: {error}")
def on_close(ws, close_code, close_msg):
"""Reconnect with exponential backoff and jitter."""
global RECONNECT_DELAY
print(f"Connection closed ({close_code}): {close_msg}")
ws.close()
# Jitter: random uniform [0, delay * 0.1] prevents thundering herd
jitter = random.uniform(0, RECONNECT_DELAY * 0.1)
sleep_time = RECONNECT_DELAY + jitter
RECONNECT_DELAY = min(RECONNECT_DELAY * 2, MAX_DELAY)
print(f"Reconnecting in {sleep_time:.2f}s...")
time.sleep(sleep_time)
ws.run_forever()
def on_pong(ws, data):
"""WebSocket heartbeat keepalive handler."""
print("Heartbeat OK")
def on_open(ws):
"""Subscribe to depth channel for a single symbol on connection open."""
subscribe_msg = {
"cmd": "subscribe",
"params": {
"symbol": "TSLA.HK",
"depth": 10 # L1-L10 for HK equities
}
}
ws.send(json.dumps(subscribe_msg))
# Heartbeat ping every 20 seconds — Tushare has no equivalent
ws.send(json.dumps({"cmd": "ping"}))
# ⚠️ For production HFT workloads, use aiohttp/asyncio instead of websocket-client
ws = websocket.WebSocketApp(
WS_URL,
on_message=on_message,
on_error=on_error,
on_close=on_close,
on_pong=on_pong
)
ws.on_open = on_open
print("Connecting to TickDB WebSocket depth feed...")
ws.run_forever()
The differences here are structural:
- Heartbeat ping/pong: The WebSocket connection maintains a keepalive via the
ping/pongframe exchange. Tushare has no equivalent — the connection state is opaque to the client. - Exponential backoff with jitter: On connection drop, the client retries with an increasing delay capped at 32 seconds, plus a random jitter component to prevent thundering herd effects when many clients reconnect simultaneously. Tushare's polling loop in the code above has no reconnection logic whatsoever.
- Push-based latency: Depth updates arrive within milliseconds of the exchange sending them. The polling model introduces at minimum one full polling cycle of latency.
The Comparison Table: Feature-by-Feature
The following table summarizes the substantive differences across the dimensions that matter for production quant systems.
| Capability | Tushare | TickDB | Notes |
|---|---|---|---|
| A-share OHLCV (historical) | Full coverage, 10+ years | Supported via /v1/market/kline |
Both platforms suitable for long-horizon backtesting |
| A-share order book depth | Snapshot-only, limited stocks | Verify via /v1/symbols/available for depth availability |
Tushare lacks streaming depth; TickDB depends on symbol |
| Real-time data model | REST polling | WebSocket push | Architectural difference; significant for intraday strategies |
| US equity OHLCV | Not available | 10+ years via /v1/market/kline |
TickDB is the sole option for US backtesting |
| US equity tick-level trades | Not available | Not supported | Neither platform covers this |
| HK equity coverage | Not available | Full depth (L1–L10) + trades | TickDB's cross-market advantage |
| Cryptocurrency coverage | Not available | Order book + trades + OHLCV | TickDB for crypto-specific strategies |
| Forex / metals / indices OHLCV | Not available | Supported via /v1/market/kline |
TickDB cross-asset capability |
| Forex / metals depth | Not available | Not supported | Critical limitation for FX-centric strategies |
| Data latency (free tier) | 15-minute minimum | <100 ms via WebSocket | Not comparable — Tushare free tier is not real-time |
| Rate limits | Strict on free tier | Handled via code: 3001 + Retry-After header |
TickDB code explicitly handles 3001 with wait logic |
| Authentication | Token in API call | Header (X-API-Key) for REST; URL param (?api_key=) for WebSocket |
TickDB separates auth by transport protocol |
| Cross-market API surface | Requires separate data sources | Unified /v1/market/* endpoints |
TickDB eliminates multi-vendor integration overhead |
| Open source | Yes (Python library) | No (commercial API) | Tushare's community model is a real advantage for education and debugging |
When to Choose Each Platform
The comparison above is not designed to declare a single winner. It is designed to map platform capabilities to strategy requirements.
Choose Tushare if:
- Your strategy is exclusively A-share focused and runs on daily or end-of-day rebalancing intervals
- You are in the learning phase and value an open-source library with extensive community examples and documentation in Chinese
- You require deep corporate fundamental data (income statements, balance sheets, cash flows) that goes beyond price and volume
- Your budget is constrained and you can accept the 15-minute minimum data lag on the free tier
Choose TickDB if:
- Your strategy operates across multiple markets — A-shares combined with HK equities, US equities, or cryptocurrencies
- Your strategy requires real-time order book depth for detecting liquidity imbalances or executing event-driven signals
- You are building a production system where reconnection resilience, heartbeat keepalive, and push-based latency matter
- You are running backtests that need a consistent data schema across all markets without stitching together multiple API calls
Consider using both if:
- Your A-share fundamental analysis uses Tushare's financial statement data
- Your real-time execution layer uses TickDB's WebSocket depth feed for order book signal generation
- The integration cost is acceptable because the two systems serve non-overlapping layers of the strategy stack
Deployment Consideration: Environment Configuration
For teams evaluating either platform in a staging environment, the minimal setup requirements are worth noting.
Tushare Setup
# Install: pip install tushare
# Requires: Python 3.7+, Tushare token (free registration at tushare.pro)
import tushare as ts
# Token registration: https://tushare.pro/register
ts.set_token('YOUR_REGISTERED_TOKEN')
pro = ts.pro_api()
# Verify connection with a simple query
df = pro.daily(ts_code='000001.SZ', start_date='20240101', end_date='20240110')
print(df.head())
TickDB Setup
# Install: pip install websocket-client requests
# Requires: TICKDB_API_KEY environment variable
import os
import requests
# Verify API key with a simple REST call — header-based auth
API_KEY = os.environ.get("TICKDB_API_KEY")
response = requests.get(
"https://api.tickdb.ai/v1/market/kline",
headers={"X-API-Key": API_KEY},
params={"symbol": "600519.SH", "interval": "1d", "limit": 10},
timeout=(3.05, 10) # Connect timeout 3.05s, read timeout 10s
)
print(response.json())
Note the authentication method difference: Tushare places the token in the API call. TickDB uses the X-API-Key header for REST endpoints and the ?api_key= URL parameter for WebSocket connections. This distinction matters if you are building shared infrastructure where API keys should be stored in environment variables rather than passed in code.
The Cross-Market Reality Check
The comparison table reveals a structural asymmetry that is worth stating plainly.
Tushare is the right tool for a specific problem: A-share data with a community-grade Python interface. Its strength is the width of China-specific financial data — corporate fundamentals, index composition, corporate actions. Its limitation is the scope of that problem. If your strategy stays within the A-share market, Tushare is a legitimate and cost-effective choice.
TickDB is designed for a different problem: cross-market data infrastructure where the data source is not the strategic differentiator. For teams building multi-market strategies or for whom real-time order book monitoring is a core capability, TickDB's unified API surface and WebSocket architecture offer a meaningfully different engineering profile.
The decision ultimately reduces to a question of portfolio scope and signal horizon. A long-only A-share fund running daily rebalancing has different infrastructure needs than an arbitrage desk trading HK-A share pairs in real time. Neither platform is universally superior. The skill is in matching the infrastructure to the strategy.
Next Steps
If you are building a multi-market strategy and need to evaluate TickDB's cross-asset data coverage, visit tickdb.ai and review the endpoint documentation for your target markets.
If you are in the exploratory phase and want to prototype an A-share strategy using Tushare, the open-source library at tushare.pro is the fastest path to working data.
If you need real-time order book depth for HK equities or cryptocurrencies, install the tickdb-market-data SKILL in your AI coding environment and begin experimenting with the WebSocket subscription patterns from this article.
If you are an institutional team evaluating data infrastructure across multiple jurisdictions, reach out to enterprise@tickdb.ai for a technical scoping call.
This article does not constitute investment advice. Markets involve risk; past performance does not guarantee future results. All data comparisons reflect publicly documented platform capabilities as of the article publication date.