Problems registering security for level 1 price updates
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<Security>(s =>
if (s.Id != securityId)
if (s.BestBid != null && s.BestAsk != null)
_connector.SecurityChanged += onSecurityChanged;
_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