Keyboard Shortcuts
Likes
Search
Re: Question regarding reboot of trader workstation
¿ªÔÆÌåÓýThanks for another great post ´³¨¹°ù²µ±ð²Ô ¨C I don¡¯t know how you find the time! Are you aware that there¡¯s this thing that humans are supposed to do, called ¡®sleep¡¯ if I remember correctly? ? I just wanted to mention that in fact it wasn¡¯t me that started this Group. It was created, within the now-defunct Yahoo Groups, by a user known as ¡®marinindextrader¡¯ (you can see his very first post, dated 8 June 2002, at /g/twsapi/message/1). I joined the Group in early May 2003, and I was invited to become a Moderator some time mid-noughties. Eventually ownership of the Group was transferred to me. I was responsible for the move from Yahoo Groups to Groups.io in January 2017 (the first post after the transfer is here: /g/twsapi/message/36779). In September 2021 I invited ´³¨¹°ù²µ±ð²Ô to become co-owner of the Group to ensure its continuity in case of any personal mishaps ¨C and I¡¯m delighted to say that this was an excellent choice. ? I absolutely underscore everything that ´³¨¹°ù²µ±ð²Ô says. The API is mature, reliable, performant and has tremendous depth and scope of functionality. I got my first autotrading system running live on 24 September 2003. I¡¯ve been using the API all day every trading day since then. Back then it had a lot of rough edges and missing functionality (though few actual bugs), and it was necessary to use a number of tricks to get round some limitations in the API (for example, if you requested contract details, there was no ¡®end¡¯ callback, so you couldn¡¯t directly know when you¡¯d got all the contracts resulting from a request, but I managed to find a workaround). ? You can get some idea of how far IB have come since then by the fact that the both TWS and the API libraries are very roughly ten times the size they were back in 2003. ? So, please let¡¯s not hear suggestions that IB¡¯s software is crap. It¡¯s not. ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of ´³¨¹°ù²µ±ð²Ô Reinold via groups.io
Sent: Saturday, August 5, 2023 8:06 PM To: [email protected] Subject: Re: [TWS API] Question regarding reboot of trader workstation ? Just because you don't like a design detail does not make it a design flaw, Arthur. Many of our group members are running rock stable automated trading systems based upon TWS API, some of them do that for more than 20 years, and Richard King created this mail group in 2002. There are aspects of TWS API that I personally would have designed differently, but it appears to me that TWS API is not fundamentally flawed. You still have to get a much better understanding of TWS API, use it in a real (paper) account, and spend more time studying and understanding the . You clearly don¡¯t have a grasp of TWS API yet if you seriously believe you ¡°will avoid using the request() functions that need an ID ¡¡±. TWS API is a low level, simple, and very fast asynchronous real-time protocol that is only concerned with the exchange of messages between your client app and TWS/IBGW within the current session (the time between connect() and disconnect() or when TWS/IBGW closes the connection). It connects your client with a complex trading world (any imaginable combination of accounts at IBKR, hundreds of exchanges, virtually unlimited number of tradable instruments) and relays to your client app(s) in real-time all events that trading world generates. The API uses ephemeral IDs to relate one or more responses with a specific request and the actual ID values have no relevance once the session ends. IDs that fall into this class are orderIds, reqIds, and tickerIds. Due to the real-time, asynchronous, and event-driven nature of the protocol, the design encourages maximum autonomy for clients and TWS/IBGW each. Therefore, your client application is in charge of and free to select the actual ID values with very few limiting requirements:
In a regime where TWS/IBGW restart daily, a client session cannot be longer than approx. 24 hours. At a rate limit of 50 requests per second, no client can generate more than 4,320,000 valid requests or orders during each session (practically only a tiny fraction thereof, though):
As I said before, the scope of orderIds, reqIds, and tickerIds is one session for one client. In other words, identical numeric IDs can (and probably will) be used when a client reconnects for a new session or when several parallel clients have their own sessions. Objects with life spans of more than one session, therefore, have permanent identifiers that are different from ephemeral session IDs:
My suggestion is you forget about the IDs since there will be many and more important challenges ahead of you. Apply the ¡°set and forget¡± and ¡°keep it simple¡± principals, add a few lines of code to the interface between your clients and TWS API, and manage IDs just like we and many others do successfully for years:
All ephemeral data (such as orderIds, reqIds, tickerIds) will be gone once your client disconnects or TWS/IBGW restart (since they are obsolete), but any account level information is retained within the IBKR infrastructure and can be retrieved by your client app as needed. Please refer to the TWS API guide, but among others, you can request:
Hope this helps, ´³¨¹°ù²µ±ð²Ô On Sat, Aug 5, 2023 at 03:32 AM, Arthur wrote:
|