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

9.1 KiB

算法交易 / 交易指令扩展及算法交易

tsAtGetParamterandDefaultValue(argv, name)

获得指定策略的缺省参数

参数 类型 说明
argv array 数组,与交易网关柜台、账号属性、交易账号、账号密码等相关的字符串数组,输入;
name string 字符串,算法交易策略名称,输入;(算法交易策略由算法交易策略开发人员开发完成后,给每个算法交易策略起一个易于理解的算法名称)

返回:array

tsAtQuery(user_id, password, end_t, query_type, time_out)

查询账号相关信息,包括资金,持仓等

参数 类型 说明
user_id string 字符串,交易账号,输入;
password string 字符串,交易密码,输入;
end_t datetime 实数,查询日期,输入;
query_type any 整数,查询类型,输入;
time_out any 整数,超时时间(单位毫秒),输入;

返回:array

tsAtQueryByOrderId(user_id, password, end_t, order_id, query_type, time_out)

策略执行结果详情查询(按订单号)

参数 类型 说明
user_id string 字符串,交易账号,输入;
password string 字符串,交易密码,输入;
end_t datetime 实数,查询日期,输入;
order_id string 字符串,母订单号,输入;(要查询所有委托母订单和执行状态时候,此参数可设置为空。否则,设置为启动策略成功后,返回的)
query_type any 整数,查询类型,输入;
time_out any 整数,超时时间(单位毫秒),输入;

返回:array

tsAtStart(h, time_out, err_str)

启动指定策略

参数 类型 说明
h any 整数,交易客户登录成功返回后返回的交易句柄,输入;;Data:数组,要执行算法交易的策略和策略参数。根据要执行算法交易策略的不同,此参数的数值可能不同。输入;
time_out any 整数,超时时间(单位毫秒),输入;
err_str string 字符串,错误信息,输出;

返回:string

tsAtStop(h, order_id, time_out)

按照订单号停止指定策略

参数 类型 说明
h any 整数,交易客户登录成功返回后返回的交易句柄,输入;
order_id string 启动策略成功后,返回的交易母单订单号,输入;
time_out any 整数,超时时间(单位毫秒),输入;

返回:any

tsOrderFuturePosition(addr, broker_id, account, password, stkid, position, cancel_threshold, comment)

函数会自动维护指定品种的头寸。用户不需要进行复杂的事务处理、交易下单、交易撤单等,大大简化了应用开发。 委托价格是品种的当前价格。当委托价格偏离最新价格指定阀值(cancel_threshold)时撤单;cancel_threshold< 0 不撤单(禁用撤单功能) 服务器模式:每间隔指定时间(循环中),调用行情信号模块——计算当前头寸,同时调用本指令维护头寸。 客户端模式:每间隔指定时间(循环中),调用行情信号模块——计算当前头寸,同时使用RDO2调用本指令维护头寸(交易在客户端)。

参数 类型 说明
addr string 字符串,期货交易柜台地址,输入;
broker_id string 字符串,经济公司代码,输入;
account string 字符串,交易账号,输入;
password string 字符串,交易密码,输入;
stkid string 字符串,代码,输入;
position any 整数,目标头寸,输入;
cancel_threshold float 实数,撤单阀值,输入;
comment string 字符串,说明信息,输入;(可以为每笔操作添加描述信息,以便区分每笔交易)

返回:any

tsOrderFuturePositionCep(addr, broker_id, account, password, stkid, position, cancel_threshold, comment, act)

本函数是对TSOrder_FuturePosition进行CEP封装,会每间隔1秒调用一次。 本指令每间隔1秒调用TSOrder_FuturePosition检查、维护指定品种头寸;运行参数为最后一次调用本函数(act=1设置头寸)的参数表。 服务器模式:本指令需要天软CEP(复杂事务处理)支持。可以订购指定品种行情事件、Timer事件,每当行情变动或定时器事件时,调用行情信号模块——计算当前头寸,同时调用本指令维护头寸。 客户端模式:天软客户端集成CEP(复杂事务处理),本指令可以通过RDO2推送到客户端运行。可以订购Timer事件(目前客户端暂不支持实时行情事件),每当定时器事件时,调用本指令维护头寸。

参数 类型 说明
addr string 字符串,期货交易柜台地址,输入;
broker_id string 字符串,经济公司代码,输入;
account string 字符串,交易账号,输入;
password string 字符串,交易密码,输入;
stkid string 字符串,代码,输入;
position any 整数,目标头寸,输入;
cancel_threshold float 实数,撤单阀值,输入;
comment string 字符串,说明信息,输入;(可以为每笔操作添加描述信息,以便区分每笔交易)
act any 整数,执行动作,输入;(1--设置当前头寸,-1--停止指令,2--查看指令运行情况,3--查看指令调用日志,4--查看当前头寸信息)

返回:any