Problems registering security for level 1 price updates
Atom
30.10.2017
Johan Kirsten


I have a windows service that hosts a web api interface. The service connects to an interactive broker TWS. A call to the web api must register the security to receive level 1 price updates. The code to do this is:

if (_connector.RegisteredSecurities.Count(s => s.Id == securityId) == 0) { var onSecurityChanged = new Action(s => { if (s.Id != securityId) return; if (s.BestBid != null && s.BestAsk != null) waitHandle.Set(); });

_connector.SecurityChanged += onSecurityChanged;

_connector.RegisterSecurity(security); waitHandle.WaitOne(30000);

_connector.SecurityChanged -= onSecurityChanged; }

if ((security.BestBid == null) || (security.BestAsk == null)) { throw new InvalidOperationException("Unable to obtain quotes"); }

The problem is the security does not get registered. Even on a second or third pass. The RegisteredSecurities  collection stays empty.

I have tested it with securities with the following ids: "SPZ7@GLOBEX", "SPXW  171215C02580000@SMART"

Any help would be greatly appreciated

Regards

Johan Kirsten




Спасибо: Support


Support

Фотография
Дата: 31.10.2017
Ответить


Hello,

Did you tried to start SampleIB, search futures contract (by underlying symbol) and press Level1 for selected securities? No any warning messages?

Спасибо:

Johan Kirsten

Фотография
Дата: 31.10.2017
Ответить


Hi

I have used SampleIB to search for futures and options and pressed Level1. The sampleIB application returned the correct bid and ask with no warnings.

Regards

Спасибо:

Johan Kirsten

Фотография
Дата: 01.11.2017
Ответить


Hi

I found the problem. In my SecurityChanged handler, I had code that stopped the code executing past a point. Effectively pausing the thread that does the update. Once I removed that, the updates came through

Regards

Спасибо: Mikhail Sukhov Support

Support

Фотография
Дата: 02.11.2017
Ответить


Could you please post full code cause currently I cannot see any tech issues with locking.

Спасибо:


Добавить файлы через драг-н-дроп, , или вставить из буфера обмена.

loading
clippy