Files
playbook/skills/tsl-api-reference/references/codegen/module/ts-index-application.md
T

17 KiB

指数研究 / 指数应用

tsindexs_getbascinfobyendt(index_arr, filter_cond)

声明:function

天软指数最新基本信息

参数 类型 说明
index_arr string 字符串,指数池,支持单个指数(字符串) ,多个指数(数组形式)
filter_cond string 指数筛选条件;支持按指数板块名、常用指数板块编号或字段条件筛选,空字符串表示不额外筛选

返回:array

示例

范例01:调用示例

indexArr := 'TSI010001';
   filterCond := '';
   return tsindexs_getbascinfobyendt(indexArr,filterCond);

tsindexs_getvalueinfobyendt(index_arr, filter_cond)

声明:function

天软指数最新估值分析 (股票指数专用)

参数 类型 说明
index_arr array 一维字符串数组,指数池
filter_cond string 字符串,筛选条件

返回:array

示例

范例01:调用示例

indexArr := 'TSI010001';
   filterCond := '';
   return tsindexs_getvalueinfobyendt(indexArr,filterCond);

tsindexs_getprofitinfobyendt(index_arr, r_type, filter_cond)

声明:function

股票指数盈利分析:行业名称、总市值、ROE、营收、营收+/-、净利润、净利润+/-、现金流、

参数 类型 说明
index_arr array 一维字符串数组,指数池
r_type user_define 用户自定义,财报数据类型 显示名 取值 TTM 0 年报 1
filter_cond string 字符串,筛选条件

返回:array

示例

范例01:调用示例

indexArr := 'TSI010001';
   filterCond := '';
   return tsindexs_getprofitinfobyendt(indexArr,0,filterCond);

tsindexs_getPeriodReturnReport(index_arr, endt, filter_cond)

声明:function

自定义区间内天软指数阶段涨幅、阶段收益率统计

参数 类型 说明
index_arr string 字符串,指数池
endt date 日期,截止日
filter_cond string 字符串,指数过滤条件

返回:array

示例

范例01:调用示例

indexArr := 'TSI010001';
   endt := 20260525t;
   filterCond := '';
   return tsindexs_getPeriodReturnReport(indexArr,endt,filterCond);

tsindexs_getRollReturnReport(index_arr, begt, endt, cycle, filter_cond)

声明:function

天软指数业绩查询

参数 类型 说明
index_arr array 一维字符串数组,指数池
begt date 日期,开始日
endt date 日期,截止日
cycle cycle_list 周期,周期
filter_cond string 字符串,指数过滤条件

返回:array

示例

范例01:调用示例

