Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Over night trading with IB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Over night trading with IB

    I have two questions about IB connections.

    First every night around midnight there is a server change and you loose the data feeds for a certain amount of time.

    Second, there is an auto logout feature that can't be turned off.

    If I want to run strategies that trade over more than one day, can ninjatrader handle this reliably? What happens when IB kicks you off or looses data feeds? can you manually restart TWS without restarting and loosing graphs and such from NT? If you have to restart NT will it automatically add open positions to a strategy?

    #2
    You can not run NT overnight with IB. IB forces a disconnect which requires a restart of NT to reconnect.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks, I kinda figured that I would have to restart everything.

      1) So then is it possible to run strategies that don't exit all trades at the end of the day?

      2) Do you loose all the data and calculations that your strategy made that day?

      3) When you reopen NT, does it automatically add open positions back into the strategy?

      Comment


        #4
        1) No, strategies terminate as NT is terminated. This will change later this year.

        2) Yes as per #1

        3) No as per #1
        RayNinjaTrader Customer Service

        Comment


          #5
          This year end?

          Need to restart NT due to external middle tier applications connection issues is definitely "beta" feature for NT that supposed to run automated strategies 24/7. Are you saing this will be fixed only in version 7.0 that coming some time when the year changes??


          Another question related to IB TWS connectivity.
          Is the starting TWS AND logging in is the necessity and the prerequisite to successful connection attempt from NT menu? I'm asking because of this two things together:
          1. IB connection has the option for user credentials (optional), so I would assume NT should be able to start TWS on its own.
          2. After misseing with suggested stanalone TWS build 882, web beta 883 and web release 884 and then stanaolne TWS minor update to 882.2 lately, seems I can't start TWS from NT.
          NT throws the dialog window titled as Message with OK button:
          Login failed: Invalid user or password, or system not available
          Optional user credentials are entered correctly and the only way to connect is manually login into TWS first (either stanalone 882 or web 884 work the same on my Vista w/out SP and NT 6.5 release).
          If that supposed to work this way then why the user name and password boxes for IB connection in NT? Or what should I do to fix that? I tried re-install of TWS 882, reboots etc. One thing noticed that even disabling all IB Connection run-time handling dialogs and auto-login NT features, NT still tries to close TWS Login window that it brings forward... weird.

          Comment


            #6
            What I am saying is that in NT7 you will have the ability for NT to automatically connect when started.

            1) Correct
            2) It should work on the supported TWS 882 version
            RayNinjaTrader Customer Service

            Comment


              #7
              NT work around for IB TWS overnight disconnection

              I am able to run NT overnight using my IB TWS connection without being logged out.

              Each day I have to open up IB TWS and select Configure>Misc>Exit and change the am/pm or time as required, and then repeat the process before the new logout time occurs.

              I would much prefer to have NT manage this and applaud the proposed version 7 changes. Thanks Ray!
              Last edited by Aussie2; 05-02-2008, 04:04 AM. Reason: Grammar

              Comment


                #8
                Still problems to start TWS from NT...

                Originally posted by Aussie2 View Post
                I am able to run NT overnight using my IB TWS connection without being logged out.

                Each day I have to open up IB TWS and select Configure>Misc>Exit and change the am/pm or time as required, and then repeat the process before the new logout time occurs.

                I would much prefer to have NT manage this and applaud the proposed version 7 changes. Thanks Ray!
                TWS shutdown is probably the sanity measure against JVM+TWS memory leaks. I think NT can have an option to flip/flop TWS shutdown time by 12h just changing a setting in some property file, no need to imitate user menu interactions (or I might be wrong if the property file has no watcher for its changing) - anyway, I guess this is the extra feature request for IB connection setup then... 1+

                As to starting TWS by NT I got mixed and unreliable results (it works sometimes, but usually TWS Login dialog filled and then just disappears with eventual Login failure log, tried TWS 882 and current 884 standalone both). Have no idea how to make it work reliably. Maybe there is too short timeout for NT to login into TWS? Can it be adjusted somewhere?


                Also, does NT uses newest IB TWS API available as extra AX_install.exe or it just utilizes API dll that is build into TWS distribution?

                Comment


                  #9
                  IB TWS Configure>Misc>Exit AM/PM "flip flop"

                  Hi Nintra

                  Used TotalUninstall to capture changes during a IB TWS Configure>Misc>Exit AM/PM "flip flop"

                  Two files were modified. Namely:
                  1. C:\Jts\dfjbqkvss\tws.tmp.xml
                  2. C:\Jts\log.Thu.txt

                  Had a peek at these - not sure how to determine if the .xml file is monitored by TWS.

                  Instead ......

                  If away from my computer rather than trying to get NT to auto login to IB TWS, I log in remotely using VNC and do the flip flop.

                  As a back up if I miss a flip flop I also use a strategy I wrote to monitor the IB connection status, and sms me on disconnection. I then log in using VNC and restart IB TWS.

                  My strategy code follows:

                  PHP Code:
                  protected override void OnConnectionStatus(ConnectionStatus orderStatusConnectionStatus priceStatus
                    { 
                    
                  string msgA "";
                        if(
                  orderStatus==ConnectionStatus.ConnectionLost)
                     {
                     
                  msgA "Ninja Trader: ConnectionLost ";
                     }
                    if(
                  orderStatus==ConnectionStatus.Connected)
                     {
                     
                  msgA "Ninja Trader: Connected ";
                     }
                    if(
                  orderStatus==ConnectionStatus.Disconnected)
                     {
                     
                  msgA "Ninja Trader: Disconnected ";
                     }
                    if(
                  Position.MarketPosition == MarketPosition.Short)msgA=msgA+"- Short";
                    else if(
                  Position.MarketPosition == MarketPosition.Long)msgA=msgA+"- Long";
                    else 
                  msgA=msgA+"- Flat";
                    
                  SendMail("xxxx""xxxxxx""Ninja Trader Connection"msgA); 
                  Typically I blank out the lines with ".ConnectionLost" or ".Connected" as IB often has many of these each day.

                  This is a simple work around that may assist pending NT v7 changes.

                  Regards
                  Last edited by Aussie2; 05-02-2008, 07:47 PM. Reason: Correction

                  Comment


                    #10
                    NT Controller

                    Hi Aussie2

                    This script is a good feedback reminder. Maybe we should try to go one step further and run some controller application from it (instead of just sending email/SMS in hope someone would react)? Can we run an executable from NT strategy? Sure that might be C# too.

                    As for the TWS shutdown flip switch, the file seems to be temporary all-in-one TWS configuration file and that would be look more like hacking TWS internals, unfortunately. As I still can't get TWS started from NT, mybe the solution would be to write TWS & NT controller application/service that will watch and control both NT & TWS, i.e. (re)start them, login to TWS, connect NT to IB, flip TWS shutdown, report problems by email/SMS. Maybe someone already did this??

                    As to IB NT connection, I would assume one will want to make connection to paper account 1st, then to live trading one 2nd (to mitigate the limits of IB data feed streaming), correct? I have no idea whether the paper accounts feed match the live accounts exactly.

                    Comment


                      #11
                      Paper Trading

                      Hello again,

                      Been away.

                      Not sure what others are doing or what is recommended, however I generally do not connect to IBs paper trading account.

                      When I want to carry out some backtesting I usually disconnect from IB (ie File>Disconnect) and rely on price data stored in the NT data base (ie I have Tools>Options>Data>General>Miscellaneous set to Store realtime bar data) This way I do not have to poll IB for data repeately.

                      When I want to carry out paper trading with say Chart Trader or the Super DOM then I simply put NT into simulation mode (ie File>Global Simulation Mode) All trades are then put through to a SIM101 NT account.

                      If you want to explore slippage impact then I suppose you could try IBs paper trading account although the above NT DOM/Chart method captures current market prices.
                      Last edited by Aussie2; 05-13-2008, 04:54 AM. Reason: Grammar

                      Comment


                        #12
                        Right on!

                        Check this out:



                        Originally posted by nintra View Post
                        Hi Aussie2

                        This script is a good feedback reminder. Maybe we should try to go one step further and run some controller application from it (instead of just sending email/SMS in hope someone would react)? Can we run an executable from NT strategy? Sure that might be C# too.

                        As for the TWS shutdown flip switch, the file seems to be temporary all-in-one TWS configuration file and that would be look more like hacking TWS internals, unfortunately. As I still can't get TWS started from NT, mybe the solution would be to write TWS & NT controller application/service that will watch and control both NT & TWS, i.e. (re)start them, login to TWS, connect NT to IB, flip TWS shutdown, report problems by email/SMS. Maybe someone already did this??

                        As to IB NT connection, I would assume one will want to make connection to paper account 1st, then to live trading one 2nd (to mitigate the limits of IB data feed streaming), correct? I have no idea whether the paper accounts feed match the live accounts exactly.

                        Comment


                          #13
                          Hi, there is a simple program you can get for free called IBController. its a really simple program that basically just keeps IB from logging off overnight - it works fairly reliably but i havent exactly tested it extensively. still need to restart it over the weekend it, but still a step forward from restarting every day!

                          Comment


                            #14
                            1. Please refer to the following thread:


                            2. The idea behind using an "autokey" type solution is complete flexibility. For example, if you restart your connection, what about your strategy? Also, what about non-IB accounts?



                            Originally posted by spinalwiz View Post
                            Hi, there is a simple program you can get for free called IBController. its a really simple program that basically just keeps IB from logging off overnight - it works fairly reliably but i havent exactly tested it extensively. still need to restart it over the weekend it, but still a step forward from restarting every day!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by DavidHP, Today, 07:56 AM
                            1 response
                            5 views
                            0 likes
                            Last Post NinjaTrader_Erick  
                            Started by kujista, Today, 06:23 AM
                            3 responses
                            6 views
                            0 likes
                            Last Post kujista
                            by kujista
                             
                            Started by Mindset, Yesterday, 02:04 AM
                            2 responses
                            17 views
                            0 likes
                            Last Post NinjaTrader_RyanS  
                            Started by f.saeidi, Today, 08:03 AM
                            1 response
                            5 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by samish18, 04-17-2024, 08:57 AM
                            15 responses
                            52 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Working...
                            X