Interactive Brokers - End of Day Flat Feature

Discussion in 'Trading Software' started by CPTrader, Jan 26, 2010.

  1. Does IB's TWS have a feature that allows you to go flat at the end of day with one click in all markets (futures, stocks, forex, etc)?

  2. you can close all positions, but I am not aware of being able to trigger it to a certain time...

    you could do this in tradelink for your IB account like so :

    using TradeLink.API;
    using TradeLink.Common;
    using System.ComponentModel;
    public class FlatClose : ResponseTemplate
      PositionTracker _pt = new PositionTracker();
      List<string> _syms = new List<string>();
      override void GotPosition(Position p) 
      override void GotFill(Trade fill) { _pt.Adjust(fill); }
      int SHUTTIME = 155000;
      [Description("shut down at this time")]
      public int ShutTime { get { return SHUTTIME; } set { SHUTTIME = value; } }
      override void GotTick(Tick k)
           if (!isValid) return;
           if (k.time>ShutTime)
              isValid = false;
              foreach (Position p in _pt)
                 sendorder(new MarketOrderFlat(p));
              D("auto shutdown");
      public FlatClose()
           // prompt user to change shutdown time when response started
    Then when you loaded this strategy in ASP, it would prompt you for a shutdown time and shutdown any positions present at that time.
  3. Chart Trader has the "close position" button, but that's only for one product. Might still be useful.

    I don't know the real answer to your question though.
  4. On the Order menu in TWS there is a "Close All Positions" item which I believe should allow you to close everything manually with just a few clicks. Or you could assign it to a hotkey(?). I've never used it however...