Files
qsdk/tushare/ths.go
2026-05-01 11:03:19 +08:00

214 lines
5.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tushare
/*
ThsHot 同花顺热榜
trade_date str N 交易日期
ts_code str N TS代码
market str N 热榜类型(热股、ETF、可转债、行业板块、概念板块、期货、港股、热基、美股)
is_new str N 是否最新默认Y如果为N则为盘中和盘后阶段采集具体时间可参考rank_time字段状态N每小时更新一次状态Y更新时间为2230
*/
func (cli *TushareClient) ThsHot(trade_date, ts_code, market, is_new string) (*TushareRespData, error) {
params := map[string]any{}
if trade_date != "" {
params["trade_date"] = trade_date
}
if ts_code != "" {
params["ts_code"] = ts_code
}
if market != "" {
params["market"] = market
}
if is_new != "" {
params["is_new"] = is_new
}
req := TushareReq{
APIName: "ths_hot",
Params: params,
}
/*
trade_date str Y 交易日期
data_type str Y 数据类型
ts_code str Y 股票代码
ts_name str Y 股票名称
rank int Y 排行
pct_change float Y 涨跌幅%
current_price float Y 当前价格
concept str Y 标签
rank_reason str Y 上榜解读
hot float Y 热度值
rank_time str Y 排行榜获取时间
*/
fields := []map[string]string{
{"trade_date": "交易日期"},
{"data_type": "数据类型"},
{"ts_code": "TS代码"},
{"ts_name": "股票名称"},
{"rank": "排行"},
{"pct_change": "涨跌幅%"},
{"current_price": "当前价格"},
{"concept": "标签"},
{"rank_reason": "上榜解读"},
{"hot": "热度值"},
{"rank_time": "排行榜获取时间"},
}
return cli.Do(req, fields)
}
/*
ThsIndex 同花顺概念和行业指数
接口说明:
- 描述:获取同花顺板块指数,包括概念、行业、特色指数
- 权限本接口需有6000积分单次最大返回5000行数据一次可提取全部数据请勿循环提取
- 注意事项:数据版权归属同花顺,如做商业用途,请主动联系同花顺
输入参数:
- ts_code: 指数代码(可选)
- exchange: 市场类型A-a股 HK-港股 US-美股(可选)
- type: 指数类型N-概念指数 I-行业指数 R-地域指数 S-同花顺特色指数 ST-同花顺风格指数 TH-同花顺主题指数 BB-同花顺宽基指数(可选)
输出参数:
- ts_code: 代码
- name: 名称
- count: 成分个数
- exchange: 交易所
- list_date: 上市日期
- type: N概念指数S特色指数
*/
func (cli *TushareClient) ThsIndex(ts_code, exchange, typ string) (*TushareRespData, error) {
params := map[string]any{}
if ts_code != "" {
params["ts_code"] = ts_code
}
if exchange != "" {
params["exchange"] = exchange
}
if typ != "" {
params["type"] = typ
}
req := TushareReq{
APIName: "ths_index",
Params: params,
}
fields := []map[string]string{
{"ts_code": "代码"},
{"name": "名称"},
{"count": "成分个数"},
{"exchange": "交易所"},
{"list_date": "上市日期"},
{"type": "类型"},
}
return cli.Do(req, fields)
}
/*
ThsDaily 同花顺板块指数行情
接口说明:
- 描述:获取同花顺板块指数行情
- 限量单次最大3000行数据需6000积分可根据指数代码、日期参数循环提取
- 注意事项:数据版权归属同花顺,如做商业用途,请主动联系同花顺
输入参数:
- ts_code: 指数代码(可选)
- trade_date: 交易日期YYYYMMDD格式可选
- start_date: 开始日期YYYYMMDD格式可选
- end_date: 结束日期YYYYMMDD格式可选
输出参数:
- ts_code: TS指数代码
- trade_date: 交易日
- close: 收盘点位
- open: 开盘点位
- high: 最高点位
- low: 最低点位
- pre_close: 昨日收盘点
- avg_price: 平均价
- change: 涨跌点位
- pct_change: 涨跌幅
- vol: 成交量(手)
- turnover_rate: 换手率(%
- total_mv: 总市值(元)
- float_mv: 流通市值(元)
*/
func (cli *TushareClient) ThsDaily(ts_code, trade_date, start_date, end_date string) (*TushareRespData, error) {
params := map[string]any{}
if ts_code != "" {
params["ts_code"] = ts_code
}
if trade_date != "" {
params["trade_date"] = trade_date
}
if start_date != "" {
params["start_date"] = start_date
}
if end_date != "" {
params["end_date"] = end_date
}
req := TushareReq{
APIName: "ths_daily",
Params: params,
}
fields := []map[string]string{
{"ts_code": "TS指数代码"},
{"trade_date": "交易日"},
{"close": "收盘点位"},
{"open": "开盘点位"},
{"high": "最高点位"},
{"low": "最低点位"},
{"pre_close": "昨日收盘点"},
{"avg_price": "平均价"},
{"change": "涨跌点位"},
{"pct_change": "涨跌幅"},
{"vol": "成交量(手)"},
{"turnover_rate": "换手率(%"},
{"total_mv": "总市值(元)"},
{"float_mv": "流通市值(元)"},
}
return cli.Do(req, fields)
}
/*
ThsMember 获取同花顺概念板块成分
ts_code: 板块指数代码
con_code: 股票代码
*/
func (cli *TushareClient) ThsMember(ts_code, con_code string) (*TushareRespData, error) {
params := map[string]any{}
if ts_code != "" {
params["ts_code"] = ts_code
}
if con_code != "" {
params["con_code"] = con_code
}
req := TushareReq{
APIName: "ths_member",
Params: params,
}
fields := []map[string]string{
{"ts_code": "指数代码"},
{"con_code": "股票代码"},
{"con_name": "股票名称"},
{"weight": "权重"},
{"in_date": "纳入日期"},
{"out_date": "剔除日期"},
{"is_new": "是否最新"},
}
return cli.Do(req, fields)
}