indexArr := 'TSI010001';
   begt := 20240525t;
   endt := 20260525t;
   filterCond := '';
   return tsindexs_getRollReturnReport(indexArr,begt,endt,'年线
',filterCond);

范例02:调用示例

indexArr := 'TSI010001';
   begt := 20240525t;
   endt := 20260525t;
   filterCond := '';
   return
tsindexs_getRiskFeatureReport(indexArr,begt,endt,1,'SH000300',filterCond)
;

tsindex_getReturnAndRisk(index_id, begt, endt, qk_type, cycle)

声明:function

天软指数收益风险特征

参数 类型 说明
index_id string 字符串,指数 ID
begt date 日期,开始日
endt date 日期,截止日
qk_type user_define 用户自定义,采样类型 显示名 取值
cycle cycle_list 周期,周期

返回:array

示例

范例01:调用示例

indexID := 'TSI010001';
   begt := 20240525t;
   endt := 20260525t;
   cycle := '年线';
   return tsindex_getReturnAndRisk(indexID,begt,endt,0,cycle);

index_getbkweight(indexid, endt)

声明:function

指数最新权重

参数 类型 说明
indexid string 字符串,指数代码
endt date 日期,截止日

返回:array

示例

范例01:调用示例

indexID := 'TSI010001';
   endt := 20260525t;
   return Index_getbkweight(indexid,endt);

index_getbkweightstat(indexid, endt, label)

声明:function

指数成分统计

参数 类型 说明
indexid string 字符串,指数代码
endt date 日期,截止日 label_:用户自定义,分类类型 显示名 取值 申万一级 1 中证一级 2 证监会一级 3 板块 4
label user_define 指数成分统计结果中用于分组或标记的字段标签

返回:array

示例

范例01:调用示例

indexID := 'TSI010001';
   endt := 20260525t;
   return Index_getbkweightstat(indexid,endt,1);

范例02:调用示例

indexid := 'TSI010001';
   begt := 20100201t;
   endt := 20100228t;
   return index_getValuationTimeSeries(indexid,begt,endt,nil,1,-1);

范例03:调用示例

indexArr := 'TSI010001';
   endt := 20260525t;
   return Index_getCorrAnalysis(indexArr,begt,endt,1,1,nil,'');

范例04:调用示例

indexid := 'TSI010001';
   endt := 20260525t;
   return index_getHistoricalPerformance(indexid,nil,endt,1,'月线
',1,'SH000300');

cal_indexDecompMetric02_endt(index_id, endt, begt, cal_method)

声明:function

指数指定日收益分解,相对起始日,单期

参数 类型 说明
index_id string 指数 ID
endt datetime 截止日期
begt datetime 起始日期
cal_method any 计算选项,取值如下: 0:指数-博格法 1:指数-博格-残差 2:个股-残差 3:个股-残差-奇异值

返回:any

示例

范例01:沪深 300 在 2026/3/31 的季度收益分解

IndexID:="SH000300";
Setsysparam(Pn_Stock(),IndexID);
Endt:=20260331T;
Begt:=20260101T;
Cycle:=cy_Quarter();
obj:=New TSF_Index2_ProfitDecompTest();
t:= obj.Cal_IndexDecompMetric02_Endt(IndexID,Endt,begt,0);
return t;

cal_indexDecompMetric_endt(index_id_endt, cycle, cal_method)

声明:function

指定日周期下的指数收益分解,单期

参数 类型 说明
index_id_endt datetime 计算或查询区间的结束日期
cycle string 周期
cal_method any 计算选项,取值如下: 0:指数-博格法 1:指数-博格-残差 2:个股-残差 3:个股-残差-奇异值

返回:any

示例

范例01:沪深 300 在 2026/3/31 的季度收益分解

IndexID:="SH000300";
Setsysparam(Pn_Stock(),IndexID);
Endt:=20260331T;
Cycle:=cy_Quarter();
obj:=New TSF_Index2_ProfitDecompTest();
t:= obj.Cal_IndexDecompMetric_Endt(IndexID,Endt,Cycle,0);
return t;

cal_indexDecompMetric_qk(index_id, begt, endt, cycle, cal_method)

声明:function

区间周期下的指数收益分解

参数 类型 说明
index_id string 指数 ID
begt datetime 起始日期
endt datetime 截止日期
cycle string 周期
cal_method any 计算选项,取值如下: 0:指数-博格法 1:指数-博格-残差 2:个股-残差 3:个股-残差-奇异值

返回:any

示例

范例01:沪深 300 在 2010/1/1~2026/3/31 的季度收益分解

IndexID:="SH000300";
Setsysparam(Pn_Stock(),IndexID);
begt:=20100101T;
Endt:=20260331T;
Cycle:=cy_Quarter();
obj:=New TSF_Index2_ProfitDecompTest();
t:= obj.Cal_IndexDecompMetric_QK(IndexID,begt,Endt,Cycle,0);
return t;

cal_indexQKZF(index_id, begt, endt)

声明:function

指数区间涨幅(%)。配置模型

参数 类型 说明
index_id string 指数 ID,字符串
begt datetime 起始日,日期型
endt datetime 截止日,日期型

返回:any

cal_portfolioProfitMetric(wt, endt, metric_field)

声明:function

指定日成分权重指标数据,配置模型

参数 类型 说明
wt array 指定日股票权重,二维数组。包含字段:截止日、代码、比例(%)
endt datetime 截止日,日期型
metric_field string 指标字段标识码,字符串

返回:any

get_indexStockWeight(index_id, endt)

声明:function

指定日指数权重,配置模型

参数 类型 说明
index_id string 指数 ID,字符串
endt datetime 截止日,日期型

返回:any

rt_indexIndicData(begt, endt)

声明:function

区间指数指标信息返回

参数 类型 说明
begt datetime 起始日期,日期型,支持缺省
endt datetime 截止日期,日期型,支持缺省

返回:any

rt_stockIndicData(begt, endt)

声明:function

区间个券指标信息返回

参数 类型 说明
begt datetime 起始日期,日期型,支持缺省
endt datetime 截止日期,日期型,支持缺省

返回:any

sat_indexDecompMetric_qk(index_id, begt, endt, cycle, cal_method, attr_type)

声明:function

区间收益分解统计

参数 类型 说明
index_id string 指数代码
begt datetime 开始日期
endt datetime 截止日期 Cycle Strting 周期
cycle string 计算或行情数据使用的周期
cal_method any 指数计算选项: 0:指数指标-不引入残差(缺省) 1:指数指标-引入残差 2:个券指标-不引入残差 3:个券指标-引入残差
attr_type any 多期收益分解算法: 0:收益贡献法(缺省) 1:算术几何法

返回:any

示例

范例01:调用示例

IndexID:="SH000300";
Endt:=20260630T;
begt:=20240101T;
CalMethod:=1;
Cycle:=cy_quarter();
AttrType:=0;
obj:=New TSF_Index2_ProfitDecompTest();
return
obj.Sat_IndexDecompMetric_QK(IndexID,begt,Endt,Cycle,CalMethod,AttrType);

tfm_indexDeCompMetric_qk(index_id, begt, endt, cycle, cal_method, attr_type)

声明:function

指数区间收益分解,指定周期

参数 类型 说明
index_id string 指数代码
begt datetime 开始日期
endt datetime 截止日期 Cycle Strting 周期
cycle string 计算或行情数据使用的周期
cal_method any 指数计算选项: 0:指数指标-不引入残差(缺省) 1:指数指标-引入残差 2:个券指标-不引入残差 3:个券指标-引入残差
attr_type any 多期收益分解算法: 0:收益贡献法(缺省)

返回:any

示例

范例01:调用示例

IndexID:="SH000300";
Endt:=20260630T;
begt:=20240101T;
CalMethod:=1;
Cycle:=cy_quarter();
AttrType:=0;
return TFM_IndexDeCompMetric_QK(IndexID,begt,Endt,Cycle,CalMethod,
AttrType);