Files
playbook/skills/tsl-api-reference/references/codegen/builtin/misc/pending.md
T
csh 1f19954dd7 ♻️ refactor(tsl-api-reference): reorganize function reference pages
Move runtime and document pages into their correct scope, remove obsolete pending entries, and regenerate the function index.\nUpdate agent test guidance and API skill routing to match the new reference layout.
2026-07-20 09:08:38 +08:00

366 lines
16 KiB
Markdown
Raw 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.
# Builtin - 待复核
## `qkfilterCC_createDateTreeIndex(data_cc, datefield, if_sort)`
持仓类数据 根据日期构建索引;持仓类数据,要求已按日期 排序,从小到大,相同日期放一起
| 参数 | 类型 | 说明 |
| ----------- | ------ | --------------------------- |
| `data_cc` | array | 二维字符串数组,区间每期持仓 |
| `datefield` | string | 字符串,日期字段 |
| `if_sort` | bool | object |
返回:array
## `qkfilterMJZ_createDateCodeTreeIndex(data_mjz, datefiled, codefiled)`
多净值类数据,根据日期、代码构建索引 截止日、代码 是唯一的
| 参数 | 类型 | 说明 |
| ----------- | ------ | ------------------------------------- |
| `data_mjz` | array | 二维字符串数组,区间多组合净值,立体表 |
| `datefiled` | string | 字符串,截止日字段 |
| `codefiled` | string | 字符串,组合代码字段 |
返回:array
## `GetSWHYBKbydate_IPO(indexid, endt)`
GetSWHYBKbydate_IPO 相关函数。
| 参数 | 类型 | 说明 |
| --------- | -------- | -------------------------------------- |
| `indexid` | string | 字符串,指数代码(仅针对申万行业指数) |
| `endt` | datetime | 日期,截止日 |
返回:array
## `down(rsp_cycle, n)`
高频下行波动率(%)
| 参数 | 类型 | 说明 |
| ----------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `rsp_cycle` | any | 采样小周期 |
| `n` | any | 整型,当前时间向历史推移N个周期长度作为采样的时间区间(大区间),与当前时间,周期相关。默认为 1,与市场周期对齐;N为0时,返回最后一个高频时刻 |
返回:float
## `invoicePrice(bond_id)`
返回指定期货相对于指定债券标的发票价格,与系统证券代码时间周期相关。
| 参数 | 类型 | 说明 |
| --------- | ------ | ---------------- |
| `bond_id` | string | 字符串,债券代码 |
返回:float
## `_v12(index_id, endt, qk_type, eg, detail_t)`
通过预测指数成分股的分红时间和分红金额,从而预测分红点数。
| 参数 | 类型 | 说明 |
| ---------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index_id` | string | 字符串型,指数ID |
| `endt` | datetime | 日期类型,截止日 |
| `qk_type` | any | 整型,返回分红区间 |
| `eg` | any | 假设当前时间为20240301,截止日为20230523时:当QKType=0时,返回20230101到20231231之间的全部交易日的分红预测,当QKType=1时,返回20230101到20241231之间的全部交易日的分红预测。 |
| `detail_t` | array | 返回成分股分红点数预测详情 |
返回:array
## `tsExpertClientConfig()`
客户端行为控制函数相关函数。
返回:any
## `table(t)`
依据数组类型返回不同的值。
| 参数 | 类型 | 说明 |
| ---- | ----- | ---------------- |
| `t` | array | 数据表类型,数组 |
返回:array
## `mdo(function_name, in1, in_n)`
单返回值的MATLAB函数调用。
| 参数 | 类型 | 说明 |
| --------------- | ------ | ---------------------------------------------------------- |
| `function_name` | string | 函数名称。 |
| `in1` | any | MatLab函数所需的第一个参数,与MATLAB的函数定义相同,可省略 |
| `in_n` | any | MatLab函数所需的第N个参数,与MATLAB的函数定义相同,可省略 |
返回:any
## `mdo2(function_name, n, out1, out_n, in1, in_n)`
多个返回值的MATLAB函数调用。
| 参数 | 类型 | 说明 |
| --------------- | ------- | ---------------------------------------------------------- |
| `function_name` | string | 函数名称。 |
| `n` | integer | 返回值的个数。 |
| `out1` | any | 返回值存贮的第一个参数,可省略。 |
| `out_n` | any | 返回值存贮的第N个参数,可省略。 |
| `in1` | any | MatLab函数所需的第一个参数,与MATLAB的函数定义相同,可省略 |
| `in_n` | any | MatLab函数所需的第N个参数,与MATLAB的函数定义相同,可省略 |
返回:any
## `menablefmarray(level)`
设置Matlab数据转换成天软fmarray的模式
| 参数 | 类型 | 说明 |
| ------- | ------- | ----------------------------------- |
| `level` | integer | 可选参数,转换模式等级,缺省值为1。 |
返回:any
### 示例
范例代码:
```tsl
t := createMatrix(3, 4, array('s', 'd', 'f'), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
rdo2 mPutVar("A", t);
rdo2 mPutVar("B", 2);
rdo2 mEval("C=A+B");
return rdo2 mGetVar("C");
// 场景一:不设置Menablefmarray
// 不修改上述范例代码,结果如下:
// 场景二:设置Menablefmarray值为0
上述范例代码前加上"rdo2 Menablefmarray(0);",结果如下:
// 场景三:设置Menablefmarray值为1
上述范例代码前加上"rdo2 Menablefmarray(1);",结果如下:
```
## `blpCall(options, svc_url, request, call_back)`
需要安装了彭博API
| 参数 | 类型 | 说明 |
| ----------- | ------ | --------------------------------------------------------------------------------------------------------- |
| `options` | array | 字符串下标的数组,会话的选项,下标值定义如下: |
| `svc_url` | string | 服务URL串,一般以//blp/开头,具体含义请参照BLP的手册或者文档。 |
| `request` | string | 请求的名字,"subscription"特指订阅,其他请看服务支持创建的request种类。 |
| `call_back` | string | 可选,如果设置为字符串,则是指定的回调函数。目前仅支持同步模式,也就是说在BLPCall函数执行过程中进行回调。 |
返回:any
## `tenantCall(session_key, call_name, param, timeout)`
平台中通过租户方式调用指定功能
| 参数 | 类型 | 说明 |
| ------------- | ---------------- | ---- |
| `session_key` | string | |
| `call_name` | string | |
| `param` | array,tablearray | |
| `timeout` | integer | |
返回:any
### 示例
```tsl
// 租户设置如下:
// 注:以下示例仅供参考,不可直接复制使用;用户需结合自身信息进行对应修改
session_key := "{58DC***DF58}";
call_name := "HQData";
param := array("SH000001", 20260325T, cy_day());
return tenantCall(session_key, call_name, param);
// 输出:
// Execute script error at Line:6
// function:__main__:line 6:instruction:usercall: function:tenantCall compile error or not found
// function:__main__:line 6:instruction:usercall: function execute error
```
## `fu()`
字符串,用户名
返回:any
## `fs()`
字符串,租户Session Key;使用特殊租户(调用功能列表为\*)替代用户时指定。
返回:any
## `waitMessage(timeout)`
注册OPS服务,通过分段模式接收天软远端转发的请求数据
| 参数 | 类型 | 说明 |
| --------- | ------- | -------------- |
| `timeout` | integer | 请求超时毫秒数 |
返回:bool
## `doOnMessage(id, event, data)`
虚方法,根据event类型,对事件进行处理;若未指定FonMessage,需重写该方法
| 参数 | 类型 | 说明 |
| ------- | ------- | -------------------------------------------------------------------------------------------------- |
| `id` | integer | 事件id,当事件类型为connect、cancel时,id为nil |
| `event` | string | 事件类型;主要事件类型:connect、call、subscription、cancel |
| `data` | string | Json格式数据;当事件类型为connect时,仅包括opsid,为call、subscription时,包括name、params等信息。 |
返回:any
## `doMessage(value)`
解析接收到的天软远端转发的请求数据
| 参数 | 类型 | 说明 |
| ------- | ------ | ------------------------------------------------------------ |
| `value` | string | 接收到的天软远端转发的请求数据,包括id、event、data、retry等 |
返回:any
## `fopsList()`
字符串,要注册的OPS服务列表,多个服务之间用逗号分隔
返回:any
## `fopsName()`
字符串,注册的TS-OPS服务名称,用于标识,可为空字符串
返回:any
## `fSubCallBack()`
字符串或函数指针,subscription事件回调函数;未指定时,必须重写WaitSubscription方法
返回:any
## `fReturnRuntimeError()`
布尔值,默认值为False;调用回调函数出错时,是否返回详细的报错信息
返回:any
## `fDebug()`
布尔值,默认值为True;是否打印调试信息
返回:any
## `waitSubscription(name, param, realdata)`
虚方法,TS-OPS服务端subscription事件处理函数;若未指定FSubCallBack,则必须重写该方法
| 参数 | 类型 | 说明 |
| ---------- | ----------------- | ---- |
| `name` | string\|tfunction | |
| `param` | array | |
| `realdata` | array | |
返回:array,tablearray
## `asyncCall(durl, id, opsid, realdata, u, p, s, runerror, debug, sub, cb, caller)`
call、subscription事件类型处理方法。根据参数sub判断是call还是subscription事件类型,并调用ops服务端的事件处理方法,调用完成后将结果上传至服务器,最终返回给请求方
| 参数 | 类型 | 说明 |
| ---------- | ----------------- | ---- |
| `durl` | string | |
| `id` | integer | |
| `opsid` | string | |
| `realdata` | array | |
| `u` | string | |
| `p` | string | |
| `s` | string | |
| `runerror` | bool | |
| `debug` | bool | |
| `sub` | bool | |
| `cb` | string\|tfunction | |
| `caller` | string | |
返回:bool
## `tsCanGrid()`
获得当前用户是否具备网格计算的权限。
返回:bool
## `isBackGround()`
获得当前运行的模型是否以委托执行的后台模式运行。
返回:bool
## `testTable(name, table_type)`
检查数据是否存在,测试是否存在指定name的数据,如果TableType为真则为测试系统数据表,即测试系统账号system是否存在name指定的数据;TableType缺省或为0
| 参数 | 类型 | 说明 |
| ------------ | ------ | ---------------------------------------------------------------------------- |
| `name` | string | 字符串,数据存储位置的名称; |
| `table_type` | bool | BOOL类型,可省略,当为假或者省略的时候,装入的为当前用户表,否则装入系统表。 |
返回:bool
### 示例
```tsl
return testTable('testA'); // 测试用户数据"testA"是否存在。返回值为1,即存在,0即不存在。
```
## `Gu_SimpleDataTransform(mtype, nodatecol)`
时序数据简单处理变形,譬如:累加、累乘、单期转多期。基于列名(含截止日、日期、date),跳过日期列 注意:该函数主要用于客户端结果处理,不提供给用户程序编辑。
| 参数 | 类型 | 说明 |
| ----------- | ---- | ------------------- |
| `mtype` | any | 用户自定义,处理方式 |
| `nodatecol` | bool | object |
返回:array
## `Gu_ExtractResultData()`
穿透展示数组,用于展示<量化分析>结果专用嵌套数组结构的分析结果,结构为「键名:数组值」的键值对格式,支持一维/二维数组嵌套 注意:该函数主要用于客户端结果处理,不提供给用户程序编辑。
返回:array
## `tsplot_PerformanceSummary(rt_data, tmplate, fname_endt, fname_pfname, fname_bmname, otherconfig)`
根据单期净值收益率数据表绘制策略报告
| 参数 | 类型 | 说明 |
| -------------- | ------ | ---------------------------------------------------------------------------------------------------------------- |
| `rt_data` | array | 二维字符串数组,收益率(%)序列 |
| `tmplate` | string | 字符串,模板编号;nil,默认: ABSG1_BM(两图:组合+基准+回撤)absg2: ABSG2_BM(三图:组合/基准/超额+超额回撤+超额月度) |
| `fname_endt` | string | 字符串,字段名\_截止日 |
| `fname_pfname` | string | 字符串,字段名\_组合 |
| `fname_bmname` | string | 字符串,字段名\_基准 |
| `otherconfig` | string | 字符串,预留参数 |
返回:array
## `tssubplot_lines(data, fname_subplots, fname_date, fname_infos, dict_indicator)`
时序数据多子图折线图批量绘制函数,按分组配置自动生成多组折线子图,自动处理时间格式化、数据列重命名、信息列合并,适用于多指标可视化对比 注意:如果数值窗口 遮挡,可以 设为浮点,任意放大,再固定,即可(2026-04-09 xqx 应为bug.) 增加右侧展示字段后,首图会缺失一个图例 (2026-04-13 xqx 应为bug.
| 参数 | 类型 | 说明 |
| ---------------- | -------- | -------------------- |
| `data` | array | 整数, |
| `fname_subplots` | any | 整数, |
| `fname_date` | datetime | 整数, |
| `fname_infos` | any | 整数, |
| `dict_indicator` | any | 整数,Metrics概览指标 |
返回:array