Submit orders to IB from textfile

Discussion in 'Automated Trading' started by sheepsucker, Sep 15, 2012.

  1. Hi,

    My strategies are written in R and they generate the desired positions to a textfile.

    Does anyone know of a program or script that could take a textfile as input and send the orders to IB TWS? This script/program could be written in any language.

    I will schedule the script to run every 5 minutes. I can easily modify the format of the textfile.

    This seems such a common need that I decided to ask here before I proceed to write one myself.
  2. Look up "basket trader" on the IB website, you can save orders as a text, and upload in text format.
  3. tnx but the problem with basket trader is that it has to be run manually. Baskettrader cannot AFAIK be run without user intervention.
  4. Eight


    People did something like that with Tradestation 2000. I don't recall the details. It was the inelegant solution that worked just fine.

    I'm familiar with Sierracharts, a script can indeed read/write text files and interface them to IB's API.

    Hyperorder was the thing a few years ago but I don't know if it's supported anymore

    Tradelink is open source, it might work for you somehow..
  5. simsim67


  6. My application does that (although it's not much used for that purpose).

    In the "Order enqueuer" (gear icon) you can specify to read a given file called "MyOrders.txt" placed in a given folder. At any change of the file (creation/change), any order not earlier enqueued would be scheduled for execution. It can be executed either at given price or current price. Order format is like:

    0001 AAPL STK IBIS_EUR BUY 1 @ 504.15
    0002 AAPL STK IBIS_EUR SELL 1 @ 504.95
    0003 AAPL STK NASDAQ_USD BUY 1 @ 663.14
    0004 AAPL STK NASDAQ_USD SELL 1 @ 663.21
    0005 AGQ STK ARCA_USD BUY 1 @ 57.68
    0006 AGQ STK ARCA_USD SELL 1 @ 57.71

    You can <a href="">request</a> it freely to experiment.
  7. Thank you all for your suggestions! Will look into them to see if I can avoid re-inventing the wheel this time.

    No suggestions for scripts using the R package IBrokers so far? The rest of my algorithms are in R, altough that doesnt actually matter in this case.
  8. Bracket trader does this. Put the order in a text file in a particular folder and BT reads it.
  9. ddude


    Why not use twsOrder and placeOrder in IBrokers package in R??? :confused:
  10. 2rosy


    for x in f.readlines():
    order = Order(v)

    PM me if you want the Order() and twsclient code
    #10     Sep 16, 2012