255 lines
6.7 KiB
Go
255 lines
6.7 KiB
Go
package tushare
|
||
|
||
/*
|
||
Income 获取利润表
|
||
|
||
ts_code: 股票代码,支持多个,逗号分隔
|
||
ann_date: 公告日期,格式:YYYYMMDD
|
||
start_date: 开始日期,格式:YYYYMMDD
|
||
end_date: 结束日期,格式:YYYYMMDD
|
||
report_type: 报表类型,1:合并报表,2:母公司报表
|
||
*/
|
||
func (cli *TushareClient) Income(ts_code, ann_date, start_date, end_date, report_type string) (*TushareRespData, error) {
|
||
params := map[string]any{}
|
||
|
||
if ts_code != "" {
|
||
params["ts_code"] = ts_code
|
||
}
|
||
if ann_date != "" {
|
||
params["ann_date"] = ann_date
|
||
}
|
||
if start_date != "" {
|
||
params["start_date"] = start_date
|
||
}
|
||
if end_date != "" {
|
||
params["end_date"] = end_date
|
||
}
|
||
if report_type != "" {
|
||
params["report_type"] = report_type
|
||
}
|
||
|
||
req := TushareReq{
|
||
APIName: "income",
|
||
Params: params,
|
||
}
|
||
|
||
fields := []map[string]string{
|
||
{"ts_code": "股票代码"},
|
||
{"ann_date": "公告日期"},
|
||
{"f_ann_date": "实际公告日期"},
|
||
{"end_date": "报告期"},
|
||
{"basic_eps": "基本每股收益"},
|
||
{"diluted_eps": "稀释每股收益"},
|
||
{"total_revenue": "营业总收入"},
|
||
{"revenue": "营业收入"},
|
||
{"total_profit": "利润总额"},
|
||
{"net_profit": "净利润"},
|
||
{"net_profit_attr_sh": "归属于母公司所有者的净利润"},
|
||
{"operating_expense": "营业总成本"},
|
||
{"operating_cost": "营业成本"},
|
||
}
|
||
|
||
return cli.Do(req, fields)
|
||
}
|
||
|
||
/*
|
||
Balancesheet 获取资产负债表
|
||
|
||
ts_code: 股票代码,支持多个,逗号分隔
|
||
ann_date: 公告日期,格式:YYYYMMDD
|
||
start_date: 开始日期,格式:YYYYMMDD
|
||
end_date: 结束日期,格式:YYYYMMDD
|
||
report_type: 报表类型,1:合并报表,2:母公司报表
|
||
*/
|
||
func (cli *TushareClient) Balancesheet(ts_code, ann_date, start_date, end_date, report_type string) (*TushareRespData, error) {
|
||
params := map[string]any{}
|
||
|
||
if ts_code != "" {
|
||
params["ts_code"] = ts_code
|
||
}
|
||
if ann_date != "" {
|
||
params["ann_date"] = ann_date
|
||
}
|
||
if start_date != "" {
|
||
params["start_date"] = start_date
|
||
}
|
||
if end_date != "" {
|
||
params["end_date"] = end_date
|
||
}
|
||
if report_type != "" {
|
||
params["report_type"] = report_type
|
||
}
|
||
|
||
req := TushareReq{
|
||
APIName: "balancesheet",
|
||
Params: params,
|
||
}
|
||
|
||
fields := []map[string]string{
|
||
{"ts_code": "股票代码"},
|
||
{"ann_date": "公告日期"},
|
||
{"f_ann_date": "实际公告日期"},
|
||
{"end_date": "报告期"},
|
||
{"total_assets": "资产总计"},
|
||
{"total_liab": "负债合计"},
|
||
{"total_hldr_eqy_exc_min_int": "股东权益合计"},
|
||
{"total_hldr_eqy_inc_min_int": "股东权益合计 (含少数股东权益)"},
|
||
{"total_share_capital": "股本"},
|
||
{"cap_rsrv": "资本公积"},
|
||
{"surplus_rsrv": "盈余公积"},
|
||
{"undist_prft": "未分配利润"},
|
||
{"monetary_cap": "货币资金"},
|
||
{"total_current_assets": "流动资产合计"},
|
||
{"total_non_current_assets": "非流动资产合计"},
|
||
}
|
||
|
||
return cli.Do(req, fields)
|
||
}
|
||
|
||
/*
|
||
Cashflow 获取现金流量表
|
||
|
||
ts_code: 股票代码,支持多个,逗号分隔
|
||
ann_date: 公告日期,格式:YYYYMMDD
|
||
start_date: 开始日期,格式:YYYYMMDD
|
||
end_date: 结束日期,格式:YYYYMMDD
|
||
report_type: 报表类型,1:合并报表,2:母公司报表
|
||
*/
|
||
func (cli *TushareClient) Cashflow(ts_code, ann_date, start_date, end_date, report_type string) (*TushareRespData, error) {
|
||
params := map[string]any{}
|
||
|
||
if ts_code != "" {
|
||
params["ts_code"] = ts_code
|
||
}
|
||
if ann_date != "" {
|
||
params["ann_date"] = ann_date
|
||
}
|
||
if start_date != "" {
|
||
params["start_date"] = start_date
|
||
}
|
||
if end_date != "" {
|
||
params["end_date"] = end_date
|
||
}
|
||
if report_type != "" {
|
||
params["report_type"] = report_type
|
||
}
|
||
|
||
req := TushareReq{
|
||
APIName: "cashflow",
|
||
Params: params,
|
||
}
|
||
|
||
fields := []map[string]string{
|
||
{"ts_code": "股票代码"},
|
||
{"ann_date": "公告日期"},
|
||
{"f_ann_date": "实际公告日期"},
|
||
{"end_date": "报告期"},
|
||
{"net_cash_invest_act": "投资活动产生的现金流量净额"},
|
||
{"net_cash_financing_act": "筹资活动产生的现金流量净额"},
|
||
{"net_cash_oper_act": "经营活动产生的现金流量净额"},
|
||
{"cash_equivalents_end": "现金及现金等价物期末余额"},
|
||
{"cash_equivalents_begin": "现金及现金等价物期初余额"},
|
||
{"net_increase_cash": "现金及现金等价物净增加额"},
|
||
}
|
||
|
||
return cli.Do(req, fields)
|
||
}
|
||
|
||
/*
|
||
FinaIndicator 获取财务指标
|
||
|
||
ts_code: 股票代码,支持多个,逗号分隔
|
||
ann_date: 公告日期,格式:YYYYMMDD
|
||
start_date: 开始日期,格式:YYYYMMDD
|
||
end_date: 结束日期,格式:YYYYMMDD
|
||
*/
|
||
func (cli *TushareClient) FinaIndicator(ts_code, ann_date, start_date, end_date string) (*TushareRespData, error) {
|
||
params := map[string]any{}
|
||
|
||
if ts_code != "" {
|
||
params["ts_code"] = ts_code
|
||
}
|
||
if ann_date != "" {
|
||
params["ann_date"] = ann_date
|
||
}
|
||
if start_date != "" {
|
||
params["start_date"] = start_date
|
||
}
|
||
if end_date != "" {
|
||
params["end_date"] = end_date
|
||
}
|
||
|
||
req := TushareReq{
|
||
APIName: "fina_indicator",
|
||
Params: params,
|
||
}
|
||
|
||
fields := []map[string]string{
|
||
{"ts_code": "股票代码"},
|
||
{"ann_date": "公告日期"},
|
||
{"end_date": "报告期"},
|
||
{"eps_basic": "基本每股收益"},
|
||
{"eps_diluted": "稀释每股收益"},
|
||
{"roe": "净资产收益率%"},
|
||
{"roe_wa": "净资产收益率 (加权)%"},
|
||
{"roa": "总资产净利率%"},
|
||
{"gross_margin": "销售毛利率%"},
|
||
{"net_profit_margin": "销售净利率%"},
|
||
{"current_ratio": "流动比率"},
|
||
{"quick_ratio": "速动比率"},
|
||
{"debt_to_assets": "资产负债率%"},
|
||
{"turnover_days": "存货周转天数"},
|
||
{"receivables_turnover": "应收账款周转率"},
|
||
}
|
||
|
||
return cli.Do(req, fields)
|
||
}
|
||
|
||
/*
|
||
Forecast 获取业绩预告
|
||
|
||
ts_code: 股票代码,支持多个,逗号分隔
|
||
ann_date: 公告日期,格式:YYYYMMDD
|
||
start_date: 开始日期,格式:YYYYMMDD
|
||
end_date: 结束日期,格式:YYYYMMDD
|
||
type: 预告类型,预增/预减/扭亏/续盈/首亏/略增/略减
|
||
*/
|
||
func (cli *TushareClient) Forecast(ts_code, ann_date, start_date, end_date, forecast_type string) (*TushareRespData, error) {
|
||
params := map[string]any{}
|
||
|
||
if ts_code != "" {
|
||
params["ts_code"] = ts_code
|
||
}
|
||
if ann_date != "" {
|
||
params["ann_date"] = ann_date
|
||
}
|
||
if start_date != "" {
|
||
params["start_date"] = start_date
|
||
}
|
||
if end_date != "" {
|
||
params["end_date"] = end_date
|
||
}
|
||
if forecast_type != "" {
|
||
params["type"] = forecast_type
|
||
}
|
||
|
||
req := TushareReq{
|
||
APIName: "forecast",
|
||
Params: params,
|
||
}
|
||
|
||
fields := []map[string]string{
|
||
{"ts_code": "股票代码"},
|
||
{"ann_date": "公告日期"},
|
||
{"end_date": "报告期"},
|
||
{"type": "预告类型"},
|
||
{"net_profit_min": "净利润下限 (万元)"},
|
||
{"net_profit_max": "净利润上限 (万元)"},
|
||
{"parent_netprofit_min": "归母净利润下限 (万元)"},
|
||
{"parent_netprofit_max": "归母净利润上限 (万元)"},
|
||
{"summary": "业绩预告摘要"},
|
||
}
|
||
|
||
return cli.Do(req, fields)
|
||
}
|