以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  金字塔软件问题提交  (http://www.weistock.com/bbs/list.asp?boardid=2)
----  1秒周期的后台交易系统挂模拟账户上去跑为什么一秒内执行很多次?  (http://www.weistock.com/bbs/dispbbs.asp?boardid=2&id=139841)

--  作者:zqs0595
--  发布时间:2016/9/21 10:56:12
--  1秒周期的后台交易系统挂模拟账户上去跑为什么一秒内执行很多次?

程序开头打了个begin,程序结果打了个end.

 

2016-09-21 10:54:53.508    ******begin******
2016-09-21 10:54:53.508    shigh = 2256.00
2016-09-21 10:54:53.508    slow = 2254.00
2016-09-21 10:54:53.508    lastClose = 2256.00
2016-09-21 10:54:53.508    ******end******
2016-09-21 10:54:53.508    ******begin******
2016-09-21 10:54:53.508    shigh = 2256.00
2016-09-21 10:54:53.508    slow = 2254.00
2016-09-21 10:54:53.508    lastClose = 2255.00
2016-09-21 10:54:53.508    ******end******
2016-09-21 10:54:53.508    ******begin******
2016-09-21 10:54:53.508    shigh = 2256.00
2016-09-21 10:54:53.508    slow = 2254.00
2016-09-21 10:54:53.508    lastClose = 2256.00
2016-09-21 10:54:53.508    ******end******
2016-09-21 10:54:53.508    ******begin******
2016-09-21 10:54:53.508    shigh = 2256.00
2016-09-21 10:54:53.524    slow = 2254.00
2016-09-21 10:54:53.524    lastClose = 2255.00
2016-09-21 10:54:53.524    ******end******
2016-09-21 10:54:53.524    ******begin******
2016-09-21 10:54:53.524    shigh = 2256.00
2016-09-21 10:54:53.524    slow = 2254.00
2016-09-21 10:54:53.524    lastClose = 2255.00
2016-09-21 10:54:53.524    ******end******
2016-09-21 10:54:53.524    ******begin******
2016-09-21 10:54:53.524    shigh = 2256.00
2016-09-21 10:54:53.524    slow = 2254.00
2016-09-21 10:54:53.524    lastClose = 2255.00
2016-09-21 10:54:53.524    ******end******
2016-09-21 10:54:53.524    ******begin******
2016-09-21 10:54:53.524    shigh = 2256.00
2016-09-21 10:54:53.524    slow = 2254.00
2016-09-21 10:54:53.524    lastClose = 2256.00
2016-09-21 10:54:53.524    ******end******
2016-09-21 10:54:53.524    ******begin******
2016-09-21 10:54:53.524    shigh = 2256.00
2016-09-21 10:54:53.524    slow = 2254.00
2016-09-21 10:54:53.524    lastClose = 2255.00
2016-09-21 10:54:53.524    ******end******


--  作者:王锋
--  发布时间:2016/9/21 11:33:17
--  

请把公式代码也一起贴过来


--  作者:zqs0595
--  发布时间:2016/9/21 11:34:33
--  

//捕获快速下跌和快速上涨的行情
runmode:0;

zh:=\'613938\';                   //交易账号

//日志文件路径
logFilePath:=\'D:\\jztLog\\log.txt\';
DEBUGFILE2(logFilePath,\'******begin1******\',1,1);

input:changeSecond(10,10,200,20);   //多少秒上涨或下跌一定幅度,大时间周期确定趋势并入场
input:outSecond(20,10,120,20);        //当前价与N秒的移动平均线交叉,止损出局
input:changeRate(0.01,0.01,2,0.2);  //secondNum秒内的涨跌幅度百分之0.2
cs:=NUMTOSTR(changeSecond,0);     //数字转字符,方便调用
mn:=NUMTOSTR(outSecond,0);        //数字转字符,方便调用

lastClose:=ref(c,1);  //上一秒K线收盘价
orderNum:=1;                      //下单数量
entertime:=(time>=010300 and time<=025500) or (time>=130300 and time<=185500);  //下单时间
exittime:=(time>025500 and time<=120000) or (time>185500 and time<=230000);                    //清仓离场时间
//lostTooMuch:=(ref(asset,todaybar)-asset)/ref(asset,todaybar)>0.1; //今日亏损超10%
deadplus:=CROSS(STKINDI(\'\',\'getSecondMa.ma1(\'&mn&\')\',0,22,1),lastClose);  //离场死叉
goldplus:=CROSS(lastClose,STKINDI(\'\',\'getSecondMa.ma1(\'&mn&\')\',0,22,1));  //离场金叉

 


//持有多头仓位时,如果当前价和秒均线死叉,平掉多头仓位   
if tholding>0 and (deadplus or exittime) then begin
    TSELL(1,tholding,mkt,zh);
    DEBUGFILE2(logFilePath,\'>最新价与秒均线死叉或者将到\',1,1);
    DEBUGFILE2(logFilePath,\'>收盘时间,平掉多头仓位\',1,1);
end

//持有空头仓位时,如果当前价和秒均线金叉,平掉空头仓位   
if tholding<0 and (goldplus or exittime) then begin
    TSELLSHORT(1,tholding,mkt,zh);
    DEBUGFILE2(logFilePath,\'>最新价与秒均线金叉或者将到\',1,1);
    DEBUGFILE2(logFilePath,\'>收盘时间,平掉空头仓位\',1,1);
end

//空仓时,判断是否有下单机会
if tholding=0 then begin
    //取cs秒内的最大值和最小值
    shigh:=STKINDI(\'\',\'getSecondHHV.c1(\'&cs&\')\',0,22,1);
    slow:=STKINDI(\'\',\'getSecondLLV.c1(\'&cs&\')\',0,22,1);

    DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'shigh = %.2f\',shigh,1);
    DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'slow = %.2f\',slow,1);
    DEBUGFILE2(\'D:\\jztLog\\log.txt\',\'lastClose = %.2f\',lastClose,1);
   
    //changeSecond秒内跌幅超指定幅度,做空 and lostTooMuch=0   
    if ROUNDS((shigh - lastClose)/shigh,2)>changeRate and entertime then begin
        MSGOUT(1,\'做空\');
        TBUYSHORT(1,orderNum,mkt,zh); 
        DEBUGFILE2(logFilePath,\'>满足开空条件,建仓空头\',1,1);
    end
   
    //changeSecond秒内涨幅超指定幅度,做多 and lostTooMuch=0   
    if ROUNDS((lastClose - slow)/slow,2)>changeRate and entertime then begin
        MSGOUT(1,\'做多\');
        TBUY(1,orderNum,mkt,zh); 
        DEBUGFILE2(logFilePath,\'>满足开多条件,建仓多头\',1,1);
    end
end

DEBUGFILE2(logFilePath,\'******end******\',1,1);


--  作者:zqs0595
--  发布时间:2016/9/21 13:31:45
--  

不是我的代码问题,我新建了一个空的后台程序化交易系统,代码如下:

//捕获快速下跌和快速上涨的行情
runmode:0;

logFilePath:=\'D:\\jztLog\\log.txt\';
DEBUGFILE2(logFilePath,\'******begin2******\',1,1);

 

DEBUGFILE2(logFilePath,\'******end******\',1,1);

 

 

照样一秒钟执行很多次


--  作者:wenarm
--  发布时间:2016/9/21 13:32:12
--  

看下你后台程序化设置的界面


--  作者:zqs0595
--  发布时间:2016/9/21 13:33:18
--  
是不是要加ISLASTBAR判断
--  作者:zqs0595
--  发布时间:2016/9/21 13:40:08
--  

哪个地方可以看?


--  作者:zqs0595
--  发布时间:2016/9/21 13:41:10
--  
我刚加了ISLASTBAR判断,模拟盘确实可以一秒钟跑一次了,但是在历史回测只在最后一笔跑了一次。测试不了。
--  作者:wenarm
--  发布时间:2016/9/21 13:55:50
--  

 ISLASTBAR,在历史上是0,所以不会执行。只有最新的k上值才是1,

另外,你测了在刚加载是,会有一个初始化的过程,对历史上的k线进行一个运算,才会刷新到新的值。

我说的设置,交易----后台程序化中设置的界面,运行周期,运行模式这些。是否勾选不间断监控,这个是我5楼中要的




--  作者:zqs0595
--  发布时间:2016/9/21 13:59:36
--  

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看