スキル一覧に戻る
tycallen

tushare-duckdb

by tycallen

🚀 A high-performance, locally-cached 💾 Tushare 📈 data interface powered by 🦆 DuckDB

8🍴 2📅 2026年1月24日
GitHubで見るManusで実行

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>.

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

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

レビュー

💬

レビュー機能は近日公開予定です