Saturday, March 7, 2009

Upgrade To API v. 9.60

It has come to my attention that IB released their newest API version 9.60 on Jan 20, 2009. As mentioned in the last post, one drawback of the API's asynchronous request and callback model is that there's no way to tell if all the information has been returned. In the case of reqAllOpenOrders() method, a workaround is to intentionally issue a reqMktData() with an invalid ticker to intentionally generate an error. The developers at IB must have agreed that this is a flaw in their model. So in the latest API release, new methods have been added to the EWrapper interface to indicate that callback requests have ended.

I have decided to use this API version for my project. The process of replacing API version 9.51 with 9.60 is relatively simple. I just had to edit Java source code (Proof Of Concept - 4 of 8) and create a new version of TwsApi.jar file (Proof of Concept - 5 of 8). Finally I had to incorporate the new callback EWrapper methods in each of the code examples in Proof of Concepts - 8 of entries. The code to be added is as follows:

# ---------------------------------------------------
# new callback methods added in API 9.60
# ---------------------------------------------------
def openOrderEnd() # invoked when all orders are sent to a client as a response to reqOpenOrders()
end

def accountDownloadEnd(account_name) #invoked when a complete snapshot of an account state is sent to a client as a response to reqAccountUpdates()
end

def execDetailsEnd( req_id) # invoked when all executions are sent to a client as a response to reqExecutions()
end

def deltaNeutralValidation(req_id, under_comp) # for Delta-Neutral DN RFQ
end

I will go through each of the Proof Of Concept entries and update them to comply with API v. 9.60.

No comments: