¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 ¿ªÔÆÌåÓý
Date

Best method for getting level 2 market depth snapshots on a large number of equities

 

Hi all.

As most probably know, even if paying for extra streams, there is a hard limit of around 10 market depth streams that can be open at any one time. If I wanted to see a snapshot of level 2 depth data on, say, 30 stocks, what is the best way of accomplishing this?

What I currently do is this: Let's say I'm allowed to have 5 open depth streams at once. Then in my code I have a loop that iterates through my list of 30 stocks, but ensuring that only a maximum of 5 streams are open at any one time. While a stream is open, the code checks whether I have data down to a specified depth, say, 10 levels, and as soon as I reach that depth on both bid and ask sides, I close the stream and open a new one. I also have a timeout, so that if any one stream has been open for too long it gets automatically closed. In this way I iterate through the list of 30 stocks, such that at the end, I have a snapshot of the depth across all 30 stocks. Obviously some of the data will be stale at this point, but for lightly traded stocks I haven't found it to be too much of an issue. One other point I should add is that in practice, I've found that I need to have one less stream than my maximum open at a time, otherwise sometimes things overlap and I get an automatic disconnection for attempting to open too many streams at once.

So, are there any clever ways for improving on this approach that people are aware of, or is this about the best I can expect to do?

BTW, I usually trade ASX equities, if that makes any difference.

Cheers all,

Colin


No historical market data for AAL/STK@VALUE Last 1d

 

Hi Everyone,

I'm receiving this error callback when making an historical data request for AAL:

"No historical market data for AAL/STK@VALUE Last 1d"? (error code 162)

I can't work out what's going on!? I'm retrieving the contract object fresh before sending the reqHistoricalData request.? The exchange in the contract object is 'SMART' and primaryExchange is 'NASDAQ', but the error message seems to indicate AAL is looking at the VALUE exchange.

TWS shows historical data for AAL in the last 1 D, so it's not clear why the API would say there is no data.

Most of my historical data requests are working fine (with all the same request parameters, except the contract object) - though there are a handful of others (say 1 in 100) that are also giving the same error above.

Can anyone help solve this?


Re: reqPositionsMulti does not work as intended

 

To add, my goal is to tag orders with different modelCodes in order to keep positions apart. For example. If I buy 100 shares of Apple with modelCode "Strategy1" and short 100 shares of Apple with modelCode "Strategy2" my net position in TWS would be 0 but when I request positions I want to see two positions, one for each modelcode with their own averagePrice and positions. But I do not seem to be able to get there....


reqPositionsMulti does not work as intended

 

I am having trouble with the C# API requesting positions via reqPositionsMulti with a modelCode. When I query with an empty string I get all open positions, however, when I populate modelCode with a non-empty string that was attached to the modelCode parameter in the Order class when submitting orders then? "positionMulti" does not return anything.?

Is there a special string that returns ALL positions, regardless of which modelCode was used when submitting orders? At this moment neither works.?


Re: opt out from: Secure Login required for trading

 

Thanks. Sounds like IB is moving towards 2fa. Guess it is time to bite the bullet. I was just I was hoping IB would do something more algo trading friendly, but of course any solution has pros/cons.?

I am big fan of IBC. Been using it for 3 years, zero issues. One of my commits was even accepted in the code :) I tested over weekend how the latest version is handling 2fa. Very impressive, exactly how I was hoping a 3rd party app. would do it. I am switching 2fa on now with IBC. fingers crossed it will be as stable as without 2fa


Re: Duplicate Order ID

 

Hello Folks,

thanks a lot for your help again. I don't want to use more of your time. I have a workaround that works for me with creating a contract object. Its time for me now to figure out how i can use the contractdetails object and if i manage this i will publish this here. So thanks again for all the information and have a good time!

Best wishes Robert


Re: Duplicate Order ID

 

You should not have to create all that code in order to use a contract object you received from reqContractDetails. And you should be able to use the entire object without having to copy individual fields. That defeats the purpose. Unfortunately, I don't have enough experience with Excel/VB (nor do we use MS/Office programs, LibreOffice/OpenOffice works much better for us) and I cannot give you additional pointers here.

Maybe, for now, you should create contracts from scratch again.

