Files
playbook/skills/tsl-api-reference/references/codegen/dotnet/datawarehouse/period_series.md
T
csh e1f7ce052c feat(skills): add tsl api reference skill
Bundle the TSL API index and markdown references under the skill, route TSL docs to use it, and update the codegen index generator to maintain the bundled data.
2026-07-07 16:36:15 +08:00

43 KiB
Raw Blame History

数据仓库 / 周期序列

analyseStockArr(b_kname, stocks)

板块BKname序列添加股票Stocks。

参数 类型 说明
b_kname string 市场和板块,板块名称
stocks array 字符串,证券代码,证券代码间以分号分隔,如 ID1;ID2;ID3...

返回:any

avgOfNDay(exp, n)

返回表达式Exp指标连续N个周期的平均值,交易日序列以上证指数的交易日为基础,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return AvgOfNDay(@close(),5);

avgOfPeriod(exp, begdate, enddate)

返回当前从开始日BegDate到截止日EndDate表达式Exp的指标平均值,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
begdate datetime 日期,开始日期
enddate datetime 日期,截止日期

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return AvgOfPeriod(@close(),20180801T,20180802T);

avgOfSector(exp, mode, shares_day, list_day, s_type, sample_select, eps_criterion, except_no_trade)

板块平均。对指定板块按照一定标准进行选股后,对板块下每一只股票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 object

返回:float

avgOfSectorExceptNoTrade(exp, mode)

