Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Architecture: real-time speed
Nick
To be clear the protocol I'm talking about is between TWS and the API client. I have not looked at the protocol between TWS and IB's servers.
toggle quoted message
Show quoted text
The easiest way to see what's going on is to look at the source code that IB supplies for its libraries. Pick whatever language you like and go through the code (it's what I did). In my view IB's libraries are unnecessarily complicated and convoluted but the most of the action is in what they call a reader which reads the socket and gathers the fields. You will see that it's just a bunch of null-terminated ascii fields going over the wire. There is similar code that gathers the arguments from client requests and sends the fields over the socket. The other part is the logon sequence. The last time I looked they had it scattered in a bunch of pieces but it's just sending a few fields back and forth to make the connection to TWS. You probably won't need a packet sniffer at all. Hope this helps. On 7/30/2021 9:15 AM, dent wrote:
I always wondered about the IB wire protocol but never took the time to look into it. Could you tell us where it's documented please? Also what do you use as a protocol analyzer?? Does wireshark have a plugin? |
Re: Architecture: real-time speed
Matthias Frener
On Fri, Jul 30, 2021 at 06:15 AM, dent wrote:
ed about the IB wire protocol but never Don't think it's documented somewhere. For a Typescript port I have reverse engineered it form the Java code. The protocol level would be this: But better to use the official Java codes a reference, Typescript might just be easier to read to get an idea. ? |
Re: Architecture: real-time speed
I always wondered about the IB wire protocol but never took the time to look into it. Could you tell us where it's documented please? Also what do you use as a protocol analyzer?? Does wireshark have a plugin?
toggle quoted message
Show quoted text
thanks for any help On 7/30/21 7:57 AM, Nick wrote:
It's not actually the API that has the architecture you describe - it's IB's libraries. |
Re: Architecture: real-time speed
Nick
It's not actually the API that has the architecture you describe - it's IB's libraries.
toggle quoted message
Show quoted text
TWS itself exposes the API through a single socket. Several of us don't use IB's libraries at all and wrote our own direct socket connection to TWS. You can then make any architecture you want. The wire protocol is simple so it's not a huge project but of course it is extra work and you will have to maintain the code from time to time as features change in the API. On 7/29/2021 9:19 PM, Eduardo Esteva Kremer wrote:
In a nutshell, I see this API has 2 threads: one for receiving messages (the reader) and another for processing them (the client). |
Re: Architecture: real-time speed
Matthias Frener
Agree with Graham. On UI it won't matter if it is 1ms late, you will not notice it. If you update tick values at 1ms rate (1000fps) this is like a Hollywood movie (24fps) at 41 times normal framerate. Your eye can't see that as number anymore, but it will be some blurry thing (I do 50ms refresh rate on UI which would be a 20fps and feels like way enough). |
Re: Architecture: real-time speed
Hey,
If your purpose is to just to display market/order data on a gui then I wouldn't worry too much about straight line speed. GUIs don't have to be that fast as the humans reading them aren't that fast. Rendering the data will be the slowest thing. The queuing approach you've described seems good to me. If you're only going to have a single GUI client per TWS then great, although if you wanted to fan out a single data feed to multiple consumers then you'd need a publisher of the data as a separate process then manage the multiple subscriptions. I think you'll be limited in performance only by TWS. It's not a high speed solution that could support a lot of connections. You'd want to use FIX I suspect. If you don't need to scale, then connecting things with buffers and blocking threads is good enough. Not sure exactly what you're trying to do but that's my view on what you've described. HTH, G. On Thu, 29 Jul 2021 21:19:06 -0400 "Eduardo Esteva Kremer" <eekremer@...> wrote: I am planning on adding a GUI like Qt to the TWS API in C++. |
Architecture: real-time speed
I am planning on adding a GUI like Qt to the TWS API in C++. In a nutshell, I see this API has 2 threads: one for receiving messages (the reader) and another for processing them (the client). These 2 threads connect with each other through a queue by using signal/wait. Instinctively, I would tend to connect the GUI to the client thread because it actually decodes messages and invokes the corresponding callbacks according to the type of message received. However, because messages must go first through the queue (signal/wait) I foresee some delays which could impact the display of real-time data on the GUI.? Another option is to connect the GUI directly to the receiving thread, so data goes straight to the GUI code (no queue, waits...in between). But this option would force us to call TWS API's decode functions and callbacks from this thread itself. And this seems a little unnatural. Any comments greatly appreciated !! Ed Kremer |
Re: 2 indicator template to use for moving average crossover strategies
Thanks for the feedback JR.? I will stop publishing templates here.? Apologies for the inconvenience to most of the 6000 members who are experienced traders in automated trading for years and do not use Python.?? Regards, Javed On Thu, Jul 29, 2021 at 9:31 PM JR <TwsApiOnGroupsIo@...> wrote:
|
Re: 2 indicator template to use for moving average crossover strategies
? ... but I am not sure that this group is the best place for you to publish your progress and code. The group has 6,000 members and many (most ?) have years of experience in automated trading and do not use Python. ? But there is a large audience that would greatly benefit from your templates and they are not members of this group. GitHub or similar code repository would be a much better home for your contributions. That way, anyone who is interested can browse all your templates in one place, you can collaborate with others, the community can help you improve your work, and those artifacts that really make your code valuable (such as documentation, howto guides, unit tests, and version control since something will change and improve) can be stored in one place. ? None of this can effectively take place within a group messaging environment such as [email protected]. ? Just a thought, and I might be wrong. Unlikely, but possible ? JR ? |
2 indicator template to use for moving average crossover strategies
Here is a template for creating 2 indicators at the same time on tick-by-tick data, so that you can use the 2 indicators for crossover strategies, etc.? Feel free to contact me directly with any questions or if you need any customized templates.? Happy to walk you through the code.??
Regards, Javed (ebtrader) import pandas as pd |
Re: ErrorCode: 200 Message: No security definition has been found for the request
¿ªÔÆÌåÓý
It turns out that my issue was actually retrieving option expirations that did not exist...problem solved.
I downloaded Contract Inspector that JR recommended from the link below.? It's very useful.
From: [email protected] <[email protected]> on behalf of Annie Yang <anniesilver@...>
Sent: Thursday, July 29, 2021 3:21 PM To: [email protected] <[email protected]> Subject: Re: [TWS API] ErrorCode: 200 Message: No security definition has been found for the request ?
I got lots of 200 error code when I was pulling the option historical bars, I contacted IB technical support and they told me that if I tried to view the same data from the TWS client , what I can see there is what I can pull out from the API. so, you
can view in TWS to see if you can get the bar you wanted there, if you can't that means there is nothing wrong with the code. But they did not explain why those data are not available.Maybe you can contact them for your case.
On Thu, 29 Jul 2021 at 14:26, Crow <aaroncook394@...> wrote:
|
Re: ErrorCode: 200 Message: No security definition has been found for the request
I got lots of 200 error code when I was pulling the option historical bars, I contacted IB technical support and they told me that if I tried to view the same data from the TWS client , what I can see there is what I can pull out from the API. so, you can view in TWS to see if you can get the bar you wanted there, if you can't that means there is nothing wrong with the code. But they did not explain why those data are not available.Maybe you can contact them for your case. On Thu, 29 Jul 2021 at 14:26, Crow <aaroncook394@...> wrote:
|
Re: ErrorCode: 200 Message: No security definition has been found for the request
When this happened to us, it was always related to our code. If you have not done so, consult Richard King's amazing ContractInspector? for a second opinion that does not use your code. I can attest the "This can be invaluable in resolving problems with the error 200 response to such calls."
JR |
Competitor brokers operating in the UK large cap market
Hi,
Not really a technical question, but I've just been looking at brokerage on CFDs for the UK main market in detail and the brokerage is wider than spread in large cap stocks. Maybe that's normal, but to someone who's worked on the institutional side, given the internal crossing opportunities for a large broker, it seems exploitatively high. And I'm some way off doing $10m/month in volume (more like 5) to access the cheaper pricing tiers. Maybe the solution is to look at mid-cap instead where the spreads are wider compared to brokerage. The big question though - are there viable alternatives to IB? It's very time consuming to dig in and find the actual pricing of all brokers operating in the UK market for large cap stocks who do DMA. Has anyone done this? Would you be willing to share your research? Cheers, G. |
ErrorCode: 200 Message: No security definition has been found for the request
¿ªÔÆÌåÓý
I am getting a lot of errors today when trying to pull historical daily bars on about half of the S&P500 stocks that I frequently query.
Here's the error message:
ErrorCode: 200
Message: No security definition has been found for the request
Here is the function that I use to pull the stock:
I define the contract using this function:
It's been working well for several years, but I started getting a bunch of ErrorCode: 200 errors today.? I tried the two commented-out ContractDetails lines near the top to fetch the contract ID, but that did not help.? I also tried setting the exchange to
"ISLAND" from the code examples, but that also did not help.? Is there something that I am missing?
|
Re: The 'All or None' order attribute may not be specified for this order.
Just checked the recent API sources and it looks like C++ and Python libraries do set eTradeOnly and firmQuoteOnly, explicitly to "true". That explains why youy get the warnings. We use the Java library which does not do that and both are false by default.
toggle quoted message
Show quoted text
Apparently both fields have been removed entirely from the "985.01 latest" build of the API that was released four weeks ago. On Thu, Jul 29, 2021 at 12:14 PM, Luke wrote:
|
Re: FINTA libary technical indicators applied to tick-by-tick data
Yea that is a much better way than how the python code is doing it with TA_LIB.? You could switch over to FINTA. On Thu, Jul 29, 2021 at 9:33 AM ebtrader <jsiddique@...> wrote: Good morning team, |
Re: The 'All or None' order attribute may not be specified for this order.
@JR Thanks, i think the link you sent explains it. There is a box at right showing how it can be used and the way i understand it is that it does not support TIF, which i am using.? Btw for the eTradeOnly and firmQuoteOnly, i was getting warnings about those and could not figure out why ( was not using it ), it stopped after i added these settings. |
Re: The 'All or None' order attribute may not be specified for this order.
Did you check (referenced at the bottom of the document you mention) whether the exchange and routing you have asked for actually support AON orders? For example, AON is only supported for US products.
toggle quoted message
Show quoted text
JR PS. Not sure that it matters for your issue, but eTradeOnly and firmQuoteOnly are not supported since 983 any longer. You may want to leave them alone and use the default value the API library for your langue uses. On Thu, Jul 29, 2021 at 11:29 AM, <lukepe3@...> wrote:
|
The 'All or None' order attribute may not be specified for this order.
I am setting up Buy Order. For now, i would prefer not to deal with partially filled orders as it creates many issues. I considered cancelling partially filled order in OrderStatus, but it seems as clumsy solution, which can result in situations where next fill happens sooner than OrderStatus gets executed and cancels the order and thus it would break anyway.
I was looking for an order setting, which would either automaticly cancel the order after partial fill or allow only for filling the whole order. I found order setting allOrNone This is code i am using for buy order
I am getting this error message:?
The 'All or None' order attribute may not be specified for this order.
?
In the TWS docs, it says that i can be applied to all order types
? |