โ Back to list

tushare-duckdb
by tycallen
๐ A high-performance, locally-cached ๐พ Tushare ๐ data interface powered by ๐ฆ DuckDB
โญ 8๐ด 2๐
Jan 24, 2026
SKILL.md
name: tushare-duckdb description: Query Chinese stock data from local DuckDB cache. Use when user wants local data access instead of direct Tushare API calls.
tushare-duckdb
Local DuckDB cache layer for Tushare Pro data. For API parameter details, use /tushare-finance <api_name>.
Quick Start
Read Data (no network, concurrent-safe)
from tushare_db import DataReader
reader = DataReader(db_path="tushare.db")
# Single stock with forward adjustment
df = reader.get_stock_daily('000001.SZ', '20240101', adj='qfq')
# Multiple stocks
df = reader.get_multiple_stocks_daily(['000001.SZ', '600519.SH'], '20240101')
# Trade calendar
df = reader.get_trade_calendar('20240101', '20241231')
# Stock list
df = reader.get_stock_basic(list_status='L')
# Custom SQL
df = reader.query("SELECT * FROM daily WHERE ts_code = ?", ['000001.SZ'])
reader.close()
Download Data (requires TUSHARE_TOKEN env var)
from tushare_db import DataDownloader
downloader = DataDownloader(db_path="tushare.db", rate_limit_profile="standard")
# Basic data
downloader.download_trade_calendar()
downloader.download_stock_basic()
# Daily data for all stocks
downloader.download_all_stocks_daily(start_date='20200101')
# Daily update (single date)
downloader.download_daily_data_by_date('20241218')
downloader.close()
Key Notes
- Date format:
YYYYMMDDstring (e.g.,'20240101') - Adjustment types:
adj_factortable stores raw Tushare adjustment factorsqfq(forward):price * (factor / latest_factor)โ latest price = market pricehfq(backward):price * factorโ historical prices stay fixed- DataReader handles calculation automatically via
adj='qfq'oradj='hfq'
- Rate limit profiles:
'trial','standard','pro'
Implemented Tables
| Table | Tushare API | Primary Keys | Fixed/Default Params |
|---|---|---|---|
trade_cal | trade_cal | exchange, cal_date | exchange='SSE' |
stock_basic | stock_basic | ts_code | โ |
stock_company | stock_company | ts_code | โ |
daily | daily | ts_code, trade_date | asset='E' (stocks), 'I' (index) |
adj_factor | adj_factor | ts_code, trade_date | โ |
daily_basic | daily_basic | ts_code, trade_date | โ |
index_basic | index_basic | ts_code | โ |
index_classify | index_classify | industry_code | src='SW2021' |
index_member_all | index_member_all | ts_code, l3_code, in_date | โ |
index_weight | index_weight | index_code, trade_date, con_code | โ |
cyq_perf | cyq_perf | ts_code, trade_date | โ |
stk_factor_pro | stk_factor_pro | ts_code, trade_date | โ |
moneyflow | moneyflow | ts_code, trade_date | โ |
moneyflow_dc | moneyflow_dc | ts_code, trade_date | โ |
dc_index | dc_index | ts_code, trade_date | โ |
dc_member | dc_member | ts_code, trade_date, con_code | โ |
fina_indicator_vip | fina_indicator_vip | ts_code, end_date | โ |
income | income / income_vip | ts_code, end_date, report_type | โ |
balancesheet | balancesheet / balancesheet_vip | ts_code, end_date, report_type | โ |
cashflow | cashflow / cashflow_vip | ts_code, end_date, report_type | โ |
dividend | dividend | ts_code, end_date | โ |
margin_detail | margin_detail | ts_code, trade_date | โ |
hs_const | hs_const | ts_code, in_date | โ |
For column details and parameter meanings, invoke /tushare-finance <api_name>.
Score
Total Score
60/100
Based on repository quality metrics
โSKILL.md
SKILL.mdใใกใคใซใๅซใพใใฆใใ
+20
โLICENSE
ใฉใคใปใณในใ่จญๅฎใใใฆใใ
+10
โ่ชฌๆๆ
100ๆๅญไปฅไธใฎ่ชฌๆใใใ
0/10
โไบบๆฐ
GitHub Stars 100ไปฅไธ
0/15
โๆ่ฟใฎๆดปๅ
3ใถๆไปฅๅ ใซๆดๆฐใใใ
0/10
โใใฉใผใฏ
10ๅไปฅไธใใฉใผใฏใใใฆใใ
0/5
โIssue็ฎก็
ใชใผใใณIssueใ50ๆชๆบ
+5
โ่จ่ช
ใใญใฐใฉใใณใฐ่จ่ชใ่จญๅฎใใใฆใใ
+5
โใฟใฐ
1ใคไปฅไธใฎใฟใฐใ่จญๅฎใใใฆใใ
0/5
Reviews
๐ฌ
Reviews coming soon