rqdatac - Ricequant Data SDK
raw JSON → 3.5.1.1 verified Fri May 01 auth: no python
Ricequant Data SDK (rqdatac) provides programmatic access to Chinese financial market data, including stocks, futures, options, and index data. It offers both snapshot and historical data retrieval with a pandas-friendly API. Current version: 3.5.1.1. The library is actively maintained by Ricequant and releases follow a monthly cadence.
pip install rqdatac Common errors
error rqdatac.exceptions.AuthenticationError: invalid token ↓
cause Token is expired, malformed, or missing. Also occurs if init() is not called.
fix
Make sure you call rq.init('valid_token_here') with a token obtained from your Ricequant account. Token must be a string.
error KeyError: 'order_book_id' ↓
cause Code refers to column 'order_book_id' but older version returns 'code' or 'symbol'.
fix
Check your rqdatac version: if <3.0, use 'code' instead. If >=3.0, use 'order_book_id'. Alternatively, use .get('order_book_id', None) or update to latest version.
error Empty DataFrame returned when calling get_price ↓
cause Instrument code is missing exchange suffix or incorrect date range.
fix
Ensure stock codes include exchange suffix (e.g., '000001.XSHE'). Also verify that the date range is within available data.
Warnings
breaking Token format changed in v3.0 - you must now pass a full API token (not user/password). Old init patterns no longer work. ↓
fix Use rq.init('your_full_token') - obtain token from Ricequant website.
gotcha Stock codes on Chinese exchanges require exchange suffix: .XSHE for Shenzhen, .XSHG for Shanghai. Omitting suffix returns empty data. ↓
fix Always append the correct exchange suffix (e.g., '000001.XSHE', '600000.XSHG').
deprecated The 'rqdatac.all_instruments' function now returns a DataFrame with different column names (e.g., 'order_book_id' instead of 'code'). Old code referencing 'code' or 'symbol' will break. ↓
fix Check column names with .columns and refer to 'order_book_id' for instrument identifiers.
gotcha get_price() expects start_date and end_date as strings in 'YYYY-MM-DD' format. Python date objects or other formats may cause unexpected errors. ↓
fix Always pass dates as strings: start_date='2024-01-01'.
Imports
- init wrong
from rqdatac import rqdataccorrectimport rqdatac as rq - all_instruments wrong
from rqdatac.rqdatac import all_instrumentscorrectfrom rqdatac import all_instruments - get_price wrong
import rqdatac.get_pricecorrectfrom rqdatac import get_price
Quickstart
import rqdatac as rq
# Initialize with your token (get from https://www.ricequant.com)
rq.init('your_token_here')
# List all instruments
instruments = rq.all_instruments()
print(instruments.head())
# Get historical price data for a stock
prices = rq.get_price('000001.XSHE', start_date='2024-01-01', end_date='2024-06-01', fields=['close'])
print(prices.head())