Simple VB.net project with IB API 9.72+

Discussion in 'App Development' started by Bob111, Jan 13, 2019.

  1. Bob111

    Bob111

    Anyone? I'm trying to migrate from my homemade ancient VB6 applications based on IB's 9.42 to 9.72 and VB.net. I got it all installed, API,IB's samples,Testbed etc,but I'm truly clueless,looking at it. What use to be a simple ActiveX drag and drop component,that anyone with a extremely basic level of programming can use became something so complex,that even in their own IB manual and examples IB saying-just use what we give you. don't even try to write your own.
    TWSAPI group doesn't have anything either. all I'm looking for is a very basic example of how how to put things together. how they work together,interacting between each other.
    simple project with a form,button to connect to TWS and respond from TWS back to user form. I spent a week,looking for a somerhing this simple,but unable to find anything that average joe shmoe like me would undestand. anyone?
    Thanks!
     
    tommcginnis likes this.
  2. gaussian

    gaussian


    Nothing about IB's API is simple. I wrote an integration in Python and in C++ and both tested my ability to code - and I do it professionally. The API is an RPC-type API but it is implement so poorly it's hard to even call it that. I've built and maintained RPC APIs and this was harrowing.


    Maybe I can help get you started with some overview...

    Going through the code (I haven't touched VB since VB6 in the early 00's):

    https://interactivebrokers.github.io/tws-api/client_wrapper.html

    This seems similar to the Python API. The API is callback based and so you have to do a few things to get it moving:

    1. `EWrapper` handles the callbacks being hit from the TWS side.
    2. `EClientSocket` who's functions are called to send messages from TWS.


    You must implement the functions you wish to be called in `EWrapper`. Every `EWrapper` function has a corresponding "sender" function in `EClientSocket` that you will use to send your side of the message.

    The way these architectures work is as follows:

    1. You establish a connection to the API (you only do this once see - https://interactivebrokers.github.io/tws-api/connection.html#connect)
    2. EClientSocket's functions are called, this sends a request to TWS/IBG for processing
    3. After processing, the result is deposited in an event queue called `EReaderSignal`
    4. EWrapper is notified and the proper function is called for the event in (2)

    This is a "two-thread" system where EClientSocket and EWrapper each operate in their own threads.

    If you implement the two classes correctly and instantiate them followed by connecting you should at least see an error message. If not, go back and start debugging each class above. A good function to start with is `error` which you can use to echo messages from the server to the screen with.

    Good luck.
     
    tommcginnis likes this.
  3. Turveyd

    Turveyd

    VB6 coder here ( not for trading ), I've used VB.NET and it's NASTY takes 5times as long, change a tables name and it crashes it, as it has to load the definitions and can't take the change, huge step backwards over VB6 sad really.

    I ended up, doing everything by SQL's, never linking a text box to a table directly, Update Qry to change data and Append to add new lines, rather than suffer the wizard that creates 200lines of code.

    Good luck :)
     
    tommcginnis likes this.
  4. Bob111

    Bob111

    Thank you for your support! As of now I rolled back to API 9.69. then converted their sample for VB6 project that comes with this API using VS 2005. Then, after this I converted it again from VS2005 using VB.net Community 2017 edition. Haven't tried yet on Windows 10, but at least looks like i'm moving forward. I was always using their activeX thing,which is pretty simple and understandable for a beginner level people. My main problem is that all latest samples are using .ddl and object(?) and I have no clue about it. but looks like this would be more gradual transition,rather just jumping from 9.41 to 9.72+ and VS 2017.
    my main reason to move to a newest API is a bracket orders. I want my stop and target sitting on IB's side, one canceling another,when either one is executed,not on my PC. From which version of API bracket orders are supported?
    I see them in 9.72
    https://interactivebrokers.github.io/tws-api/bracket_order.html
    are they supported in earlier versions?
    Thanks!
     
    tommcginnis likes this.