Files
playbook/skills/tsl-api-reference/references/codegen/dotnet/datawarehouse/wizard.md
T
csh 9010829c6d feat(tsl-api-reference): expand and reorganize api catalog
Flatten builtin pages, add third-party and platform scopes, and import financial and data warehouse references.

Keep the existing generated index without rebuilding after signature normalization.
2026-08-10 18:26:24 +08:00

301 lines
10 KiB
Markdown

# 数据仓库 / 向导函数
## `avgOfSector(exp, mode, shares_day, list_day, s_type, sample_select, eps_criterion, except_no_trade)`
声明:function
板块平均。对指定板块按照一定标准进行选股后,对板块下每一只股票Exp表达式的指标值按mode求平均,选股标准由SampleSelect与EPSCriterion确定。其中亏损股为当前时间之前最近一期报告期每股收益(摊薄)\*12/报告期所在月份<0,停牌股为当前时间之前最近一期报告期每股收益(摊薄)\*12/报告期所在月份<EPSCriterion,与系统参数(股票,周期)相关
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------------------------------------------------------------ |
| `exp` | expr | 函数表达式 |
| `mode` | int | 用户自定义,平均模式 |
| `shares_day` | datetime | 日期,收益计算日 |
| `list_day` | datetime | 日期,在之前上市 |
| `s_type` | int | 用户自定义,股票类型 |
| `sample_select` | int | 用户自定义,样本股选择 |
| `eps_criterion` | float | 实数,绩差股标准。每股收益(摊薄)<EPSCriterion即表示绩差股 |
| `except_no_trade` | bool | 真假,剔除停牌股 |
返回:float
### 示例
范例01:返回:12.27
```tsl
return AvgOfSector(@close(), 2, 20180801T, 20180801T, 1, 0, 0, 0);
// 输出:12.27
```
## `derivative1(f, n)`
声明:function
指标技术趋势,返回N个时间点前连续三个周期的指标Expr变化趋势,与当前系统参数(股票,日期,周期,复权)相关
| 参数 | 类型 | 说明 |
| ---- | ---- | --------------- |
| `f` | expr | 函数表达式,指标 |
| `n` | int | 整数,日期偏移 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
SetSysParam(pn_date(), 20180801T);
return Derivative1(@close(), 0); // 指标值为收盘价
```
## `derivative2(a)`
声明:function
指标技术加速度,返回4个周期的指标Expr变化趋势,与当前系统参数(股票,日期,周期,复权)相关
| 参数 | 类型 | 说明 |
| ---- | ---- | ---------- |
| `a` | expr | 函数表达式 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
SetSysParam(pn_date(), 20180801T);
return Derivative2(@close()); // 指标值为收盘价
```
## `growthWithLowestOfPeriod(exp, beg_date, end_date, return_type)`
声明:function
返回表达式Exp在区间BegDate到EndDate中的最小值与在EndDate的值的偏离,ReturnType决定返回偏离值(增加值)还是偏离率(增速%)
| 参数 | 类型 | 说明 |
| ------------- | -------- | -------------------- |
| `exp` | expr | 函数表达式 |
| `beg_date` | datetime | 日期,开始日 |
| `end_date` | datetime | 日期,截止日 |
| `return_type` | int | 用户自定义,返回类型 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
return GrowthWithLowestOfPeriod(@close(), 20180801T, 20180903T, 0);
```
## `positionOfSector(exp, sector)`
声明:function
从大到小排名。板块Sector中成分股按个券指标EXP大小排序,返回指定股票pn_stock()的排名,该函数与系统参数(股票,日期,复权,周期)相关
| 参数 | 类型 | 说明 |
| -------- | ------ | ---------------- |
| `exp` | expr | 函数表达式 |
| `sector` | string | 市场和板块,板块 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
SetSysParam(pn_date(), 20180801T);
return PositionOfSector(@close(), 'A股');
```
## `positionOfSectorDesc(exp, sector)`
声明:function
从小到大排名。板块Sector中按指标EXP大小排序,返回指定股票的排名,与系统参数(股票,日期,复权,周期)相关
| 参数 | 类型 | 说明 |
| -------- | ------ | ---------------- |
| `exp` | expr | 函数表达式 |
| `sector` | string | 市场和板块,板块 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
SetSysParam(pn_date(), 20180801T);
return PositionOfSectorDesc(@close(), 'A股');
```
## `reduceWithHighestOfPeriod(exp, beg_date, end_date, return_type)`
声明:function
返回表达式Exp在区间BegDate到EndDate中的最大值与在EndDate的值的偏离,ReturnType决定返回偏离值(增加值)还是偏离率(增速%)
| 参数 | 类型 | 说明 |
| ------------- | -------- | -------------------- |
| `exp` | expr | 函数表达式 |
| `beg_date` | datetime | 日期,开始日 |
| `end_date` | datetime | 日期,截止日 |
| `return_type` | int | 用户自定义,返回类型 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
return ReduceWithHighestOfPeriod(@close(), 20180801T, 20180803T, 0);
```
## `relativeStrengthOfSector(exp, sector)`
声明:function
系统当前证券在板块中的相对强弱(%)。系统当前证券pn_stock()在指定板块Sector中的指标Exp值的从大到小的排位百分比。该函数与系统参数(股票,日期,复权,周期)相关
| 参数 | 类型 | 说明 |
| -------- | ------ | ---------------- |
| `exp` | expr | 函数表达式 |
| `sector` | string | 市场和板块,板块 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SH000300');
SetSysParam(pn_date(), 20180801T);
return RelativeStrengthOfSector(@stockzf3(), 'A股');
```
## `relativeStrengthOfSectorDesc(exp, sector)`
声明:function
系统当前证券在板块中的相对强弱(%)。系统当前证券pn_stock()在指定板块Sector中的指标Exp值的从小到大的排位百分比。该函数与系统参数(股票,日期,复权,周期)相关
| 参数 | 类型 | 说明 |
| -------- | ------ | ---------------- |
| `exp` | expr | 函数表达式 |
| `sector` | string | 市场和板块,板块 |
返回:float
### 示例
范例01:调用函数
```tsl
SetSysParam(pn_stock(), 'SZ000001');
SetSysParam(pn_date(), 20180801T);
return RelativeStrengthOfSectorDesc(@close(), 'A股');
```
## `stockTrailingAvgByEndT(endt, ref_type, exp, is_exclude_ipo, n)`
声明:function
获取基于指定日推移阶段的日均指标
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | --------------------------------------------- |
| `endt` | datetime | 日期,截止日 |
| `ref_type` | user_define | 用户自定义,选择所推移类型,取值如下: |
| `exp` | string | 字符串, 指标表达式,如"close()","stockzdf3()" |
| `is_exclude_ipo` | bool | 真假, 是否剔除上市日区间行情 |
| `n` | int | 整数, 剔除天数 |
返回:float
### 示例
范例01:调用函数
```tsl
获取万科A过去1年的日均成交金额
setsysparam(pn_stock(), "SZ000002");
endt := 20210714t;
RefType := 4; // 过去1年
exp := "Amount()";
return StockTrailingAvgByEndT(Endt, RefType, Exp);
```
## `stockTrailingStdByEndT(endt, ref_type, exp, is_exclude_ipo, n)`
声明:function
获取基于指定日推移阶段的指标标准差
| 参数 | 类型 | 说明 |
| ---------------- | ----------- | --------------------------------------------- |
| `endt` | datetime | 日期,截止日 |
| `ref_type` | user_define | 用户自定义,选择所推移类型,取值如下: |
| `exp` | string | 字符串, 指标表达式,如"close()","stockzdf3()" |
| `is_exclude_ipo` | bool | 真假, 是否剔除上市日区间行情 |
| `n` | int | 整数, 剔除天数 |
返回:float
### 示例
范例01:调用函数
```tsl
获取万科A过去1年的日收益率标准差
setsysparam(pn_stock(), "SZ000002");
endt := 20210714t;
RefType := 4; // 过去1年
exp := "stockzf3()";
return StockTrailingStdByEndT(Endt, RefType, Exp); // 1.69
```
## `sumOfSector(exp, shares_day, list_day, s_type, sample_select, eps_criterion, except_no_trade)`
声明:function
对指定板块按照一定标准进行选股后,对板块下每一只股票Exp表达式的指标值求和. 选股标准由SType、SampleSelect与EPSCriterion确定。 其中亏损股为当前时间之前最近一期报告期每股收益(摊薄)\*12/报告期所在月份<0; 停牌股为当前时间之前最近一期报告期每股收益(摊薄)\*12/报告期所在月份<EPSCriterion,与系统参数(板块,周期,时间)相关
| 参数 | 类型 | 说明 |
| ----------------- | -------- | ------------------------------------------------------------ |
| `exp` | expr | 函数表达式 |
| `shares_day` | datetime | 日期,收益计算日 |
| `list_day` | datetime | 日期,在之前上市 |
| `s_type` | int | 用户自定义,股票类型 |
| `sample_select` | int | 用户自定义,样本股选择 |
| `eps_criterion` | float | 实数,绩差股标准。每股收益(摊薄)<EPSCriterion即表示绩差股 |
| `except_no_trade` | bool | 真假,剔除停牌股 |
返回:float
### 示例
范例01:调用函数
```tsl
setsysparam(pn_bk(), "上证A股");
setsysparam(Pn_date(), 20180801T);
return SumOfSector(@close(), 20180801T, 20180801T, 1, 0, 0, 0);
```