โ† Back to list
tycallen

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: YYYYMMDD string (e.g., '20240101')
  • Adjustment types:
    • adj_factor table stores raw Tushare adjustment factors
    • qfq (forward): price * (factor / latest_factor) โ€” latest price = market price
    • hfq (backward): price * factor โ€” historical prices stay fixed
    • DataReader handles calculation automatically via adj='qfq' or adj='hfq'
  • Rate limit profiles: 'trial', 'standard', 'pro'

Implemented Tables

TableTushare APIPrimary KeysFixed/Default Params
trade_caltrade_calexchange, cal_dateexchange='SSE'
stock_basicstock_basicts_codeโ€”
stock_companystock_companyts_codeโ€”
dailydailyts_code, trade_dateasset='E' (stocks), 'I' (index)
adj_factoradj_factorts_code, trade_dateโ€”
daily_basicdaily_basicts_code, trade_dateโ€”
index_basicindex_basicts_codeโ€”
index_classifyindex_classifyindustry_codesrc='SW2021'
index_member_allindex_member_allts_code, l3_code, in_dateโ€”
index_weightindex_weightindex_code, trade_date, con_codeโ€”
cyq_perfcyq_perfts_code, trade_dateโ€”
stk_factor_prostk_factor_prots_code, trade_dateโ€”
moneyflowmoneyflowts_code, trade_dateโ€”
moneyflow_dcmoneyflow_dcts_code, trade_dateโ€”
dc_indexdc_indexts_code, trade_dateโ€”
dc_memberdc_memberts_code, trade_date, con_codeโ€”
fina_indicator_vipfina_indicator_vipts_code, end_dateโ€”
incomeincome / income_vipts_code, end_date, report_typeโ€”
balancesheetbalancesheet / balancesheet_vipts_code, end_date, report_typeโ€”
cashflowcashflow / cashflow_vipts_code, end_date, report_typeโ€”
dividenddividendts_code, end_dateโ€”
margin_detailmargin_detailts_code, trade_dateโ€”
hs_consths_constts_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