Files
playbook/skills/tsl-api-reference/references/codegen/dotnet/quant/dev.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

2.9 KiB

因子与量化 / Dev

buySample()

买入策略范例,与系统环境变量有关

返回:bool

示例

SetSysParam(PN_Stock(),'SZ000002');
SetSysParam(pn_date(),inttodate(20121017));
return BuySample();

sellSample()

卖出策略范例,与系统环境变量有关

返回:bool

示例

SetSysParam(PN_Stock(),'SZ000002');
SetSysParam(pn_date(),inttodate(20121017));
return sellSample(); //判断万科A在2012-10-17在卖出策略sellSample()下是否卖出, 结果:0

stockBuyDiff()

现价与买入价的差异比,用于做交易策略用,与当前股票有关

返回:float

示例

SetStockBuyPrice('SZ000002',8.04);
SetSysParam(PN_Stock(),'SZ000002');
return StockBuyDiff(); //结果:4.47761

stockBuyPrice()

返回当前环境代码的’BuyPrice’对应的系统变量值

返回:any

stockBuyTime()

返回当前环境代码的'BuyTime'对应的系统变量值

返回:datetime

stockBuyTimeDiff()

返回买入天数,作为交易策略用,与当前股票、时间有关

返回:int

示例

SetStockBuyTime('SZ000002',inttodate(20121018));
SetSysParam(pn_date(),inttodate(20121022));
SetSysParam(PN_Stock(),'SZ000002');
return StockBuyTimeDiff(); //结果:4

selectStockIndex(stocks, beg_t, end_t, buy_cond, sell_cond, index_id, show_type)

策略期间,股票组合的收益情况,等比投资,与周期有关

参数 类型 说明
stocks Array 字符串,以分号分割,股票列表
beg_t TDateTime 日期型时间,策略验证开始时间
end_t TDateTime 日期型时间,策略验证截止时间
buy_cond Expsression 布尔公示表达式,策略买入条件
sell_cond Expression 布尔公示表达式,策略卖出条件
index_id String 字符串,指数代码
show_type Integer 整数型,显示类型(图形或者数据表类型),0表示返回图形,1表示数据类型

返回:TableArray

示例

setSysParam(PN_CYCLE(),cy_day());
ReturnSelectStockIndex("SZ000541;SH600000",intToDate(20120620),
intToDate(20120930),@bsByMacd(12,26,9,2),@ssByMacd(12,26,9,2),"SH000001",1);  //返回股票组合array(SZ000541;SH600000)在2012-06-20到2012-09-30在给出的买入条件和卖出条件下的等比投资的交易情况
//结果:

setRetBuyPrice(price)

设置一个“tmpBuyPrice”自定义的系统变量的值

参数 类型 说明
price Real 实数,价格

返回:Integer

示例

setRetBuyPrice(20);
return getSysParam('tmpBuyPrice'); //结果:20

setRetSellPrice(price)

设置一个“tmpSellPrice”自定义的系统变量的值

参数 类型 说明
price Real 实数,价格

返回:Integer

示例

setRetSellPrice(50);
return getSysParam('tmpSellPrice'); //结果:50