Using reqContractDetails to retrieve contract objects that IBKR creates for you with all fields they care about initialized is a "best practice" (but clearly not the only approach):

  • It facilitates a code structure that "separates concerns". Meaning that you have a small specialized module that knows everything that needs to be known about instruments, trading hours, exchanges, and other contract object details. It knows the many things that can go wrong and what to do in case something does, and applies in a central location all validations and safety checks you care about. You don't want to realize during an urgent position close attempt that something has changed and the contract is no good for trading.
  • You are correct that reqContractDetails also needs a contract object for the request, but it has a different function, is more human oriented, and you can provide fewer details than what you'd need for placing orders or other API requests (machine usable). You can specify the instrument in the most convenient way for you (local symbol, CUSIP/ISIN, conid, ...) and, if that makes sense, you can even ask for all contracts of a certain type (say all active futures of a certain type, or the contracts for all currencies of a stock, ...) and you get trade hour details for the current session and the next week or so. Are you really sure you know all rules for trading around holidays and other, possibly short notice, trade hour changes?
  • take a look at Richard King's ContractInspector that you can get at . The ContractInspector allows to explore what reqContractDetails can do for you without having to create code first.

But again, this only makes sense if you can convince the Excel/VB environment that it should use the contract object from reqContractDetails without any extra coding or field copying.

´³¨¹°ù²µ±ð²Ô

On Mon, Aug 1, 2022 at 05:37 AM, Metrodus79 wrote:

Hello joanmarcel119, hello ´³¨¹°ù²µ±ð²Ô

I'm not anymore sure if the the request for the is valuable for me. To make the request i need a contract object and fill this with all the information that also need to place an order. I'm not sure if the contract object need all the information that i put in.

Request for?

Sub M_REAL_ORDER_KONTRAKT_DETAILS_ANFORDERN()

Call M_GLOB_DEKLARATIONEN_EXCEC
?? ?
??? If Not (objTWSControl Is Nothing) Then
????? ?
??????? If objTWSControl.m_isConnected Then
?????? ?
??????????? 'Create object contract
??????????? Set contract = objTWSControl.contract

??????????? 'Fill this object it with contract information
??????????? With objTWSControl.contract

??????????????? .Symbol = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SYMBOL")))
??????????????? .secType = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SECTYP")))
??????????????? .lastTradeDateOrContractMonth = wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("VERFALLSDATUM"))
??????????????? .multiplier = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("MULTIPLIKATOR")))
??????????????? .exchange = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("B?RSE")))
??????????????? .currency = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("W?HRUNG")))
??????????? ?
??????????? End With
?????????? ?
??????????? Dim lngreqId As Long
?????????? ?
??????????? lngreqId = 1
???????????
?????????? 'Call for detailed contract information.
??????????? Call objTWSControl.m_TWSControl.reqContractDetailsEx(lngreqId, objTWSControl.m_contractInfo)
?????? ?
??????? End If
??
?? End if

end Sub

Public Event send me the contract object in class modul

Public WithEvents m_TWSControl As Tws
Public contract As TWSLib.IContract

Private Sub m_TWSControl_contractDetailsEx(ByVal lngreqId As Long, ByVal contract As ComContractDetails)

Call M_REAL_ORDER_KONTRAKT_OBJEKT(lngreqId, contract)

End Sub

Do i get the same object back what i declared before? is This my problem here?

Thanks again but I'm struggling with this.




Re: Duplicate Order ID

 

I think the best for you is to get the excel file which comes with the IB API and do some tests in their code.?

What you have now developed I can not check if it is valid or it will work. I started the same way, by copying first the excel file of IB and then doing some minor changes and debugging. So if you already did this, then I recommend starting again. You should also debug the code to see how it works, like for example, setting a breakpoint?into the procedures called by the TWS usually?placed in the API module after your request has been sent.

Hope that helps

El lun, 1 ago 2022 a las 12:37, Metrodus79 (<robert.metasch@...>) escribi¨®:
Hello joanmarcel119, hello ´³¨¹°ù²µ±ð²Ô

I'm not anymore sure if the the request for the is valuable for me. To make the request i need a contract object and fill this with all the information that also need to place an order. I'm not sure if the contract object need all the information that i put in.

Request for?

Sub M_REAL_ORDER_KONTRAKT_DETAILS_ANFORDERN()