返回当前板块当前时间存在交易股票指标Exp的平均值,其中Mode决定返回的平均类型,与系统参数(板块,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
mode int 用户自定义,平均模式

返回:float

示例

SetSysParam(pn_bk(),'安徽');
SetSysParam(pn_date(),20180801t);
return AvgOfSectorExceptNoTrade(@close(),0);

continuedMatchOfPeriod(exp, beg_date)

取Begdate到Enddate的交易日序列,如果在交易日序列Expr指标存在值则返回1,否则返回0。

参数 类型 说明
exp Expr 布尔公式表达式
beg_date datetime 日期,开始日期;EndYear:日期,截止日期

返回:bool

示例

SetSysParam(pn_stock(),'SZ000001');
return ContinuedMatchOfPeriod(@close(),20180801T,20180803T);

correlOfNDay2(exp, n, base_id)

表达式N日相关系数(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return CorrelOfNDay2(@close(),10,"SH000001");

correlOfPeriod(exp, beg_date, end_date, base_id)

表达式区间相关系数(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return CorrelOfPeriod(@close(),20230901T,20231010T,"SH000001");

covOfNDay(exp, n, base_id)

表达式N日协方差(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return CovOfNDay(@close(),10,"SH000001");

covOfPeriod(exp, beg_date, end_date, base_id)

表达式区间协方差(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return CovOfPeriod(@close(),20230901T,20231010T,"SH000001");

cyFreeCycle(n)

指定秒数的自由滚动周期

参数 类型 说明
n any 整数,指定的滚动秒数。

返回:any

cyTrailingDays(n)

指定交易日数的自由滚动周期

参数 类型 说明
n any 整数,指定的滚动交易日数。

返回:string

cyTrailingSeconds(n)

指定秒数的自由滚动周期

参数 类型 说明
n any 整数,指定的滚动秒数,秒数应超过4*3600也就是4个小时以内。

返回:string

decayAvgOfNDay(exp, n, cache_str)

N日线性衰减加权平均,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串。统计表达式
n int 整数。天数
cache_str string 字符串。缓存串

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return DecayAvgOfNDay(@close(),5);

derivative1(f, n)

指标技术趋势,返回N个时间点前连续三个周期的指标Expr变化趋势,与当前系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
f Expr 函数表达式,指标
n int 整数,日期偏移

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801T);
return Derivative1(@close(),0);//指标值为收盘价

derivative2(a)

指标技术加速度,返回4个周期的指标Expr变化趋势,与当前系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
a Expr 函数表达式

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801T);
return Derivative2(@close());//指标值为收盘价

filterSampleByCriterionWiz(stock_arr, list_day, sample_select, eps_criterion, eps_day)

按照一定的标准过滤计算板块指标的股票,标准由SampleSelect与EPSCriterion确定。其中亏损股为当前时间之前最近一期报告期每股收益(摊薄)*12/报告期所在月份<0,停牌股为当前时间之前最近一期报告期每股收益(摊薄)*12/报告期所在月份<EPSCriterion,与系统参数(股票,周期)相关。

参数 类型 说明
stock_arr array 一维字符串数组,股票列表
list_day datetime 整数,上市日约束
sample_select any 用户自定义,样本股选择
eps_criterion float 实数,绩差股标准。每股收益(摊薄)<EPSCriterion即表示绩差股
eps_day datetime 整数型日期,收益计算日

返回:any

growthOfNDay(exp, n, return_type)

返回表达式Exp在N个周期指标的增长,其中returnType决定增长显示的类别,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数
return_type int 用户自定义,返回类型

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return GrowthOfNDay(@close(),5,0);

growthOfPeriod(exp, beg_date, end_date, returntype)

从Begdate到Enddate之间Expr指标的增长,增长模式由Returntype决定,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 布尔公式表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
returntype int 用户自定义,返回类型

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return GrowthOfPeriod(@close(),20180801T,20180803T,1);

growthWithHighestOfNDay(exp, n, return_type)

表达式N日最大与当前的偏离,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
return_type int 整数,返回类型

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return GrowthWithHighestOfNDay(@close(),100,0);

growthWithLowestOfNDay(exp, n, return_type)

表达式N日最小与当前的偏离,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
return_type int 整数,返回类型

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return GrowthWithLowestOfNDay(@close(),100,0);

hhvBarsOfNDay(exp, n, cache_str)

N日最高点到当前的周期数。N日表示市场交易日,当日最低为0。注:剔除非交易日(停牌或未上市)数据指标。

参数 类型 说明
exp string 字符串。统计表达式
n int 整数。天数
cache_str string 字符串。缓存串

返回:int

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return HHVBarsOfNDay(@close(),10,"");

hhvBarsOfPeriod(exp, beg_date, end_date)

表达式区间最高点到当前的周期数

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return HHVBarsOfPeriod(@close(),20230101T,20231010T);

highestOfNDay(exp, n)

返回连续N个周期表达式Exp指标值的最大值,交易日序列以上证指数的交易日为基础,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return HighestOfNDay(@close(),5);

highestOfPeriod(exp, beg_date, end_date)

返回当前从开始日Begt到截止日Endt表达式Exp的指标的最大值,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
beg_date datetime 日期,开始日
end_date datetime 日期,截止日

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return HighestOfPeriod(@close(),20180801T,20180802T);

interceptofNday(exp1, exp2, n, cache_str)

N日线性回归截距项,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp1 string 字符串。因变量表达式
exp2 string 字符串。自变量表达式
n int 整数。交易日天数
cache_str string 字符串。缓存字段

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return interceptofNday(@close(),@open(),100,"");

interceptOfNDay2(exp, n, base_id)

表达式N日回归截距(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return InterceptOfNDay2(@close(),10,"SH000001");

interceptOfPeriod(exp, beg_date, end_date, base_id)

表达式区间回归截距(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return InterceptOfPeriod(@close(),20230901T,20231010T,"SH000001");

kurtosisOfNDay(exp, n)

表达式N日峰度,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return KurtosisOfNDay(@close(),100);

llvBarsOfNDay(exp, n, cache_str)

N日最低点到当前的周期数。N日表示市场交易日,当日最低为0。注:剔除非交易日(停牌或未上市)数据指标。

参数 类型 说明
exp string 字符串。统计表达式
n int 整数。天数
cache_str string 字符串。缓存串

返回:int

llvBarsOfPeriod(exp, beg_date, end_date)

表达式区间最低点到当前的周期数

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return LLVBarsOfPeriod(@close(),20230101T,20231010T);

lowestOfNDay(exp, n)

返回表达式Exp指标连续N个周期的最小值,交易日序列以上证指数的交易日为基础,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return LowestOfNDay(@close(),5);

lowestOfPeriod(exp, beg_date)

从Begdate到Enddate之间Expr指标的最小值,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 布尔公式表达式
beg_date datetime 日期,开始日期;EndYear:日期,截止日期

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return LowestOfPeriod(@close(),20180801T,20180803T);

medianOfNDay(exp, n)

表达式N日中位数,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return MedianOfNDay(@close(),100);

occuredOfNDay(exp, n)

返回表达式Exp指标连续N个周期发生次数,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数

返回:int

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return OccuredOfNDay(@close(),10);

occuredTimeOfNDay(exp, n)

返回表达式Exp指标值发生前N个时间点的时间序列,与系统参数(股票,时间,周期)相关。

参数 类型 说明
exp any 表达式,函数表达式
n any 整数,天数

返回:any

occuredTimeOfPeriod(exp, beg_date, end_date)

返回BegDate至Endtime之间表达式Exp存在值的时间序列,与系统参数(股票,复权,周期)相关。

参数 类型 说明
exp any 布尔公式表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止时间

返回:any

positionOfSector(exp, sector)

从大到小排名。板块Sector中成分股按个券指标EXP大小排序,返回指定股票pn_stock()的排名,该函数与系统参数(股票,日期,复权,周期)相关。

参数 类型 说明
exp Expr 函数表达式
sector string 市场和板块,板块

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801T);
return PositionOfSector(@close(),'A股');

positionOfSectorDesc(exp, sector)

从小到大排名。板块Sector中按指标EXP大小排序,返回指定股票的排名,与系统参数(股票,日期,复权,周期)相关。

参数 类型 说明
exp Expr 函数表达式
sector string 市场和板块,板块

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801T);
return PositionOfSectorDesc(@close(),'A股');

queryWithPeriod(market_list, stock_id_list, condition, field_name1, expression1, field_name2, expression2, field_name_n, expression_n)

取证券一段时间的时间序列数据(行情、净值等)

参数 类型 说明
market_list string 字符串,板块名称列表;
stock_id_list bool 字符串,股票代码列表
condition string 布尔型,选股条件;
field_name1 expr 字符串,字段名称1
expression1 string 函数,函数表达式1
field_name2 expr 字符串,字段名称2
expression2 string 函数,函数表达式2;;…
field_name_n expr 字符串,字段名称N
expression_n string 函数,函数表达式N。

返回:float

示例

oV:=BackUpSystemParameters2();
setsysparam(pn_begt(),inttodate(20120801));
setsysparam(pn_endt(),inttodate(20121001));
setsysparam("TimeIndex",1);
return
QueryWithPeriod("","SZ000002;SZ000001;SH600000;SH600004",@True,"","收盘价",@close(),
"成交量",@vol(),
"成交金额",@amount());

rd(id)

取得实时数据,就是当前最近的数据,主要用于盘中分析,委托5-10为LEVEL2行情专用。该函数与当前时间,当前周期无关,只与当前证券代码有关。

参数 类型 说明
id int 整数,含义如下:

返回:any

示例

setsysparam(pn_stock(),'SZ000002');
rds := array(datetimetostr(sp_time()),
rd(0),//股票代码
rd(1),//股票名称
rd(2),//开盘价
rd(3) //昨收
);
return rds;

refValue(exp, n)

返回表达式Exp在前N个交易日的指标值,以市场交易日为准往前推N个交易日,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 表达式,函数表达式
n int 整数,天数

返回:float

示例

返回上证指数在2018年7月18号的收盘价
SetSysParam(pn_stock(),'SH000001');
SetSysParam(pn_date(),20180801t);
return RefValue(@close(),10);

relativeStrengthOfSector(exp, sector)

系统当前证券在板块中的相对强弱(%)。系统当前证券pn_stock()在指定板块Sector中的指标Exp值的从大到小的排位百分比。该函数与系统参数(股票,日期,复权,周期)相关。

参数 类型 说明
exp Expr 函数表达式
sector string 市场和板块,板块

返回:float

示例

SetSysParam(pn_stock(),'SH000300');
SetSysParam(pn_date(),20180801T);
return RelativeStrengthOfSector(@stockzf3(),'A股');

relativeStrengthOfSectorDesc(exp, sector)

系统当前证券在板块中的相对强弱(%)。系统当前证券pn_stock()在指定板块Sector中的指标Exp值的从小到大的排位百分比。该函数与系统参数(股票,日期,复权,周期)相关。

参数 类型 说明
exp Expr 函数表达式
sector string 市场和板块,板块

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801T);
return RelativeStrengthOfSectorDesc(@close(),'A股');

rsqOfNDay(exp, n, base_id)

表达式N日相关系数平方(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return RSQOfNDay(@close(),10,"SH000001");

rsqOfPeriod(exp, beg_date, end_date, base_id)

表达式区间相关系数平方(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return RSQOfPeriod(@close(),20230901T,20231010T,"SH000001");

sectionSubmitBuyVol()

当天截止累计委买量,与系统参数(股票、时间、周期、复权等相关),查看相关行情数据说明

返回:float

skewnessOfNDay(exp, n)

表达式N日偏度,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return SkewnessOfNDay(@close(),100);

slopeOfNDay2(exp, n, base_id)

表达式N日回归斜率(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return SlopeOfNDay2(@close(),10,"SH000001");

slopeOfPeriod(exp, beg_date, end_date, base_id)

表达式区间回归斜率(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return SlopeOfPeriod(@close(),20230901T,20231010T,"SH000001");

stdOfNDay(exp, n)

返回连续N个周期的表达式Exp指标值的标准差,交易日序列以上证指数的交易日为基础,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return StdOfNDay(@close(),5);

steyxOfNDay(exp, n, base_id)

表达式N日标准偏差(双序列) ,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return SteyxOfNDay(@close(),10,"SH000001");

steyxOfPeriod(exp, beg_date, end_date, base_id)

表达式区间标准偏差(双序列)

参数 类型 说明
exp string 字符串,函数表达式
beg_date datetime 日期,开始日期
end_date datetime 日期,截止日期
base_id string 字符串,基准证券代码

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
return SteyxOfPeriod(@close(),20230901T,20231010T,"SH000001");

sumifofNday(exp, n, condition, cache_astr)

N日条件求和,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串。统计表达式
n int 整数。N日
condition string 字符串。条件表达式
cache_astr string 字符串。缓存串

返回:float

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231030T);
return SumifofNday(@open(),30,"@open()>@close()","");

sumOfNDay(exp, n)

返回表达是Exp指标值在N个周期内的求和,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 表达式
n int 整数,天数

返回:float

示例

计算平安银行截止2018年8月1日最近10个交易日的成交量和
SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return SumOfNDay(@vol(),10);

sumOfPeriod(v, beg_t, end_t)

返回当前从开始日Begt到截止日Endt表达式Exp的指标和,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
v Expr 函数表达式
beg_t datetime 日期,开始日
end_t datetime 日期,截止日

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return SumOfPeriod(@close(),20180801T,20180802T);

sumOfSector(exp, shares_day, list_day, s_type, sample_select, eps_criterion, except_no_trade)

对指定板块按照一定标准进行选股后,对板块下每一只股票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 object

返回:float

示例

setsysparam(pn_bk(),"上证A股");
setsysparam(Pn_date(),20180801T);
return SumOfSector(@close(),20180801T,20180801T,1,0,0,0);

sumOfSectorExceptNoTrade(exp)

返回当前板块当前时间存在交易股票指标Exp的和,与系统参数(板块,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式

返回:float

示例

SetSysParam(pn_bk(),'安徽');
SetSysParam(pn_date(),20180801t);
return SumOfSectorExceptNoTrade(@close());

swingOfNDay(exp, n, return_type)

返回表达式Exp在N个周期指标的振幅,其中returnType决定振幅显示的模式,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
n int 整数,天数
return_type int 用户自定义,返回类型

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
SetSysParam(pn_date(),20180801t);
return SwingOfNDay(@close(),5,0);

swingOfPeriod(exp, beg_date, end_date, re_turn_type)

返回当前从开始日Begt到截止日Endt表达式Exp的指标区间振幅,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
beg_date datetime 日期,开始日
end_date datetime 日期,截止日
re_turn_type int 用户自定义,返回类型

返回:float

示例

SetSysParam(pn_stock(),'SZ000001');
return SwingOfPeriod(@close(),20180801T,20180802T,0);

td(id)

返回当前时间指定的交易明细数据。必须设置当前周期为小于日线的高频周期。

参数 类型 说明
id int 整数,字段标识

返回:any

示例

setsysparam(pn_stock(),'SZ000002');
setsysparam(PN_Cycle(),cy_10s());
setsysparam(pn_date(),strtodatetime('2011-09-09 14:15:33'));
tds := array(
datetimetostr(td(0)),//时间
td(1),//价格
td(2),//成交金额
td(3) //成交量
);
return tds;

timeOfHighestOfNDay(exp, n)

表达式N日最高时间,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数

返回:string

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return TimeOfHighestOfNDay(@close(),100);

timeOfHighestOfPeriod(exp, beg_date, end_date)

返回当前从开始日BegDate到截止日EndDate表达式Exp的指标最大值的时间点,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
beg_date datetime 日期,开始日
end_date datetime 日期,截止日

返回:string

示例

SetSysParam(pn_stock(),'SZ000001');
return TimeOfHighestOfPeriod(@close(),20180801T,20180802T);

timeOfLowestOfNDay(exp, n)

表达式N日最低时间,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp string 字符串,函数表达式
n int 整数,天数

返回:string

示例

SetSysParam(pn_stock(),"SH600585");
SetSysParam(pn_date(),20231010T);
return TimeOfLowestOfNDay(@close(),100);

timeOfLowestOfPeriod(exp, beg_t, end_t)

返回当前从开始日Begt到截止日Endt表达式Exp的指标最小值的时间点,与系统参数(股票,日期,周期,复权)相关。

参数 类型 说明
exp Expr 函数表达式
beg_t datetime 日期,开始日
end_t datetime 日期,截止日

返回:string

示例

SetSysParam(pn_stock(),'SZ000001');
returnTimeOfLowestOfPeriod(@close(),20180801T,20180802T);

tradeDays(begin_date, end_date)

得到当前股票在两个日期间的交易日数目。如果参数BeginDate和参数EndDate是同一天而且有交易则为1,如果之间无交易日则为0。 该模型与股票、周期相关。获取开始时间到截止时间的交易日(周期)数。

参数 类型 说明
begin_date datetime TDateTime类型,开始时间
end_date datetime TDateTime类型,结束时间

返回:int

示例

setsysparam(pn_stock(),'SZ000002');
return tradeDays(inttodate(20100101), inttodate(20101231));//返回:240

tsPeriod(stock_id, cycle, date)

返回指定证券指定日期的指定周期时间序列。如有夜盘,包含昨日夜盘数据。

参数 类型 说明
stock_id string 字符串,证券代码,支持所有类型证券(包括已退市)
cycle string 秒线和分钟线级别周期,支持半秒线和自由周期
date datetime 日期或日期时间,任意自然日。自由周期下,支持传入具体时间作为自由周期基准时间点。

返回:array

nDay2(field0, expression0, field1, expression1, field_m, expression_m)

同NDay类似,只是没有参数N,默认180天,用户可以通过系统参数 pn_nDay进行设定天数。和当前的股票,周期,时间等系统参数相关。详细说明也可参考nday

参数 类型 说明
field0 String string 字段名
expression0 texpression 表达式,跟Field0相对应
field1 String string字段名
expression1 texpression 表达式,跟Field1相对应
field_m String string字段名
expression_m texpression 表达式,跟FieldM相对应

返回:tablearray

示例

//用NDAY2取得万科截止20110909前30个交易日的若干行情信息;
setSysParam(pn_stock(),'SZ000002');
setSysParam(pn_date(), intToDate(20110909));
setSysParam(pn_nDay(),30);
return nDay2('时间',dateTimeToStr(sp_time()),
'收盘价',close(),
'当日高价',high(),
'30日均线',ma(close(),30));
返回结果(部分)

nDay3(n, expression)

提取或计算N个交易日的Expression数据。和当前的股票,周期,时间等系统参数相关。与Nday的区别即该函数仅能提取一个表达式Expression的数据,返回值为一维数组;而Nday可以提取多个,返回值为二维数组。

参数 类型 说明
n Integer 整数,交易日个数
expression texpression 表达式.

返回:array

示例

//取得万科截止20110909前30个交易日的价格序列(按交易日升序排列)
setSysParam(pn_stock(),'SZ000002');
setSysParam(pn_date(), intToDate(20110909));
return nDay3(30,close());
结果:

ref(exp, n)

求N日前Exp的值

参数 类型 说明
exp texpression TExpression型表达式
n Integer 整数,天数

返回:any

示例

setSysParam(pn_stock(),'SZ000002');
setSysParam(pn_date(), intToDate(20110909));
r := array();
r := array('设定日价格':close(),//20110909
'设定日前1交易日收盘':ref(close(),1),//20110908
'设定日后1交易日收盘':ref(close(),-1));//20110913
return r;
结果:

specDate(exp, date)

设置当前时间的快捷方式,只影响exp表达式。指定Date时间为当前时间,计算表达式Exp的值返回。

参数 类型 说明
exp TExpression 表达式
date tdatetime 日期类型

返回:any

示例

setSysParam(pn_stock(),'SZ000002');
setSysParam(pn_date(), intToDate(20110909));
return nDay(30,'date',dateToStr(sp_time()),
'close',close(),
//使用年初价格作为参照。
'close_20110101',specDate(close(),intToDate(20110101)));
结果(部分)

spec(exp, stock_id)

设置当前股票的快捷方式,只影响Exp表达式。指定StockID股票为当前股票,计算表达式的值返回

参数 类型 说明
exp TExpression TExpression型表达式
stock_id string 字符串类型

返回:any

示例

//获得两个指数时间序列净值曲线
setSysParam(pn_stock(),'SH000904');
setSysParam(pn_date(), intToDate(20110909));
n := 30;
beg_close1 := ref(close(),n-1);//SH000904 N日前收盘
beg_close2 := spec(ref(close(),n-1),'SH000300');//SH000300 N日前收盘
return nDay(n,'date',dateToStr(sp_time()),
'中证200',1000*close()/beg_close1,
'沪深300',1000*spec(close(),'SH000300')/beg_close2);
结果(部分)

specAll(exp, sys_param)

指定特定的系统参数计算表达式的值返回

参数 类型 说明
exp TExpression TExpression型表达式
sys_param array 数组形式,以系统参数名为下标参数值为值类型的数组。

返回:any

示例

return specAll(close(),
array(pn_stock():'SZ000001',
pn_date():intToDate(20140117),
pn_rate():1,
pn_rateday():-1));
//获取SZ000001的2014年01月17日的复权价格,复权方式为比例复权,复权基准日为上市日。

hdNDay3(day_count)

NDay3函数教学函数,返回DayCount个数的日期时间。与系统参数(股票、时间、周期相关)。

参数 类型 说明
day_count any 整数

返回:any

hdNDay(day_count)

NDay函数教学函数,返回DayCount个数开盘价、收盘价、最高价、最低价、日期时间。与系统参数(股票、时间、周期、复权等相关)。

参数 类型 说明
day_count any 整数

返回:any

hdSpec(id)

Spec函数教学函数,返回指定股票收盘价。与系统参数(时间、周期、复权等相关)。

参数 类型 说明
id string 证券

返回:float

hdSpecDate(endt)

SpecDate函数教学函数,返回指定日期时间的最高价。与系统参数(股票、周期、复权等相关)。

参数 类型 说明
endt datetime 日期

返回:float

hdSpecAndSpecDate(id, days, endt)

Spec函数与SpecDate函数结合教学函数,返回指定股票ID到截止日Endt前Days个最高价中的最大者。与系统参数(周期、复权等相关)。

参数 类型 说明
id string 证券
days any 整数
endt datetime 日期

返回:float