请高手指点一下AB的自动交易设置

Discussion in 'AmiBroker' started by northman, Aug 4, 2010.

  1. 我目前的问题是头寸反转问题,如果Buy和Cover, Short和sell 的信号是同时发生的,AB只能送出一个买 或卖的信号,我希望能够分两步进行,先平掉现有头寸,再开新头寸。这样不仅便于统计交易结果,看起来也比较清楚。但目前只能发送一个信号,我的理解是 (1)如果使用了OrderID, AB就不容许连续二次发送同方向的买或卖信号到TWS。(2)问题是否出在 buy = Ref(Buycond, -1); 或 Short = Ref(Shortcond, -1); 但如果不是有ref,又会有另外的问题出现。(3) 其他问题。 不知各位高手有无好的解决办法。
     
  2. 谢谢espresso的解释,很有启发。
     
  3. 对于你所说的情况,似乎buy和cover只用一个就可以。因为对于同一个交易品种,IB不会同时保持两个方向的头寸。比如你卖出EURUSD 20000,这个时候如果在买入 40000的话,最后你看到的是 EURUSD 20000。卖出头寸20000已经被平仓了。
     
  4. espresso兄的见解有一定道理。
    这个连接,对有兴趣的人,或许有所参考。
    http://code.google.com/p/tradelink/
    •Hook TradeStation to 3rd party brokers 就是提供一个接口了。

    不过对个人来说,的确会牵扯精力太多。
    比如ninjatrader里面,就有通过文本传递的接口。也是一个办法了。
     
  5. How to handle TWS disconnect while auto trade running

    Brothers,

    The last problem which I can not fixed it is TWS disconnection.
    How can you fix this problem.

    The program can be set only running while TWS connection ok. but after TWS
    re-connect, time changed (price changed too).

    Any comments
     
  6. 这个问题似乎不能由AB自己去重新连接,我的简单的解决方法是定时监测TWS的连接,如果一段时间内没有变化,则发邮件(或短信)通知,然后我就连到服务器上手工连接一下。

    自动交易系统的里面监测和通知功能非常重要,这样才能让你无需随时盯着屏幕。 ;)
     
  7. Brother,

    Good idea, however, I still seeking solutions.
    by the way. will Hongkong server has same problem ? how often and how long.

    Thank you.
     
  8. I known to re-set IBcontroller can solve the disconnect problem.

    I can start it with below AB code.

    AlertIf( trigger, "EXEC D:\\IBC283_demo\\sampleIBControllerStart_demo.bat", "Launching external application", 4 );

    BUT, before starting IBcontroller, how can I shut down the IBcontroller with
    AB code.

    Any one can help ?
     
  9. 找个杀进程的程序,做成批处理,干掉IBController试试看?
     
  10. done already, share with brothers as below :

    AlertIf(tws_reset, "EXEC D:\\IBC283_demo\\tws_off.bat", "TWS off", 0,1+2 );
    AlertIf(tws_reset, "EXEC D:\\IBC283_demo\\sampleIBControllerStart_demo.bat", "TWS on", 0,1+2 );
     
  11. Network monitor

    Hello,

    Due to the TWS freeze problem, I found the best solution is to use
    TWSstart instead of IBcontroller. because TWSstart monitors the network
    connection.

    Meanwhile, I am looking a network tool which can
    monitor my local IP or IB server, if it find TWS freeze or diconnected,
    it can re-start network connection automatically.

    Is there some one can nominate such software to me.