simple program

Discussion in 'App Development' started by clarodina, Nov 3, 2012.

  1. how to code a small program to do simple computation from number from ib platform and send order conditionally?
     
  2. mutluit

    mutluit

    Generally it's not that simple if you have to write the whole program.
    You need to be an experienced programmer in the language of the API (C++, Java, C# etc.).
    Just study the IB API for your programming language and operating system platform:
    http://www.interactivebrokers.com/download/newMark/PDFs/APIprintable.pdf
    http://www.interactivebrokers.com/en/software/api/api.htm
    http://www.interactivebrokers.com/en/p.php?f=programInterface

    It could be cost- and time-efficient to hire a developer with experience in the API.
     
  3. jasonc

    jasonc

    Microsoft excel I have found to be the most user friendly way to create your own basic programs. I think a lot of platforms can be accessed using VBA to calculate and activex to trade. I think interactive brokers can, the spreadsheet they provide also has a lot of code you can learn from to do whatever you want.
     
  4. 2rosy

    2rosy

    use the python API. its so much faster to develop in and if you're worried about speed dont use IB.


    Code:
    from sys import argv
    from time import sleep, strftime
    from trading import *
    from baseapp import  *
    import numpy as np
    
    from ib.ext.Contract import Contract
    from ib.ext.Order import Order
    from ib.ext.EWrapper import EWrapper
    from ib.ext.EClientSocket import EClientSocket
    from ib.ext.ExecutionFilter import ExecutionFilter
    
    #~~~~~
    #    [url]http://bit.ly/rUGFwD[/url]
    #~~~~~~
    
    class ReferenceApp(BaseApp):
        def blast (self):
            for q in self.subscriptions.values():
                if q.isReady():
                    better = q.strategy.better(q)
                    optContractX = q.contract
                    if q.bidqty>q.strategy.showing:
                        oid= self.nextOrderID()
                        optOrderX = Utils.makeOptOrder( 'BUY', oid, 'DAY', 'LMT',q.bid + better,q.strategy.size)
                        self.placeOrder(oid, optContractX, optOrderX)
                    ##
                    if q.askqty>q.strategy.showing:
                        soid= self.nextOrderID()
                        optOrderS = Utils.makeOptOrder( 'SELL', soid, 'DAY', 'LMT',q.ask - better,q.strategy.size)
                        self.placeOrder(soid, optContractX, optOrderS)
    
    
    
        def subscribe(self):
            for e in ['20121026']:
                for s in np.arange(7.65,7.8,.05):
                    print s
                    cid = self.nextConID()
                    optContract = Utils.makeOptContract('ZC', e, 'C',s,exchange='ECBOT')
                    s=Strategy(maxspread= .125 * 8,minspread= .125 * 5,showing = 3,size = 1,tick=.125)
                    qt=Quote(optContract)
                    qt.setStrategy(s)
                    self.subscriptions[cid]= qt
                    self.connection.reqMktData(cid, optContract, '', False)
                
    if __name__ == '__main__':
        app = ReferenceApp()
        app.eConnect()
        app.subscribe()
        app.blast()
        sleep(5)
        app.cancelAll()
        
    
     
  5. really new to this area

    how to use the python code and for vb is there some open source platform spreadsheet using vb with some example vb code?
     
  6. in tradelink it would be something like :

    Code:
    public class MyStrategy
    {
    
    public void GotTick(Tick k)
    {
         if (k.isTrade && k.hasAsk && (k.trade==100)
            sendorder(new BuyLimit(k.symbol,k.ask,k.AskSize));
    }
    }
    
     
  7. Hello mutluit,

    I have knowledge in C programming language, So can I learn quickly C++, Someone said if I can learn Java. It is better than C++ for this.
    I also hope your answer about it too.

    Thank you.
     
  8. Goldorakk

    Goldorakk

    Rosy,

    Where does the IB python API you use come from?
     
  9. mutluit

    mutluit

    Plan to invest at least 6 months to be fit in such OOP languages like C++ or Java. And, do it only if you plan to be a professional programmer, as the investment in time and intellect is not small.

    I have seen veteran C programmers who couldn't understand the "object concept" (class concept), ie. OOP...
    Sure, using a C++ compiler one can program also in C, but it won't help when it comes to use an OOP-API like the IB API, then C++ (or Java) is needed...

    Just take a look into a C++ beginner's book to check if it is something for you. I'm not uptodate with literature, but 5 years ago or so Lippman's book "C++ Primer" was much in use for teaching...

    -
    OOP: object oriented programming (C++, Java, C#, etc.)
     
  10. mutluit

    mutluit

    I have no experience with Python, but a quick googling gives for example the following libs/interfaces/wrappers:

    http://code.google.com/p/ibpy/
    "IbPy is a third-party implementation of the API used for accessing the Interactive Brokers on-line trading system. IbPy implements functionality that the Python programmer can use to connect to IB, request stock ticker data, submit orders for stocks and futures, and more."

    http://sourceforge.net/projects/ibpy/

    http://code.google.com/p/pytws/
     
    #10     Nov 5, 2012