Call M_GLOB_DEKLARATIONEN_EXCEC
?? ?
??? If Not (objTWSControl Is Nothing) Then
????? ?
??????? If objTWSControl.m_isConnected Then
?????? ?
??????????? 'Create object contract
??????????? Set contract = objTWSControl.contract

??????????? 'Fill this object it with contract information
??????????? With objTWSControl.contract

??????????????? .Symbol = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SYMBOL")))
??????????????? .secType = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SECTYP")))
??????????????? .lastTradeDateOrContractMonth = wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("VERFALLSDATUM"))
??????????????? .multiplier = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("MULTIPLIKATOR")))
??????????????? .exchange = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("B?RSE")))
??????????????? .currency = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("W?HRUNG")))
??????????? ?
??????????? End With
?????????? ?
??????????? Dim lngreqId As Long
?????????? ?
??????????? lngreqId = 1
???????????
?????????? 'Call for detailed contract information.
??????????? Call objTWSControl.m_TWSControl.reqContractDetailsEx(lngreqId, objTWSControl.m_contractInfo)
?????? ?
??????? End If
??
?? End if

end Sub

Public Event send me the contract object in class modul

Public WithEvents m_TWSControl As Tws
Public contract As TWSLib.IContract

Private Sub m_TWSControl_contractDetailsEx(ByVal lngreqId As Long, ByVal contract As ComContractDetails)

Call M_REAL_ORDER_KONTRAKT_OBJEKT(lngreqId, contract)

End Sub

Do i get the same object back what i declared before? is This my problem here?

Thanks again but I'm struggling with this.




Suggestions on how to deal with blocking pop up from TWS (like last week)

 

¿ªÔÆÌåÓý

Hi all,

Last week, I suddenly had this blocking pop-up from TWS asking me to read a document and confirm it. The message was about some rewritten parts in a particular agreement. The problem is, that message was triggered right when my algo tried to place an order. The order was then held back, until I read and manually confirmed the document (which was hours later). In the TWS settings itself, I have disabled all pop-ups, but also, these are only about trade warnings, not a legal document that the user is forced to read.

Luckily, I haven't seen this type of intrusive pop-up before, but is there a work aroud for this? I'm sure many people had this pop-up too last week. Does the gateway have these blocking pop-ups? (I prefer using TWS so I can manually check what's going on)

Thanks for any help, regards,
Raoul


Re: Duplicate Order ID

 

Hello joanmarcel119, hello ´³¨¹°ù²µ±ð²Ô

I'm not anymore sure if the the request for the is valuable for me. To make the request i need a contract object and fill this with all the information that also need to place an order. I'm not sure if the contract object need all the information that i put in.

Request for?

Sub M_REAL_ORDER_KONTRAKT_DETAILS_ANFORDERN()

Call M_GLOB_DEKLARATIONEN_EXCEC
?? ?
??? If Not (objTWSControl Is Nothing) Then
????? ?
??????? If objTWSControl.m_isConnected Then
?????? ?
??????????? 'Create object contract
??????????? Set contract = objTWSControl.contract

??????????? 'Fill this object it with contract information
??????????? With objTWSControl.contract

??????????????? .Symbol = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SYMBOL")))
??????????????? .secType = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("SECTYP")))
??????????????? .lastTradeDateOrContractMonth = wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("VERFALLSDATUM"))
??????????????? .multiplier = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("MULTIPLIKATOR")))
??????????????? .exchange = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("B?RSE")))
??????????????? .currency = UCase(wksRealImport.Cells(lngZ, flngFindeSpaltewksRealImport("W?HRUNG")))
??????????? ?
??????????? End With
?????????? ?
??????????? Dim lngreqId As Long
?????????? ?
??????????? lngreqId = 1
???????????
?????????? 'Call for detailed contract information.
??????????? Call objTWSControl.m_TWSControl.reqContractDetailsEx(lngreqId, objTWSControl.m_contractInfo)
?????? ?
??????? End If
??
?? End if

end Sub

Public Event send me the contract object in class modul

Public WithEvents m_TWSControl As Tws
Public contract As TWSLib.IContract

Private Sub m_TWSControl_contractDetailsEx(ByVal lngreqId As Long, ByVal contract As ComContractDetails)

Call M_REAL_ORDER_KONTRAKT_OBJEKT(lngreqId, contract)

End Sub

Do i get the same object back what i declared before? is This my problem here?

