参考这个范例的处理思路。
[PEL] 复制代码
y:=5;//品种数量限制
ct:=0;
zh:=TACCOUNT( 1);//账户ID
GLOBALVARIABLE:CTX:=0;
temp_str:='';//保存品种代码集合
for i=1 to tholdcount(zh) do
begin
hlabel:=tholdindexlabel(i,zh);
//判断当前代码集合中是否已经存在,不存在则进行统计。只统计老仓为0的品种
if strfind(temp_str, ','&hlabel,1 )=0 and tbuyholdingex('',hlabel,1)=0 then
begin
ct:=ct+1;
end
end
show:ct;//调试语句,输出当前今仓品种数量
//后台监控是否有未成交单,没有未成交情况下 才能确定有效的账户持仓品种数量
uncompleted:tisremainex(1,zh,'')+tisremainex(3,zh,'');
if uncompleted=0 then
begin
CTX:=CT;
end
//账户品种数量控制
cond:=ct<y and CTX<y;
if cond then begin
//开仓语句
CTX:=CTX+1;
end
|