feat(tsl-api-reference): expand API and module coverage

This commit is contained in:
csh
2026-08-14 17:12:55 +08:00
parent 8f1056130d
commit 3d3036ebe1
571 changed files with 47842 additions and 14458 deletions
@@ -1,5 +1,33 @@
# 数据仓库 / 财务函数
## `infoArrayExt(info_id, changed_field_name, changed_value, record_id, ...)`
声明:function
在当前证券的数据表中查找条件字段值不大于指定值的记录,并可返回指定字段
<!-- tags: 数据仓库 财务 数据表 条件查询 记录 字段 InfoArray -->
| 参数 | 类型 | 说明 |
| -------------------- | ------------- | -------------------------------------------------------------- |
| `info_id` | integer | 信息类别 ID |
| `changed_field_name` | string | 用于筛选记录的条件字段名 |
| `changed_value` | real\|integer | 条件字段的上限值 |
| `record_id` | integer | 可选。负数或省略取最后一条,`0` 取第一条,正数按零基序号取记录 |
| `...` | any | 可选。更多按返回字段名、接收返回值变量成对传入的参数 |
返回:array
### 示例
范例01:查询指定股权登记日之前的最后一条记录
```tsl
setSysParam(pn_stock(), "SZ000002");
info_id := databaseInfoArrayId(21);
return infoArrayExt(info_id, "股权登记日", 20130516);
```
## `last12MData(r_date, info_id, get_the_nearest)`
声明:function
@@ -1,5 +1,34 @@
# 数据仓库 / 取行情数据序列函数
## `nDay(n, field_0, expression_0, ...)`
声明:function
提取或计算当前日期向前 `n` 个周期的数据,并按字段名称和表达式组成数据表
<!-- tags: 数据仓库 行情序列 历史数据 NDay 字段 表达式 -->
函数与系统证券、周期和日期参数相关,`field_0``expression_0` 之后可以继续传入任意数量的字段名称和表达式对
| 参数 | 类型 | 说明 |
| -------------- | ------------ | ---------------------------------------------- |
| `n` | integer | 提取的周期数 |
| `field_0` | string | 第一列的字段名称 |
| `expression_0` | t_expression | 第一列的数据表达式 |
| `...` | any | 可选。更多按字段名称、数据表达式成对传入的参数 |
返回:table_array
### 示例
范例01:获取万科 A 最近两个交易日的收盘价
```tsl
setSysParam(pn_stock(), "SZ000002");
setSysParam(pn_date(), 20140115T);
return nDay(2, "close", close());
```
## `nDay2(field_0, expression_0, field_1, expression_1, field_m, expression_m)`
声明:function
@@ -0,0 +1,38 @@
# 数据仓库 / 查询和轮询函数
## `query(market_list, stock_id_list, condition, sort_field, field_name_1, expression_1, ...)`
声明:function
从指定市场和证券列表中筛选满足条件的证券,按指定字段排序并返回选定数据列
<!-- tags: 数据仓库 查询 轮询 选股 市场列表 证券列表 报表 -->
| 参数 | 类型 | 说明 |
| --------------- | ------------ | ---------------------------------------------- |
| `market_list` | string | 以分号分隔的市场或板块列表 |
| `stock_id_list` | string | 以分号分隔的证券代码列表 |
| `condition` | boolean | 选股条件,无条件限制时传入 `true` |
| `sort_field` | string | 排序字段,空字符串表示不指定排序字段 |
| `field_name_1` | string | 第一列的显示名称 |
| `expression_1` | t_expression | 第一列的数据表达式 |
| `...` | any | 可选。更多按字段名称、数据表达式成对传入的参数 |
返回:table_array
### 示例
范例01:查询收盘价高于 10 日均线的证券
```tsl
setSysParam(pn_date(), 20110909T);
return query(
"上证A股;创业板",
"SZ000001;SZ000002;SZ000997",
close() > ma(close(), 10),
"",
"证券代码", defaultStockID(),
"证券名称", currentStockName(),
"收盘价", close()
);
```
@@ -8,11 +8,11 @@
<!-- tags: 数据仓库 向导函数 区间 返回 获取 -->
| 参数 | 类型 | 说明 |
| ---------- | -------- | -------------- |
| `exp` | expr | 函数表达式 |
| `begdate` | datetime | 日期,开始日期 |
| `enddate` | datetime | 日期,截止日期 |
| 参数 | 类型 | 说明 |
| --------- | -------- | -------------- |
| `exp` | expr | 函数表达式 |
| `begdate` | datetime | 日期,开始日期 |
| `enddate` | datetime | 日期,截止日期 |
返回:float
@@ -33,11 +33,11 @@ return AvgOfPeriod(@close(), 20180801T, 20180802T);
<!-- tags: 数据仓库 向导函数 区间 返回 获取 -->
| 参数 | 类型 | 说明 |
| ------------ | ---- | ------------------ |
| `exp` | expr | 函数表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
| 参数 | 类型 | 说明 |
| ----------- | ---- | ------------------ |
| `exp` | expr | 函数表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
返回:int
@@ -392,11 +392,11 @@ return OccuredOfPeriod(@IsUp(), 20230101T, 20231010T);
<!-- tags: 数据仓库 向导函数 区间 返回 获取 -->
| 参数 | 类型 | 说明 |
| ------------ | ---- | ------------------ |
| `exp` | expr | 布尔公式表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
| 参数 | 类型 | 说明 |
| ----------- | ---- | ------------------ |
| `exp` | expr | 布尔公式表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
返回:int
@@ -621,11 +621,11 @@ return SumOfPeriod(@close(), 20180801T, 20180802T);
<!-- tags: 数据仓库 向导函数 区间 返回 获取 -->
| 参数 | 类型 | 说明 |
| ------------ | ---- | ------------------ |
| `exp` | expr | 函数表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
| 参数 | 类型 | 说明 |
| ----------- | ---- | ------------------ |
| `exp` | expr | 函数表达式 |
| `begreport` | int | 报告期,开始报告期 |
| `end_year` | int | 年份,截止年份 |
返回:int
@@ -26,8 +26,11 @@
范例01:返回:12.27
```tsl
return AvgOfSector(@close(), 2, 20180801T, 20180801T, 1, 0, 0, 0);
// 输出:12.27
setSysParam(pn_bk(), "沪深300");
setSysParam(pn_stock(), "SH600000");
setSysParam(pn_cycle(), cy_day());
return avgOfSector(@close(), 2, 20180801T, 20180801T, 1, 0, 0, 0);
// 输出:53.354628
```
## `derivative1(f, n)`
@@ -231,66 +234,70 @@ SetSysParam(pn_date(), 20180801T);
return RelativeStrengthOfSectorDesc(@close(), 'A股');
```
## `stockTrailingAvgByEndT(endt, ref_type, exp, is_exclude_ipo, n)`
## `stockTrailingAvgByEndT(end_t, ref_type, exp, is_exclude_ipo, n)`
声明:function
获取基于指定日推移阶段的日均指标
返回指定证券截至 `end_t` 的推移区间日均指标
<!-- tags: 数据仓库 向导函数 获取 查询 -->
<!-- tags: 数据仓库 向导函数 证券 推移区间 日均值 成交金额 历史统计 -->
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | --------------------------------------------- |
| `endt` | datetime | 日期,截止日 |
| `ref_type` | user_define | 用户自定义,选择所推移类型,取值如下: |
| `exp` | string | 字符串, 指标表达式,如"close()","stockzdf3()" |
| `is_exclude_ipo` | bool | 真假, 是否剔除上市区间行情 |
| `n` | int | 整数, 剔除天数 |
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | ------------------------------------ |
| `end_t` | datetime | 截止日 |
| `ref_type` | user_define | 推移区间类型;`4` 表示过去 1 年 |
| `exp` | string | 指标表达式字符串,如 `'amount()'` |
| `is_exclude_ipo` | bool | 是否剔除上市初期区间行情 |
| `n` | int | 剔除的上市初期天数;不剔除时可传 `0` |
返回:float
依赖系统参数:`pn_stock()`
### 示例
范例01调用函数
范例01计算万科 A 截至 2021-07-14 过去 1 年的日均成交金额
```tsl
获取万科A过去1年的日均成交金额
setsysparam(pn_stock(), "SZ000002");
endt := 20210714t;
RefType := 4; // 过去1年
exp := "Amount()";
return StockTrailingAvgByEndT(Endt, RefType, Exp);
setSysParam(pn_stock(), 'SZ000002');
end_t := 20210714T;
ref_type := 4;
exp := 'amount()';
return stockTrailingAvgByEndT(end_t, ref_type, exp, false, 0);
// 输出:2172484158.52107
```
## `stockTrailingStdByEndT(endt, ref_type, exp, is_exclude_ipo, n)`
## `stockTrailingStdByEndT(end_t, ref_type, exp, is_exclude_ipo, n)`
声明:function
获取基于指定日推移阶段的指标标准差
返回指定证券截至 `end_t` 的推移区间指标标准差
<!-- tags: 数据仓库 向导函数 获取 查询 -->
<!-- tags: 数据仓库 向导函数 证券 推移区间 标准差 收益率 波动 历史统计 -->
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | --------------------------------------------- |
| `endt` | datetime | 日期,截止日 |
| `ref_type` | user_define | 用户自定义,选择所推移类型,取值如下: |
| `exp` | string | 字符串, 指标表达式,如"close()","stockzdf3()" |
| `is_exclude_ipo` | bool | 真假, 是否剔除上市区间行情 |
| `n` | int | 整数, 剔除天数 |
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | ------------------------------------ |
| `end_t` | datetime | 截止日 |
| `ref_type` | user_define | 推移区间类型;`4` 表示过去 1 年 |
| `exp` | string | 指标表达式字符串,如 `'stockzf3()'` |
| `is_exclude_ipo` | bool | 是否剔除上市初期区间行情 |
| `n` | int | 剔除的上市初期天数;不剔除时可传 `0` |
返回:float
依赖系统参数:`pn_stock()`
### 示例
范例01调用函数
范例01计算万科 A 截至 2021-07-14 过去 1 年的日收益率标准差
```tsl
获取万科A过去1年的日收益率标准差
setsysparam(pn_stock(), "SZ000002");
endt := 20210714t;
RefType := 4; // 过去1年
exp := "stockzf3()";
return StockTrailingStdByEndT(Endt, RefType, Exp); // 1.69
setSysParam(pn_stock(), 'SZ000002');
end_t := 20210714T;
ref_type := 4;
exp := 'stockzf3()';
return stockTrailingStdByEndT(end_t, ref_type, exp, false, 0);
// 输出:1.687273
```
## `sumOfSector(exp, shares_day, list_day, s_type, sample_select, eps_criterion, except_no_trade)`