Thanks again but I'm struggling with this.




Re: Duplicate Order ID

 

¿ªÔÆÌåÓý

There is no point in deleting it ¨C it has already been sent out to all the members (the vast majority) who receive posts via email.

?

Just post again with the complete message, and you can add a comment explaining that the previous post was incomplete.

?

Richard King

Moderator

?

?

From: [email protected] <[email protected]> On Behalf Of Metrodus79
Sent: 01 August 2022 11:08
To: [email protected]
Subject: Re: [TWS API] Duplicate Order ID

?

How i can delete the last message...i was not finish with this ;)


Re: Duplicate Order ID

 

As you mentioned: " I think the object "contract" out of the??is not correct used. I tried different ways but I'm not sure if i can use the complete object or if i have to take all the information out and put this in a new object.?"

I do think the same as you.?
You need to "extract" the information received to fill the new object for the order to be sent.?

I think?the most important is this one, in my implementation which may differ from yours:
(The object conDetails comes from the Contract detail request)

? ? Dim contract As TWSLib.IContract
? ? Set contract = conDetails.contract
? ? Debug.print "Api contractDetails " & contract.localSymbol & "-" & contract.Exchange & "-" & contract.secType
? ? Debug.print " ? ? ?-----------> " & conDetails.lastTradeTime & ";" & conDetails.contractMonth & ";" & contract.lastTradeDateOrContractMonth & ";" & conDetails.timeZoneId & ";" & contract.conId & ";" & conDetails.priceMagnifier

This above piece of code will display on your excel debugger log some of the information which sends your the TWS once the request of contract details is received. Hope that helps you to fill the proper information for the new order request

Hope that helps

El dom, 31 jul 2022 a las 18:58, Metrodus79 (<robert.metasch@...>) escribi¨®:
Hello Folks,

summarized briefly I could figure out that the problem was a confirmation what i had to do in my account. After that i could set the order placement.

@Richard: Unfortunately I forgot to say that i had no problem on my paper account. Only on my live account and only for the future contracts. There absolutely no failure log were i could figure out why the order was not accepted. But i thank you for your time and that you tried this for me!

@´³¨¹°ù²µ±ð²Ô: The hind with the order-ID is great and i implemented this in my program. I tried to implement the too but still now i couldn't manage this. Maybe you can give me a hind again.

1. I made the request for the contract details and i get a object called contract: m_TWSControl_contractDetailsEx(ByVal lngreqId As Long, ByVal contract As ComContractDetails)
2. In the next step i tried to use this object in the request for order placement
3. I create the object with the order information out of the class m_orderCom. This object comes for the class ComOrder and is defined as? Public m_orderCom As TWSLib.ComOrder:
Set objTWSControl.m_orderCom = objTWSControl.m_TWSControl.createOrder
4. I fill that object with the significant order information

??????????????? With objTWSControl.m_orderCom
?? ?
??????????????????? .Action = "BUY" 'strOrderAktion? 'BUY, SELL, SSHORT"
??????????????????? .totalQuantity = 1 'lngOrderAnzahl 'ORDER ANZAHL
??????????????????? .orderType = "STP" 'strOrderTyp? 'MKT, MKTCLS, LMT, LMTCLS, PEGMKT, SCALE, STP, STPLMT, TRAIL, REL, VWAP, TRAILLIMIT
??????????????????? .auxPrice = 1 'dblOrderStoppPreis 'Stopp price
??????????????????? .timeInForce = "DAY" 'Order ist nur f¨¹r den Tag der Orderer?ffnung aktiv
??????????????????? .whatIf = 1 'bolwhatIf
?????????????? ?
??????????????? End With
5. I put the two objects (contract and objTWSControl.m_orderCom) in the request for the order placement and it doesn't work
?? ???????????
?????????????? Set objTWSControl.m_orderCom.orderMiscOptions = objTWSControl.m_TWSControl.createTagValueList()
?????????????? Call objTWSControl.m_TWSControl.placeOrderEx(lngOrderId, contract, objTWSControl.m_orderCom)

I think the object "contract" out of the is not correct used. I tried different ways but I'm not sure if i can use the complete object or if i have to take all the information out and put this in a new object.

You helped me a lot to solve my problem. If this need to much time its absolute ok for me. i will figure out how it works by time.

THANKS A LOT AGAIN!

