TsDataCache

class czsc.data.TsDataCache(data_path, refresh=False, sdt='20120101', edt=datetime.datetime(2024, 3, 8, 10, 0, 19, 390231))[source]

Bases: object

Tushare 数据缓存

Methods Summary

cctv_news([date])

新闻联播

clear()

清空缓存

daily_basic(ts_code, start_date, end_date)

每日指标

daily_basic_new(trade_date)

股票每日指标接口整合

get_all_ths_members([exchange, type_])

获取同花顺A股全部概念列表

get_dates_span(sdt, edt[, is_open])

获取日期区间列表

get_next_trade_dates(date[, n, m])

获取将来的交易日期

hk_hold([trade_date])

沪深港股通持股明细

index_weight(index_code, trade_date)

指数成分和权重

limit_list(trade_date)

https://tushare.pro/document/2?doc_id=198

pro_bar(ts_code[, start_date, end_date, ...])

获取日线以上数据

pro_bar_minutes(ts_code[, sdt, edt, freq, ...])

获取分钟线

stock_basic()

获取基础信息数据,包括股票代码、名称、上市日期、退市日期等

stocks_daily_bars([sdt, edt, adj])

读取A股全部历史日线

stocks_daily_basic_new(sdt, edt)

读取A股 sdt ~ edt 时间区间的全部历史 daily_basic_new

ths_daily(ts_code[, start_date, end_date, ...])

获取同花顺概念板块的日线行情

ths_index([exchange, type_])

获取同花顺概念

ths_member(ts_code)

获取同花顺概念成分股

trade_cal()

https://tushare.pro/document/2?doc_id=26

Methods Documentation

cctv_news(date='20190625')[source]

新闻联播

https://tushare.pro/document/2?doc_id=154

clear()[source]

清空缓存

daily_basic(ts_code: str, start_date: str, end_date: str)[source]

每日指标

https://tushare.pro/document/2?doc_id=32

daily_basic_new(trade_date: str)[source]

股票每日指标接口整合

每日指标:https://tushare.pro/document/2?doc_id=32 备用列表:https://tushare.pro/document/2?doc_id=262

Parameters:

trade_date – 交易日期

Returns:

get_all_ths_members(exchange='A', type_='N')[source]

获取同花顺A股全部概念列表

get_dates_span(sdt: str, edt: str, is_open: bool = True) List[str][source]

获取日期区间列表

Parameters:
  • sdt – 开始日期

  • edt – 结束日期

  • is_open – 是否是交易日

Returns:

日期区间列表

get_next_trade_dates(date, n: int = 1, m: int | None = None)[source]

获取将来的交易日期

如果 m = None,返回基准日期后第 n 个交易日;否则返回基准日期后第 n ~ m 个交易日

Parameters:
  • date – 基准日期

  • n

  • m

Returns:

hk_hold(trade_date='20190625')[source]

沪深港股通持股明细

https://tushare.pro/document/2?doc_id=188

index_weight(index_code: str, trade_date: str)[source]

指数成分和权重

https://tushare.pro/document/2?doc_id=96

limit_list(trade_date: str)[source]

https://tushare.pro/document/2?doc_id=198

Parameters:

trade_date – 交易日期

Returns:

每日涨跌停统计

pro_bar(ts_code, start_date=None, end_date=None, freq='D', asset='E', adj='qfq', raw_bar=True)[source]

获取日线以上数据

https://tushare.pro/document/2?doc_id=109

Parameters:
  • ts_code

  • start_date

  • end_date

  • freq

  • asset – 资产类别:E股票 I沪深指数 C数字货币 FT期货 FD基金 O期权 CB可转债(v1.2.39),默认E

  • adj – 资产类别:E股票 I沪深指数 C数字货币 FT期货 FD基金 O期权 CB可转债(v1.2.39),默认E

  • raw_bar

Returns:

pro_bar_minutes(ts_code, sdt=None, edt=None, freq='60min', asset='E', adj=None, raw_bar=True)[source]

获取分钟线

https://tushare.pro/document/2?doc_id=109

Parameters:
  • ts_code – 标的代码

  • sdt – 开始时间,精确到分钟

  • edt – 结束时间,精确到分钟

  • freq – 分钟周期,可选值 1min, 5min, 15min, 30min, 60min

  • asset – 资产类别:E股票 I沪深指数 C数字货币 FT期货 FD基金 O期权 CB可转债(v1.2.39),默认E

  • adj – 复权类型,None不复权,qfq:前复权,hfq:后复权

  • raw_bar – 是否返回 RawBar 对象列表

Returns:

stock_basic()[source]

获取基础信息数据,包括股票代码、名称、上市日期、退市日期等

https://tushare.pro/document/2?doc_id=25

Returns:

stocks_daily_bars(sdt='20190101', edt='20220218', adj='hfq')[source]

读取A股全部历史日线

Parameters:
  • sdt – 开始日期

  • edt – 结束日期

  • adj – 复权类型

Returns:

stocks_daily_basic_new(sdt: str, edt: str)[source]

读取A股 sdt ~ edt 时间区间的全部历史 daily_basic_new

Parameters:
  • sdt – 开始日期

  • edt – 结束日期

Returns:

ths_daily(ts_code, start_date=None, end_date=None, raw_bar=True)[source]

获取同花顺概念板块的日线行情

ths_index(exchange='A', type_='N')[source]

获取同花顺概念

https://tushare.pro/document/2?doc_id=259

ths_member(ts_code)[source]

获取同花顺概念成分股

https://tushare.pro/document/2?doc_id=261 :param ts_code: :return:

trade_cal()[source]

https://tushare.pro/document/2?doc_id=26