No Security definition has been found for the request when running cpp sample code


 

Hi, I'been trying to run the cpp sample code to reqRealTimeBars for some contract. but the ib server returns no security defintionn found even though I was using the sample contract.
 


 

reqRealTimeBars is served by the historical data server. But IBKR does not maintain ‘last price’ historical data for forex pairs. So you will never get realtime bars for any forex pair, if you have WhatToShow=”TRADES”: you’ll just get this error message 420:

 

Invalid Real-time Query:No historical market data for EUR/CASH@FXSUBPIP Last 0

 

But if you set WhatToShow=”MIDPOINT”, it works fine:

 

20241203 09:49:47.068  id=131072 time=20241203-09:49:40 open=0.829655 high=0.829655 low=0.82962 close=0.82964 volume=-1 WAP=-1 count=-1

20241203 09:49:50.362  id=131072 time=20241203-09:49:45 open=0.82964 high=0.82968 low=0.82964 close=0.829665 volume=-1 WAP=-1 count=-1

20241203 09:49:55.533  id=131072 time=20241203-09:49:50 open=0.829665 high=0.829665 low=0.82962 close=0.82962 volume=-1 WAP=-1 count=-1

 

Richard

 


 

Thanks for the reply richard.
  When I send requests to the ib server, sometimes the data returns just fine, sometimes I get error 'Connectivity between IBKR and Trader Workstation has been lost' followed by  'No security defintion has been found for the request'. I'm wondering what's causing this? and how should I handle this?


 

runnig the test client multiple times gives different results..


 

It might be my eyes, but the pictures you post are too small to read. And when zooming in they become blurry, thus unreadable.


 

Some suggestions:

 

  1. Stop posting these screenshots: they’re almost impossible to read. Try to make life easy for recipients if you want help. Instead, copy the text from the terminal and paste it into your post, or into an attachment. If you really need to show a screenshot, take a high-resolution image and attach the image file.
  2. Make sure your log entries have timestamps. It’s impossible to tell whether all these things happened immediately consecutively, or spread out over time.
  3. The error 1100 means what it says: TWS/Gateway has lost its connection to the IBKR servers. Therefore it can’t process API requests until that connection is restored. It looks like your request was submitted while the connection was broken, so of course you get an error response.
  4. Note that the IBKR test clients are bare minimum demo code, and not production quality, so they don’t handle situations like this. When writing ‘real’ code, you have to pay attention to error conditions and act according – for example, don’t make API calls when there is no connection to TWS, or no connection from TWS to IBKR.

 

Richard

 

From: twsapi@groups.io <twsapi@groups.io> On Behalf Of xz2872 via groups.io
Sent: 06 December 2024 02:51
To: twsapi@groups.io
Subject: Re: [TWS API] No Security definition has been found for the request when running cpp sample code

 

runnig the test client multiple times gives different results..


 

Thank you for the suggestions richard.
  I guess you're right about the third point that the connection is lost between the Gateway and the IBKR servers thus is cannot handle API requests hence the error. So I just need to figure out a way to correctly handle this situation. 
  Sry for the inconvience caused by the low quality pictures and again thanks for the help.