Robert
???


monthly data scanner

 

So I've been using the ib scanner for a while now, and I'm confused about how to scanne for stocks for a longer period than intraday. On tws we can choose between the mosaic market scanner or the advanced market scanner, looking deeper into the advanced market scanner I noticed that some features are missing compared to the mosaic market scanner like the month to month % change. Looking at?? ?it appears that the connection to the mosaic market scanner is not available. Am I? missing something? or does IB really doesnt provide access to the mosaic market scanner from it's API ?


Re: Duplicate Order ID

 

Glad that worked, Robert. On the surface your approach looks fine. It is the contract object you receive with your object that you'd use for the order. There is a little more detail at

Couple of thoughts:

  • What error message do you get when the order placement fails?
  • Did you get exactly one object from your request and is it the one you are trying to order? reqContractDetails returns a list of results and depending on what you ask for, you can get 0, 1, or several (even many) .
  • I am not familiar with the Excel/VBA details. But in your earlier post it looked like you used "With objTWSControl.m_contractInfo" to specify the contract information. Is it possible that you have to set objTWSControl.m_contractInfo to the contract object you received in

I guess you have to do a little more digging.

´³¨¹°ù²µ±ð²Ô


Re: Duplicate Order ID

 

Hello Folks,

summarized briefly I could figure out that the problem was a confirmation what i had to do in my account. After that i could set the order placement.

@Richard: Unfortunately I forgot to say that i had no problem on my paper account. Only on my live account and only for the future contracts. There absolutely no failure log were i could figure out why the order was not accepted. But i thank you for your time and that you tried this for me!

@´³¨¹°ù²µ±ð²Ô: The hind with the order-ID is great and i implemented this in my program. I tried to implement the too but still now i couldn't manage this. Maybe you can give me a hind again.

1. I made the request for the contract details and i get a object called contract: m_TWSControl_contractDetailsEx(ByVal lngreqId As Long, ByVal contract As ComContractDetails)
2. In the next step i tried to use this object in the request for order placement
3. I create the object with the order information out of the class m_orderCom. This object comes for the class ComOrder and is defined as? Public m_orderCom As TWSLib.ComOrder:
Set objTWSControl.m_orderCom = objTWSControl.m_TWSControl.createOrder
4. I fill that object with the significant order information

??????????????? With objTWSControl.m_orderCom
?? ?
??????????????????? .Action = "BUY" 'strOrderAktion? 'BUY, SELL, SSHORT"
??????????????????? .totalQuantity = 1 'lngOrderAnzahl 'ORDER ANZAHL
??????????????????? .orderType = "STP" 'strOrderTyp? 'MKT, MKTCLS, LMT, LMTCLS, PEGMKT, SCALE, STP, STPLMT, TRAIL, REL, VWAP, TRAILLIMIT
??????????????????? .auxPrice = 1 'dblOrderStoppPreis 'Stopp price
??????????????????? .timeInForce = "DAY" 'Order ist nur f¨¹r den Tag der Orderer?ffnung aktiv
??????????????????? .whatIf = 1 'bolwhatIf
?????????????? ?
??????????????? End With
5. I put the two objects (contract and objTWSControl.m_orderCom) in the request for the order placement and it doesn't work
?? ???????????
?????????????? Set objTWSControl.m_orderCom.orderMiscOptions = objTWSControl.m_TWSControl.createTagValueList()
?????????????? Call objTWSControl.m_TWSControl.placeOrderEx(lngOrderId, contract, objTWSControl.m_orderCom)

I think the object "contract" out of the is not correct used. I tried different ways but I'm not sure if i can use the complete object or if i have to take all the information out and put this in a new object.

You helped me a lot to solve my problem. If this need to much time its absolute ok for me. i will figure out how it works by time.

THANKS A LOT AGAIN!

Robert
???


Re: How to automatically accept (or disable) the paper trading notification?

 

If you are comfortable with running IB gateway inside a docker container, I have an open-source project that closes this popup automatically among other things. It's called?IB Gateway Automation (IBGA) ?. :)


Re: How to automatically accept (or disable) the paper trading notification?

 

Have a look at the IBC. It can do this for you.

/g/ibcalpha/topics


Re: TWS Closing

 

Hello ´³¨¹°ù²µ±ð²Ô, thanks for your thoughts.

