IB API HOWTOs and Guidelines - For Beginners

fact is you talk about IB here in this thread and have NO SINGLE IDEA how IB and TWS and its Gateway work, you made that apparently clear. Other users, such as vicirek pointed you in the right direction but you are ignorant. Then you made a tool out of yourself and your stupid OOP comments. Good luck with your Python IB execution module, written by someone who has no clue about how the IB interface works, has no clue about OOP languages, and suddenly claims to know the inside scoop of BNP and SocGen. You are just a fart, on ignore.

well at least I can speak several languages, can you ? probably not,

Python can do OOP you silly idiot, but it's not required. That's the beauty of it.

And what is it with your "Status Quo" thing ? you have no clue what's being done these days, you don't have access to every projects on the planet, so stop making silly claims about status quo, you have no fucking clue and it feels like you are trying to prove yourself by hiding behind some "invisible" status quo thing, like we should give a fuck about it.
 
fact is you talk about IB here in this thread and have NO SINGLE IDEA how IB and TWS and its Gateway work, you made that apparently clear. Other users, such as vicirek pointed you in the right direction but you are ignorant. Then you made a tool out of yourself and your stupid OOP comments. Good luck with your Python IB execution module, written by someone who has no clue about how the IB interface works, has no clue about OOP languages, and suddenly claims to know the inside scoop of BNP and SocGen. You are just a fart, on ignore.

what an angry little turd you make,

where is your thread explaining how IB works ? oh wait, you didn't make one. And how user vicirek pointed me in the right direction ? wtf are you talking about ? I made pretty clear from the start that the purpose of this thread was to build a simple and functional Python module to use IB APIs. Somehow, you got offended when I pointed out that OOP wasn't necessary for building batch trading applications.

You sound like an angry loser, sorry to say. Why don't you go play somewhere with C# on some Microsoft forums for miserable programmers like yourself. Put me on ignore if you are so offended by those truth, since you seem to be simply another coward.

gee, who needs another angry developer :LOL:
 
here this is how it is done...

Code:
# Define a function to catch "OrderStatus" and "OrderState" type messages from IB Server
def status_orders(msg):
  global ft
  #dump(msg)
  print "Status: ", msg.typeName, msg
  #ft.write("%s [%s] %s\n" % (datetime.datetime.now().strftime("%Y-%m-%d|%T"), msg.typeName, msg))
  ft.write("%s:%s:%s:%s:%s:%s:%s\n" % (msg.typeName, msg.orderId, msg.status, msg.whyHeld, msg.avgFillPrice, msg.filled, msg.remaining))

# Map server replies to "status_orders" function client requests
ibgw_conChannel.register(status_orders, 'OrderStatus','OrderState')

#print "Requesting All Open Orders..."
ibgw_conChannel.reqAllOpenOrders()
Butterfly, this is awesome. Thanks, unfortunately I had to move on to programming my app in Java. But I'm sure others will find this useful. Is the ft variable now just a string of the OrderStatus() message? I could just use string processing to get the filled=0 value (0) into a "filled" variable?
 
Butterfly, this is awesome. Thanks, unfortunately I had to move on to programming my app in Java. But I'm sure others will find this useful. Is the ft variable now just a string of the OrderStatus() message? I could just use string processing to get the filled=0 value (0) into a "filled" variable?

don't pay attention to "ft", it's a file descriptor to handle an open file to write "logs" and "trades" in my code.

the function can also be written like this:

Code:
# Define a function to catch "OrderStatus" and "OrderState" type messages from IB Server
def status_orders(msg):
print "Status: ", msg.typeName, msg.orderId, msg.status, msg.whyHeld, msg.avgFillPrice, msg.filled, msg.remaining

the "msg" variable is an object and msg.filled is the attribute that contains the number of shares filled, so there is no string transformation or anything else to do. It's already assigned and it's numeric. Therefore you could use it like any other numeric variables. See below:

Code:
if msg.filled == 0:
    print "Trades not filled, still in progress"
else:
   print "Trades Done, Average Fill Price = %s, Shares Remaining =  %s" % (msg.avgFillPrice, msg.remaining)

Voila !!!
 
don't pay attention to "ft", it's a file descriptor to handle an open file to write "logs" and "trades" in my code.

the function can also be written like this:

Code:
# Define a function to catch "OrderStatus" and "OrderState" type messages from IB Server
def status_orders(msg):
print "Status: ", msg.typeName, msg.orderId, msg.status, msg.whyHeld, msg.avgFillPrice, msg.filled, msg.remaining

the "msg" variable is an object and msg.filled is the attribute that contains the number of shares filled, so there is no string transformation or anything else to do. It's already assigned and it's numeric. Therefore you could use it like any other numeric variables. See below:

Code:
if msg.filled == 0:
    print "Trades not filled, still in progress"
else:
   print "Trades Done, Average Fill Price = %s, Shares Remaining =  %s" % (msg.avgFillPrice, msg.remaining)

Voila !!!
Butterfly, I ran across a short IBPy tutorial by sentdex on YouTube. Also, many videos he has uploaded on just about anything Python:
https://www.youtube.com/user/sentdex/videos
 
Hello,

I'm trying to write simple gui for IB API. I have already connected to reqMktData without any problems. Now i'm trying to connect to reqMktDepth, but I don't obtain any data or errors. I'm working on demo IB API demo version. Any ideas why it happens? I call it this way.

Code:
reqMktDepth(requestReference, contract, 20,
                new Vector<TagValue>());

It's same like reqMktData.

Thx for help!
 
Can someone provide the code for bracket order (Stoploss/Profit Target)? Thank you.

you just set create a new order and set m_parentId to the initial order

def createBracketOrder(origOrder, oID, tif, orderType,price):
bracketoptOrder = Utils.makeOptOrder( Side.flipside(origOrder.m_action), oID, tif, orderType,price,origOrder.m_totalQuantity)
bracketoptOrder.m_parentId = origOrder.m_orderId
return bracketoptOrder
 
Back
Top