automatic trading with IB TWS

Discussion in 'Automated Trading' started by samsonocb, Mar 19, 2004.

  1. samsonocb


    hello everybody.

    I am going to start trading automated through the TWS Api.

    As I do not want to set up tradestation 2000 for automation i have to
    write my own aplication. I will do it in VB.

    if have to read out TWS market data for QQQ, generate 10 minute bars
    calculate several indicators and creat orders.

    but where should i store the data? in a database or should i print
    the bar data simply to a text file?

    Is there a way to get missed data? Lets say my compi lost connection
    and I miss the bars from 14 - 16 h ?

    Any other things I should take care of?

    I would appreciate all inputs on this topic
  2. I store bars in text file. Only because its quicker to read (i use minute bars, and get many). Database is an option - but would also require more effort, although not much.

    I can say this - text is messy. For example, i have text files which hold a lot of data - they are huge in size, and slow to open and edit. Although i never really edit them.
    So database is cleaner. And easy to edit.
    Theres your tradeoff. Speed, and not much work to do (writing to txt is easy) or cleanliness(DB).

    Finally, my data provider allows to download for past 20 days. I just created a method to download bars on request. So, if i missed data from three days ago, i just download last 3 days from data vendor. You NEED to do this (something similar), in case you miss a day, or data you get is wrong.

    Every day i download data to file(s) to keep current.

    Hope this helps.
  3. abogdan


    We have been running robots with IB for quite some time now. We always use redundant data feed (eSignal) on top of the IB data stream. We prefer running our history via SQL server data base. You should not have any problems writing VB app. to the IB API, its well documented. Make sure though that you read all the history to their API versions. It has a lot of useful info there.
  4. Aaron


    Check out the possibilities for autotrading an IB account using Wealth Lab Developer at If it suits your needs it'll save you a lot of coding.
  5. hayman


    I 2nd Aaron's comment. Wealthlab provides an entire framework for this type of trading. You can then focus on the application specifics and not worry about the system logistics. Well worth the $ 650 license fee, and they have awesome support.
  6. Ultimately, you may want a secondary feed with historical data. DTN IQFeed offers an API for this for a yearly and monthly fee.

    If you are trying to cut costs by using IB's feed, I think your answer depends on how far back you need to go. If you only need the current day's data, why not just store it in memory? If you need more data than that, a text file or database is probably the thing to do, though as you said, you might lose some data with IB's feed...

    Good luck.
  7. freeedu


    I've found a description on how to build automated strategies just using TWS without any other software here:

    I've tested It on a Connor's like strategy based on moving averages and It works.

    Last edited: Apr 1, 2017