Tws Api

Discussion in 'Automated Trading' started by maninjapan, Dec 15, 2009.

  1. Hi, Im trying to write a simple system Direct to TWs, but have hita brick wall. Ive been at it all day, but still not able to recieve data from TWS. Does anyone out there have any experience with the TWS API? Or does anyone know of any quirks or traps with it?
    Ive tried even running the demo code, but that doesnt even seem to work....

    Any help on this would be much appreciated.

  2. slacker


    If you cannot get the demo code working it is unlikely that you can get some custom app working.

    Does the Standalone TWS Workstation work? Quotes, MarketDepth, Charts???

    Good luck
  3. Guys, thanks for the replies, I will go through each of them.
    My program connects to IB successfully, when I request to retrieve live data for some Symbol (Stock or Option), it did not return anything, no data and no any error message, I have tried to request 5 second and 30 second data and even after waiting 5 minutes no output.

    Ill go through those suggestions though
  4. To make sure you are actually connecting to TWS, call the TWS Connect() routine twice in a row. This will generate an "already connected" error message (might be #202, check the error code list).
    If you are truly connected to TWS, you should get feedback when you try to request data: either you start recieving data, or you will receive errors because you didn't specify the contract correctly or asked for an incorrect format.
  5. rosy2


    since we dont know what you did help will be limited.

    you need to implement the interfaces

    1) class QuoteRequester implements EWrapper,Constants { ... }

    2) create contracts ...
    Contract contract = new Contract();

    3) use those contracts in

    4) print some stuff out inthe error() methods

    5) print stuff out in tickPrice()
  6. Also, your best bet is to get the TWS example code running for starters...the sample code is pretty thorough and has all the bare bones to make sure you are implementing things correctly.