[PEL] 复制代码
code1:='ic00';
code2:='if00';
d1:=callstock(code1,vtclose,6,-1);//ic 昨日收盘价
d2:=callstock(code2,vtclose,6,-1);
//基于前一日收盘价计算的涨跌幅
zd1:=100*(c-d1)/d1;
zd2:=100*(c-d2)/d2;
tcd:time=145900;//这里按照这样的时间判断,要实现目标效果,则需要用走完K下单
if tcd and zd1>0 and zd2>0 then //都涨
begin
codea:=if(zd1>zd2,code1,code2);
codeb:=if(zd1>zd2,code2,code1);
ax:=stkindi(codea,'b.ss1(100)',0,-1,0);
bx:=stkindi(codeb,'b.ss1(50)',0,-1,0);
dt1:=tbuyholdingex('',codea,1);
kt1:=tsellholdingex('',codea,1);
dt2:=tbuyholdingex('',codeb,1);
kt2:=tsellholdingex('',codeb,1);
if kt1<>0 then tsellshort(1,0,mkt,0,0,'',codea);
if kt2<>0 then tsellshort(1,0,mkt,0,0,'',codeb);
if ax-dt1<>0 then
begin
tbuy(ax-dt1>0,ax-dt1,mkt,0,0,'',codea);
tsell(ax-dt1<0,dt1-ax,mkt,0,0,'',codea);
end
if bx-dt2<>0 then
begin
tbuy(bx-dt2>0,bx-dt2,mkt,0,0,'',codeb);
tsell(bx-dt2<0,dt2-bx,mkt,0,0,'',codeb);
end
end
if tcd and 100*zd1*zd2<0 then //一涨一跌
begin
codea:=if(zd1>zd2,code1,code2);
codeb:=if(zd1>zd2,code2,code1);
ax:=stkindi(codea,'b.ss1(50)',0,-1,0);
bx:=stkindi(codeb,'b.ss1(50)',0,-1,0);
dt1:=tbuyholdingex('',codea,1);
kt1:=tsellholdingex('',codea,1);
dt2:=tbuyholdingex('',codeb,1);
kt2:=tsellholdingex('',codeb,1);
if kt1<>0 then tsellshort(1,0,mkt,0,0,'',codea);
if dt2<>0 then tsell(1,0,mkt,0,0,'',codeb);
if ax-dt1<>0 then
begin
tbuy(ax-dt1>0,ax-dt1,mkt,0,0,'',codea);
tsell(ax-dt1<0,dt1-ax,mkt,0,0,'',codea);
end
if bx-kt2<>0 then
begin
tbuyshort(bx-kt2>0,bx-kt2,mkt,0,0,'',codeb);
tsellshort(bx-kt2<0,kt2-bx,mkt,0,0,'',codeb);
end
end
if tcd and zd1<0 and zd2<0 then //都跌
begin
codea:=if(zd1<zd2,code1,code2);
codeb:=if(zd1<zd2,code2,code1);
ax:=stkindi(codea,'b.ss1(100)',0,-1,0);
bx:=stkindi(codeb,'b.ss1(50)',0,-1,0);
dt1:=tbuyholdingex('',codea,1);
kt1:=tsellholdingex('',codea,1);
dt2:=tbuyholdingex('',codeb,1);
kt2:=tsellholdingex('',codeb,1);
if dt1<>0 then tsell(1,0,mkt,0,0,'',codea);
if dt2<>0 then tsell(1,0,mkt,0,0,'',codeb);
if ax-kt1<>0 then
begin
tbuyshort(ax-kt1>0,ax-kt1,mkt,0,0,'',codea);
tsellshort(ax-kt1<0,kt1-ax,mkt,0,0,'',codea);
end
if bx-kt2<>0 then
begin
tbuyshort(bx-kt2>0,bx-kt2,mkt,0,0,'',codeb);
tsellshort(bx-kt2<0,kt2-bx,mkt,0,0,'',codeb);
end
end