Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: I have a hard time doing Paper Trading
In my opinion a MKT order that doesn't get filled when it should have been means that the platform doesn't work. Is not an API issue, because even if I place the trade from TWS GUI is the same, even 20, 30 minutes to fill a MKT order.
I don't rely in paper trading to test the strategy, I did backtesting, and used it on other platform, but I have to test the integration of the strategy into the platform, , connection, data, orders and others. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: TWS startup parameters
User settings are stored in a local directory and nothing prevents you from having multiple folders with different settings and layouts. To set the folder on the command line:
Also, it's convenient to uncheck "Use/store settings on server" in the login screen in order to start with a clean slate. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Intraday VWAP standard deviation channel
A lot of these differences ("discrepancies"?) come from the variation on the original data set. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: I have a hard time doing Paper Trading
You can call the Help Desk and have them track the messages sent between your app the IB to find out what's the problem.
On Thursday, July 20, 2023, 09:28:10 AM EDT, flaviupaul@... <flaviupaul@...> wrote:
Hello, Any advice would be helpful. ? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I have a hard time doing Paper Trading
Hello, Any advice would be helpful. ? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Intraday VWAP standard deviation channel
Hi,
TWS charts have the intraday vwap volume study feature which has a checkbox to also display standard deviation channels together with its?vwap (under Studies.. -> Volume Studies -> Intraday Volume Weighted Average Price). I am trying to replicate those studies, but I am ending up with different results for the standard deviation (STDEV) channels. It is not clear to me how IB/TWS calculates these channels. So I am wondering if somebody knows either a) an API request to pull the STDEV information, or b) how IB/TWS calculates the STDEV channels? Much appreciated! Thanks, Simon |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: can not place order after updated to TWS 1019.2
By checking I meant that you look for the new sample code exactly on the function/procedure where you get your errors?with the old excel sample, check the differences. I think on the excel sample there is an example of how to use the whatif functionality, isn't it? El dom, 16 jul 2023 a las 9:06, Zoran via (<zoran_sevo=[email protected]>) escribi¨®:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Sent multiple bracket orders (open, takeprofit, stoploss, exit at time), but 1 of them only took (open and exit at time)
It happened again today but this time, only the MIT part of the order was missing from 2 of the orders. Here is a screenshot. IB got back to me after I sent them the logs, they told me that, After reviewing your logs further, we saw that almost all of your orders are using the same set of order IDs, 71, 73, 74, 75. Given Interactive Brokers does not allow order IDs to repeat, it means that either all subsequent orders are having an error for duplicate order IDs, or the more likely reason is because there is some other error rejecting the order initially.I am not sure how to fix, am I advancing through each bracket / new parent order wrongly here???
As such, we noticed the average API connection time was no more than about 150ms before you had disconnected. We would ask that you remain connected for at least 1 second before disconnecting. Please try your standard code, with the extended connection time, and let us know if any messages are returned. The increased connection time should allow for order status and error messages to return.Do they mean I should put a time.sleep(1) after I finish my loops? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Meaning of Message 1102 (2104, 2106)
You are coming to the wrong conclusions, Greg. The situation is very different when an existing subscription experiences errors 1100/1102 and when you subscribe to additional instruments. HMDS servers provide more than just ¡°historical data¡± and are involved during the subscription request, but they do not provide real-time data once the data feed has started. So it is safe for TWS/IBGW to disconnect HMDS farms at any point. Here a quick overviw (as I understand it): TWS/IBGW establish a connection to port 4001 of a ¡°primary server¡± at IBKR which is required to always be active. Primary servers are responsible for everything from login and account management to order processing, order status, and real-time data subscription permissions and management. They are located in several regions around the world, and their names look something like ndc1.ibllc.com. TWS/IBGW is always prepared to switch over to one or two redundant hot-standby backup primary servers in a different region. When the connection to the primary server is lost, TWS/IBGW will have very limited functions (or stop functioning all together). Error code 1100 is sent when the connection is lost, and connection restoration is indicated with codes 1101 (data and subscriptions may have been lost) or 1102 (no data or subscriptions have been impacted). Depending on the reason for the disconnection and in case it is brief, existing market data feeds may actually continue while the primary server is disconnected. TWS/IBGW connect to various data servers (¡±farms¡±) as soon as data from those farms is needed. Under certain circumstances, TWS/IBGW will disconnect from those farms when they are no longer needed and indicates that with ¡°is inactive¡± codes 2107, 2108, and 2159. This has no impact on any subscribed services and connections will be reestablished transparently and instantaneously when the need arises. Your code can safely ignore these codes. For a variety of reasons, connections to these farms can be lost while they are still in use. That can result in service disruption or delay and is indicated by the ¡°is broken¡± error codes 2103, 2105, and 2157. While it generally does not impact the subscription itself (data feed will restart and the connection is restored) your code may want to be aware of these codes and flag extended periods of disconnection especially outside of the daily IBKR maintenance/reset windows. Once a connection is established to a farm (for the first time, after a period of inactivity, or after a broken connection), TWS/IBGW will send ¡°connection is OK¡± codes 2104, 2106, and 2158. When you subscribe to a real-time market data feed TWS/IBGW perform the following steps:
While there is an active market data subscription, TWS/IBGW will keep the market data farm connected and there is nothing you need to do. Once the last subscription handled by a farm is cancelled, you may see an ¡°is inactive¡± code 2108 for that farm. A few thoughts on next steps for you. If you experience stalling real-time market data subscriptions after a 1100/1102 sequence, I suggest you enable the ¡°Create API message log file¡± and the ¡°Include market data in API log file¡± options in TWS/IBGW for a while. That way you can verify that really no market data is being sent after 1102, or whether data is sent but the callback logic in your client is somehow malfunctioning. I¡¯d reach out to IBKR for a solution if that log indeed shows that data was sent until 1100 but never restarted after 1102. We have never experienced that. IBKR generally assigns your primary server based on your location and the kinds of instruments you work most with. But they can, if necessary, permanently assign your account(s) to a specific region. Your primary server defines when your daily server reset times are. You will have the most stable service if your TWS/IBGW has reliable connections to all IBKR primary servers in the world (since at any point TWS/IBGW might have to switch over), but at least to the one assigned to your account. IBKR provides? a simple tool at you can use to verify that your TWS/IBGW machine can indeed connect to all of these servers. If you want to learn more about how these things work (and you have some time on your hand) you can enable ¡°Help¡úTroubleshooting¡úEnable Verbose Logging¡± and ¡°Enable HMDS Logging¡± and follow a subscription and the subsequent data feed yourselves. Here a quick overview about the "good" and 'bad" codes:
? ´³¨¹°ù²µ±ð²Ô |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Intermittent IBGW connection problems 10.19.2a
Ewald de Wit
On Sun, Jul 16, 2023 at 04:07 PM, John wrote:
An "Inactive" order can become active again, so it's not certain that it's done yet. -- Ewald |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(Paid) Finishing up a software
Hi, I am looking for a coder to finish a semi functional code in python. This code has been organized and reviewed so it will be easy to work with but it still has a few bugs, needs another asset integration and a tweak in logic. Also it needs to be more reliable and disconnection proof. If interested please contact me directly to my email?Ferreira.helhazar@.... ? Let me know if it works for you! ? Thanks |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Intermittent IBGW connection problems 10.19.2a
Thanks Jurgen for the detailed reply.
?uses a similar approach to mine, with the two below sets, and monitoring order.fills. Unsure why Ewald chose to isolate the 'Inactive' state rather than adding it to the DoneStates btw. ? ? DoneStates: ClassVar[Set[str]] = {'Filled', 'Cancelled', 'ApiCancelled'}
? ? ActiveStates: ClassVar[Set[str]] = {'PendingSubmit', 'ApiPending', 'PreSubmitted', 'Submitted'} I don't like the asyncio module, and prefer to use a tailored combinations of Threads, Events and Timers, but we are essentially doing the same thing. I will play with the??to see if it adds any value over my current setup. I also trade futures and restart daily after the close, "units" that's a very interesting concept. I also considered monitoring positions myself, deducting them from order status updates, especially useful when 2 strategies trade the same contract on the same account, it allows differentiation. However I just preferred to avoid it so far in order to keep no stored info whatsoever on the client side, and rely solely on the server side info at all times. Indeed not the topic of this thread, thanks for sharing insights anyways, much appreciated. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: can not place order after updated to TWS 1019.2
¿ªÔÆÌåÓýHi Joan, Thanks for your comments and suggestions. I¡¯ve tried using the newest API from IB but I get number of compile errors with my Excel file. I¡¯ll have to look first at those issues.? I thought it would be easier if I just update TWS and stay with my current API since everything works well. Best On 15 Jul 2023, at 11:26, joanmarcel119 <joanmarcel@...> wrote:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TWS startup parameters
Are there any? It's not an API question but sometimes I'd like a completely different layout to do some research or try out different features without messing up my "standard" layout.
I realize I can save and load specific layouts but the default behaviour of exiting and saving the current layout means I need to manually manage the whole process. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: can not place order after updated to TWS 1019.2
Hi Zoran! I don't use the whatif API function yet and?I can not check this, but why don't you download the newest API software from IB (first rename the old folder usually on C:\TWS API) and then check the "new" IB's sample excel again? Maybe there is some new logic there and you could adapt your excel easily. Hope that helps El vie, 14 jul 2023 a las 23:30, Zoran via (<zoran_sevo=[email protected]>) escribi¨®:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Intermittent IBGW connection problems 10.19.2a
In general, reqMktData feeds seem to be quite stable and timely, too, John. Though we use them only to give context to our TickByTick and Level II data feeds, so we have less analysis for them. Keep in mind that most reqMktData feeds are aggregated over various time periods. As an example, here a few highlights from a quick review of our June 2023 five second real-time bars (the ones you request via ). We get those for 50+ instruments and I looked at the arrival delay. Basically "arrival time" minus "bar time plus bar width":
Our API clients are not impacted since we have our own implementation of ¡°Position¡± and ¡°PNL¡±. The IBKR implementations may make sense for human traders but never worked for us (even when they are correct). Our biggest problem is that PNL resets around midnight. We work in ¡°units¡± of CME futures trading sessions (17:00 to 16:00 US/Central next day) and API clients get confused when position PNL suddenly resets ¡°around midnight¡±. We have found execution reports, commission reports, and even order status updates to be very reliable and timely. Our (Java) framework is multi-threaded, entirely event driven, broken into many small focused domain classes, models, and controllers/managers. It is completely separate from and unaware of TWS API. A thin adapter layer translates abstract framework operations (such as placing orders) into actual TWS API requests. That layer also converts TWS API responses into framework events that are independent of TWS API. Certain framework events (such as market price update events) are broadcast so that position controllers can easily maintain their own notion of current PNL. We rarely have partial order fills, but TWS API order status events and execution reports are very accurate and timely so that position controllers can adequately model reality based on streams of order state, order status, execution and commission reports, and market price update events. The framework uses a domain/class/model hierarchy that looks something like this: Accounts ¡ú [1:*] Account ¡ú Positions ¡ú [0:*] Position ¡ú Trades ¡ú [0:*] Trade ¡ú Orders ¡ú [0:*] Order Our API clients never have to restart or resubscribe during the trading session in response to TWS API activities. There are, however, controlled automatic daily restarts of TWS and API clients during the one hour per day when Chicago futures markets are closed.
You need to make sure your client does not assume any order or timing of events (order state, order status, execution reports, errors), can tolerate the occasional duplication of updates, takes all events into consideration (not just order status), and does not block the TWS API callback thread. We make heavy use of the Java built-in concurrency features from , specifically the (a Java language concept, has nothing to do with CME future contracts). I believe some of those concepts are available in Python through the . Another good source for ideas how you can better structure your Python clients may be Ewald de Wit¡¯s project. But we are meandering away from the scope of this post and and the group. ´³¨¹°ù²µ±ð²Ô On Wed, Jul 12, 2023 at 02:13 PM, John wrote:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
can not place order after updated to TWS 1019.2
Dear all,
? I've been using TWS version 981.3c for number of years without problems. Communication between ExcelActiveX spreadsheet and TWS worked flawlessly. Recently IB has announced that they will stop supporting this version and that the minimum supported version will be 1019.2.
? To bypass these errors, I specified the 'firmQuoteOnly' and ¡®EtradeOnly¡¯ order attributes as false. ? With the above modification the error message was gone, my order was sent and TWS responded with the message ¡®Submitted¡¯. However, my order never arrived at TWS. There was nothing listed under that tab showing active orders. ? Does anyone knows what are the changes in the TWS version 1019.2 comparing to 981.3c that could cause that my software can not place order any more? ? How can I find out what went wrong when placing the order? ? Thank you in advance for you help. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: gateway version dependent error 10089
The insync group is generally a better place for ib_insync related issues, but I have the feeling you are correct and there are behavioral differences between TWS/IBGW V9 and V10 versions. Keep in mind the TWS/IBGW 981 track is more than two years old. I can't recall where I saw it, but there was a comment about requesting market data via SMART in one of the IBKR TWS API or market data documents. It basically said that? you need market data subscriptions for all exchanges that SMART routing works with for a given instrument. When you call reqContractDetails for SPY/STK/SMART/USD through TWS 981 versus your V10 versions, is there any difference in the list of valid exchanges? You could try 'ARCA' instead of 'SMART' when you request market data since 'ARCA' is the primary exchange for SPY. But your market data feed would likely be focused on trades that take place only at 'ARCA'. Also review your market data subscriptions a the error suggests. Adding the missing subscriptions may not be too expensive or may even be cost neutral. Just a guess, ´³¨¹°ù²µ±ð²Ô Dear all, |