Generally it's not that simple if you have to write the whole program.Quote from clarodina:
how to code a small program to do simple computation from number from ib platform and send order conditionally?
Quote from clarodina:
how to code a small program to do simple computation from number from ib platform and send order conditionally?
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()
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));
}
}
Quote from 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.
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.Quote from michael45:
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.
I have no experience with Python, but a quick googling gives for example the following libs/interfaces/wrappers:Quote from Goldorakk:
Rosy,
Where does the IB python API you use come from?