Files
playbook/skills/tsl-api-reference/references/codegen/dotnet/financial/financial_engineering-index_research-intermediate.md
T

9.9 KiB

金融 / 金融工程 / 指数研究 / 中间函数

deleteDataOutOfScopes(t_1, t_2)

声明:function

删除多余日期

参数 类型 说明
t_1 table_array 数据表,必须含有’time’字段
t_2 table_array 数据表,必须含有’time’字段

返回:table_array

示例

范例01:调用函数

t1 := array(('s':0, 'time':41201), ('s':6, 'time':41202), ('s':2, 'time':41203), ('s':8, 'time':41204), ('s':2, 'time':41207), ('s':3, 'time':41208));
t2 := array(('s':2, 'time':41101), ('s':7, 'time':41202), ('s':9, 'time':41205), ('s':3, 'time':41206), ('s':5, 'time':41207), ('s':1, 'time':41209));
deleteDataOutOfScopes(t1, t2);
return array(t1, t2);

fileterValue(v, w)

声明:function

返回找出需要过滤处理的日期

参数 类型 说明
v table_array 数据表,必须含有’time’字段
w array 一维日期型时间数组

返回:table_array

示例

范例01:调用 FileterValue

v := array(('s':0, 'time':41201), ('s':6, 'time':41202), ('s':2, 'time':41203), ('s':8, 'time':41204), ('s':2, 'time':41207), ('s':3, 'time':41208));

w := array(41101, 41202, 41205, 41206, 41207, 41209);

FileterValue(v, w);

filterValueByCycle(t, beg_t, end_t, cycle_name)

声明:function

按照周期取数据

参数 类型 说明
t table_array 数据表,必须含有’time’字段
beg_t t_date_time 日期型时间,选取开始时间
end_t t_date_time 日期型时间,选取截止时间
cycle_name string 字符串,周期函数

返回:table_array

示例

范例01:调用函数

setSysParam(PN_Stock(), 'SZ000002');
setSysParam(PN_DATE(), intToDate(20121029));
t := nDay(20, 'time', dateToInt(sp_time()), 'c', close());
filterValueByCycle(t, intToDate(20120918), intToDate(20121029), cy_week());
return t;

getMaxListedDate(stock_arr)

声明:function

获取股票列表StockArr中最晚的上市日值

参数 类型 说明
stock_arr array 一维字符串数组

返回:t_date_time

示例

范例01:调用函数

return getMaxListedDate(array("SZ000920", "SH600718", "SH600900"));

indexDataToShowable(index_table, base_value)

声明:function

把计算存贮好的指数数据转换

参数 类型 说明
index_table table_array 数据表,指数结果表,必须含有’Date’,’Close’字段
base_value real 实数,基准值

返回:table_array

示例

范例01:调用 IndexDataToShowable

SetSysParam(PN_Stock(), 'SZ000002');

SetSysParam(PN_DATE(), IntToDate(20121026));

t := Nday(20, 'Date', sp_time(), 'Close', close());

Return array('转换前':t, '转换后':IndexDataToShowable(t, 1000));

indexLineMerge(bk_name, bk_value, index_name, index_value, show_type)

声明:function

返回两个指数迭加

参数 类型 说明
bk_name string 字符串,板块名称
bk_value table_array 数据表,计算出来的板块指数,必须含有’time’,’close’字段
index_name string 字符串,指数代码
index_value table_array 数据表,指数数值,必须含有’time’,’close’字段
show_type integer 用户自定义,返回类型,含义如下表:

返回:table_array

示例

范例01:调用函数

setSysParam(PN_Stock(), 'SZ000002');
setSysParam(PN_DATE(), intToDate(20121026));
bk_value := nDay(20, 'time', sp_time(), 'close', close());
setSysParam(pn_stock(), 'SH000001');
index_value := nDay(20, 'time', sp_time(), 'close', close());
return indexLineMerge('SZ000002', bk_value, 'SH000001', index_value, 1);

kLineDataForIndex(stock_id, beg_t, end_t)

声明:function

返回K线数据(指数专用)

参数 类型 说明
stock_id string 字符串,股票代码
beg_t t_date_time 日期型时间,开始日期
end_t t_date_time 日期型时间,截止日期

返回:table_array

示例

范例01:调用 KLineDataForIndex

Return KLineDataForIndex("SH600206", inttodate(20120618), inttodate(20120926));

kLineMerge(bk_name, bk_value, index_name, begt, endt, show_type)

声明:function

返回板块指数与大盘指数迭加

参数 类型 说明
bk_name string 字符串,板块名称
bk_value table_array 数据表,计算出来的板块指数,必须含有’time’,’close’字段
index_name string 字符串,指数代码
begt t_date_time 日期型时间,开始日期
endt tdate_time 日期型时间,截止日期
show_type integer 用户自定义,返回类型,0表示图形,1表示数据

返回:table_array

示例

范例01:调用 KLineMerge

SetSysParam(PN_Stock(), 'SH000001');

SetSysParam(PN_DATE(), IntToDate(20121026));

BkValue := nday(20, 'time', sp_time(), 'close', close());

return KLineMerge("SH000001", BkValue, "SH600718", inttodate(20120618),

    inttodate(20121026), 1);

manyBkLineMerge(r, show_type)

声明:function

返回指数叠加结果处理,用于计算复合指数的中间过程

参数 类型 说明
r table_array 数据表,必须含有’value’字段
show_type integer 用户自定义,0为图形,1为数据

返回:table_array

示例

范例01:调用函数

t := array(
    ("time":20061229, "close":2675.47),
    ("time":20070104, "close":2715.72),
    ("time":20070105, "close":2641.33),
    ("time":20070108, "close":2707.2),
    ("time":20070109, "close":2807.8),
    ("time":20070110, "close":2825.58),
    ("time":20070111, "close":2770.11),
    ("time":20070112, "close":2668.11),
    ("time":20070115, "close":2794.7),
    ("time":20070116, "close":2821.02),
    ("time":20070117, "close":2778.9),
    ("time":20070118, "close":2756.98));
t1 := array(
    ("time":20061229, "close":1000),
    ("time":20070104, "close":1017.56),
    ("time":20070105, "close":961.42),
    ("time":20070108, "close":978.96),
    ("time":20070109, "close":1022.61),
    ("time":20070110, "close":1017.87),
    ("time":20070111, "close":986.16),
    ("time":20070112, "close":947.22),
    ("time":20070115, "close":991.12),
    ("time":20070116, "close":988.37),
    ("time":20070117, "close":971.06),
    ("time":20070118, "close":948.98),
    ("time":20070119, "close":970.16));
r := array(("Name":"SH000001", "Value":t), ("Name":"复合指数", "Value"
    :t1));
return manyBkLineMerge(r, 1);

setToFirstValue(t_1, t_2)

声明:function

返回归一处理,用于在计算复合指数时,在基准数据t2的基础上对t1归一化

参数 类型 说明
t_1 table_array 数据表,必须含有’close’字段
t_2 table_array 数据表,必须含有’close’字段

返回:table_array

volDataForIndex(stock_id, beg_t, end_t)

声明:function

返回K线数据(指数专用)

参数 类型 说明
stock_id string 字符串,股票代码
beg_t t_date_time 日期型时间,开始日期
end_t t_date_time 日期型时间,截止日期

返回:table_array

示例

范例01:调用函数

return volDataForIndex("SH600206", intToDate(20120618), inttodate
    (20120926));