Comprehensive data infrastructure for quantitative trading in Chinese A-share market.
bash
pip install tushare akshare pandas numpy
python
# Set Tushare token
export TUSHARE_TOKEN=your_token_here
# Or in code
from quant_data import DataPlatform
platform = DataPlatform(tushare_token='your_token')
python
from quant_data import DataPlatform
platform = DataPlatform()
# Get real-time quotes
quotes = platform.get_realtime_quotes(['600519', '000858'])
print(quotes)
# code price change volume amount
# 600519 1850.00 +12.50 125000 231250000
# 000858 156.32 +2.18 89000 13912320
# Get tick data
ticks = platform.get_tick_data('600519', date='2026-03-22')
# Get order book
book = platform.get_order_book('600519')
python
# Get daily K-line
daily = platform.get_daily(
codes=['600519', '000858'],
start='2020-01-01',
end='2026-03-22'
)
# Get minute data
minute = platform.get_minute(
code='600519',
freq='5min',
start='2026-03-01',
end='2026-03-22'
)
# Get adjusted data
adj = platform.get_daily_adj(code='600519', adjust='qfq')
python
# Get sentiment data
sentiment = platform.get_sentiment('600519', days=30)
# Get news
news = platform.get_news('600519', limit=50)
# Get fundamentals
fundamentals = platform.get_fundamentals('600519', years=5)
# Get short interest
short = platform.get_short_interest('600519')
python
# Get pre-computed factors
factors = platform.get_factors(
codes=['600519', '000858'],
factor_list=['pe', 'pb', 'roe', 'momentum_20d', 'volatility_20d']
)
# Calculate custom factors
custom = platform.calculate_factors(
code='600519',
factor_config={
'name': 'my_momentum',
'formula': 'close / close.shift(20) - 1',
'params': {}
}
)
python
# Check data quality
quality = platform.check_quality('600519', date_range='2026-03')
print(quality)
# {
# 'completeness': 0.98,
# 'accuracy': 0.99,
# 'timeliness': 0.95,
# 'overall': 0.97
# }
# Get data gaps
gaps = platform.find_gaps('600519', start='2026-01-01')
# Validate data
valid = platform.validate('600519', date='2026-03-22')
MethodDescriptionget_realtime_quotes(codes)Get real-time quotesget_tick_data(code, date)Get tick dataget_order_book(code)Get order booksubscribe(codes, callback)Subscribe to updates
MethodDescriptionget_daily(codes, start, end)Get daily K-lineget_minute(code, freq, start, end)Get minute dataget_daily_adj(code, adjust)Get adjusted dataget_trading_dates(start, end)Get trading dates
MethodDescriptionget_sentiment(code, days)Get sentiment dataget_news(code, limit)Get newsget_fundamentals(code, years)Get fundamentalsget_short_interest(code)Get short interest
MethodDescriptionget_factors(codes, factor_list)Get factor valuescalculate_factors(code, config)Calculate custom factorslist_factors()List available factorsget_factor_metadata(name)Get factor info
MethodDescriptioncheck_quality(code, date_range)Check data qualityfind_gaps(code, start)Find missing datavalidate(code, date)Validate data point
TypeSourceUpdate FrequencyQuotesTushare, AkshareReal-timeFundamentalsTushareDailyNewsTushare, EastmoneyReal-timeSentimentCustomHourlyAlternativeMultipleVaries
python
# Configure caching
platform = DataPlatform(
cache_dir='~/.quant_data/cache',
cache_expire={
'daily': '1d',
'minute': '1h',
'realtime': '0',
'fundamentals': '1d'
}
)
SourceRate LimitStrategyTushare200/minToken bucketAkshare100/minToken bucketCustomUnlimitedN/A
text
code: str # Stock code
trade_date: date # Trading date
open: float # Open price
high: float # High price
low: float # Low price
close: float # Close price
volume: int # Volume
amount: float # Amount
turnover: float # Turnover rate
text
code: str # Stock code
trade_date: date # Trading date
factor_name: str # Factor name
factor_value: float # Factor value