Basic Question re API

Discussion in 'Trading Software' started by Babak, Apr 9, 2003.

  1. Babak

    Babak

    ok I know this may sound silly but what the heck is an API (I know its an acronym) but what is it exactly? what does it do? What is DDE? How do you set it up? How do you use it? etc...

    I'm not a software expert and have never programmed but would be interested to find out if there is a way that I can 'automate' a part of my trading.

    Thanks in advance.
     
  2. corvus

    corvus

    API is "Application Programming Interface", and that means "a set of routines, protocols, and tools for building software applications". Basically, an API exposes some functionality that you can use to build something bigger and better on top of. For instance, Windows itself has an API that let's programmers write things like IE or Windows Media Player. In the case of IB, it exposes most of the functionality in IB in a way that lets programmers write applications that use IB in ways that the developers of TWS never intended, ie my simulator (http://www.cicleworks.com/ibrapp.html). :)

    DDE stands for "Dynamic Data Exchange", which is just a feature in Windows that lets two running applications exchange data (if the applications themselves are set up to use it). So, IB TWS can pass data to Excel via DDE...it's kind of like an API, but not as full featured or flexible and requires less programming knowledge on the part of the user. You might use it to write a graphing or data-crunching spreadsheet in Excel, but using DDE you don't have to write a bunch of code, you just "link" to TWS using DDE just like using the clipboard (copy-paste). If you are pretty good at using Excel but not too familiar with programming, this is definitely the way to go...
     
  3. Babak

    Babak

    ok thanks for the basics...now how would one set about learning and putting that stuff into action?

    are there some good web resources? books? etc...

    again...TIA
     
  4. m_c_a98

    m_c_a98

    quickest way is to learn Visual Basic, then get a broker that gives you API connection through an ActiveX control.

    That's the fast track.
     
  5. corvus

    corvus

    For an API like IB's Java or C++ API, there's a bit of a learning curve, because you have to learn how to write an application in Java or C++ or VB first. If you want to go that route, best bet is to use any of the countless introductory books, or for Java specifically, Sun's got a great tutorial that will give you the basics at http://java.sun.com/docs/books/tutorial/. The second step would be to learn how to use IB's API to connect to and manipulate IB, for which I would advise to just take a look at someone else's code...either IB's samples, or some of the code freely available on the web. IB has sufficient documentation in the TWS User's Guide and there's alot of info in the discussion forums on the API. But be forewarned...this is the long approach. IB's API is decently sophisticated and learning to write an application well enough that it doesn't have bugs takes time. And having bugs in trading software can get expensive...

    edit: m_c_a98 is right...VB would be easier to learn than Java or C++ for coding with the API, but would still be more difficult, imho, than going the excel+DDE route.

    The best route for a beginner to programming is to use DDE and Excel. You can do some pretty sophisticated things with Excel, including buttons and all sorts of interactive stuff. Again, the best route is to get a book on using excel, and then take a look at things other people have done and play around. I know there's a lot of excel spreadsheets out there that use IB's DDE link. If you download the API from IB's website, I believe there's a sample one called "TwsDde.xls". Doing something this route would be far easier and probably more robust.

    For the DDE, here are some links to check out:

    http://groups.yahoo.com/group/twsapi/
    http://hometown.aol.co.uk/nqtraderman/myhomepage/business.html
     
  6. def

    def Interactive Brokers

    Babak,

    If you are not a programmer then you're probably better off letting someone else do the work. However it never hurts to try and depending on what you're trying to do, it is not that hard to get started. For example, if you wrote some macros to enter a basket of stocks from a spreadsheet into the TWS, you would be using the API.

    To get started, download the API http://www.interactivebrokers.com/cgi-bin/tws_windows_users.pl from IB. The installation package includes the C++ Socket, Java Socket, DDE, and Active X API's, plus sample code for each.

    Play around with the sample code with the demo as it might be a good start. On the IB web site discussion board, there have been numerous people who have been very helpful with ideas. I also understand that there is a twsapi group on yahoo as well. (whatever you do, don't come to me for help, outide of perl and awk scripts, my programming days are long over :) )
     
  7. Babak

    Babak

    Thanks guys, I appreciate all the help. I'll try the basic stuff and ask a programmer friend for the rest.
     
  8. cashonly

    cashonly Bright Trading, LLC

    You should also get some pointers from your brokers technical people.

    And if you get a programmer, definitely make sure they know what they are doing with trading systems. This isn't an office accounting package. One small mistake in the code could drain your account in an instant!
     
  9. Using IB's Excel DDE worksheet, could someone tell me the proper format for class "A" or class "B" shares?

    I've tried a space, no space, underline and no luck.

    Thanks for your help.
     
  10. nitro

    nitro

    Add a space after the symbol and:

    pra for preferred a
    prb for preferred b
    pr for preffered

    For example, C PRW for the Citi preferred W shares.

    nitro
     
    #10     Nov 7, 2003