tslediter/tsdata/股票/行情因子/中间函数/StocktTrailingAvgByEndT.tsf

35 lines
1.1 KiB
Plaintext
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.

Function StocktTrailingAvgByEndT(Endt,RefType,Exp,IsExcludeIPO,N);
Begin
{** ======================================================================//
%% @explain(说明):
获取基于指定日推移阶段的日均指标
%% 输入:
%% @param(EndT)(TDateTime) 日期,区间截止日
%% @param(RefType) 用户自定义,选择所推移类型,取值如下:
0: 最近1周
1: 最近1月
...
12:成立以来
%% @param(Exp)(exp) 指标表达式,如@close(),@stockzdf3()
%% @param(IsExcludeIPO)(Bool) 是否剔除上市日区间行情
%% @param(N)(Int) 剔除天数
%% 输出: 值real
%% @remark(更新日志) 2021-07-14 TS业务框架
%%//====================================================================== **}
ov := BackupSystemParameters2();
if ifnil(IsExcludeIPO) then IsExcludeIPO:=0;
if ifnil(N) then N:=1;
setsysparam(pn_date(),endt);
setsysparam(pn_cycle(),cy_day());
begt := StockRefDatebyEndt(Endt,RefType);
ND := tradedays(begt,endt);
if IsExcludeIPO then
begin
MD := tradedays(firstday(),sp_time());
ND := MD-ND<=N?MD-N:ND;
end
return MA(eval(Exp),ND);
End;