I am in Australia, and connect to the Hong Kong server. I have NBN internet fibre direct to the home, then cable to the PC. It was wireless, but I changed when problems started. IB have looked at my logs, for both when the connection is ok, and when IBG failed to re-connect to the Hong Kong server during the restart time (approx 23:02 Chicago time). IB even asked me to ping the server, so I set a ping script going every 2 seconds while IBG was trying to connect. There was no interruption in the ping sequence.

So, we're at a loss to explain the situation. I am reluctant to change things at the moment as TWS is running successfully during the week. If it happens again, I'll come back to your post and look at the DNS aspects.

Thanks again,
KH


Re: TWS Closing

 

Nothing is impossible, but I cannot think of any reason why TWS would handle connection loss with IBKR any different or better than IBGW. The code is absolutely identical (65,817 identical class and 2,919 other files for version 10.16.1n) and only install4j scripts are slightly different between the two.

We have seen the situation YQ describes where the disconnect was too long for the automatic re-connect without credentials. But tht happened very rarely and most cases took place over the weekend during extended IBKR maintenance periods.

There can be many different reasons for re-connect failures and TWS/IBGW logs may be able to give you some pointers of what is going one, but most of them probably fall into one of three categories:

  • Basic network connectivity is disrupted and no data packets flow between TWS/IBGW and IBKR or the packet loss is excessive. We continuously monitor the IBKR performance on that level and their network infrastructure and our path to them is rock solid. Below a table with results measured on a "real" server in a tier 1 data center outside of Chicago. And attached a few SmokePing screen grabs with one measurement of 10 pings every minute for the last 400 days.

    The "Business Internet" provided by a well know cable company to our home is a very different story as you can see from the SmokePing measurements. But as bad as the cable internet network service is (packet loss, latency, huge latency jitter) TWS/IBGW would probably reconnect reliably.

    You might want to verify that your TWS/IBGW does connect to the closest IBKR contact point and that the route between you and IBKR is reliable.

  • Stability of network services such as DNS and NTP. DNS is the Achilles heal of all IP networks. When DNS does not properly or reliably resolve names to IP addresses "rien ne va plus", long wait times can occur, and TWS/IBGW may give up at some point.

    I was able to improve the stability of our cable company "Business Internet" service significantly by replacing their (intermittently unreliable) DNS servers with some of the open servers such as 1.1.1.1, 8.8.4.4, 8.8.8.8, 9.9.9.9, or those from Level3 and CISCO OpenDNS. Same is true for NTP time services.

  • IBKR higher level functions have intermittent issues (individual servers fail or capacity limits get hit)? or your TWS/IBGW has lower priority. When we run two TWS instances on the same server in the cloud that connect to IBKR with two different accounts (say a "real" and a "paper" account) disconnects and resets do not occur at the same time, frequency, or duration. While we have no long-term measurements, I have experienced periods where the "paper" account TWS had more frequent and longer disconnects than the "real" account TWS. But both TWS did reconnect eventually.

All of this assumed wired connectivity. Your mileage will be worse in case your TWS/IBGW communicates through WIFI or other wireless services.

Just some thoughts,

´³¨¹°ù²µ±ð²Ô



400 day average, tier 1 data center near Chicago
IBKR Host RT Latency (ms) Avg Packet Loss
US CDC1 3.4 none
US NDC1 21.5 none
EU ZDC1 100.7 none
ASIA HDC1 194.7 0.10%
China MCGW1 215.0 3.40%



On Fri, Jul 29, 2022 at 04:25 PM, Kevin wrote:
I recently experienced the exact same problem as Yilin Qin described, however it is with IB Gateway, not TWS. I ended up changing from IB Gateway to TWS (reluctantly).

As Yilin rightly pointed out, there is no good solution. IB have been through all my logs, good days and bad, and all they can suggest is to change to a different internet connection. That, for me, isn't an alternative. I restart TWS at least once during the week, and that seems to make the problem go away.

KH


How to automatically accept (or disable) the paper trading notification?

 

I'm opening TWS using IBC via Task Scheduler.
I'm paper trading while testing my strategy.
TSI has an automatic notification pop up when I log in to remind me that I'm paper trading.
Unless this notification is accepted, my bot can't connect to the TWS API.
Is there a way to automatically accept (or disable) this notification? Thanks!