public void Serialization() { BasketImpl mb = new BasketImpl(); mb.Add(new SecurityImpl("IBM")); BasketImpl compare = BasketImpl.Deserialize(mb.ToString()); Assert.That(compare.Count == 1); mb.Clear(); compare = BasketImpl.Deserialize(mb.ToString()); Assert.That(compare.Count==0); mb.Clear(); SecurityImpl longform = SecurityImpl.Parse("CLZ8 FUT NYMEX"); mb.Add(longform); compare = BasketImpl.Deserialize(mb.ToString()); Assert.AreEqual(longform.ToString(),compare[0].ToString()); }
void tl_newRegisterSymbols(string client, string symbols) { debug("got symbol request: " + client + " for: " + symbols); // get original basket Basket org = new BasketImpl(b); // get new basket Basket mb = BasketImpl.FromString(symbols); // track it b.Add(mb); //Close_Connections(false); foreach (Security s in mb) { // skip symbol if we already have it if (org.ToString().Contains(s.symbol)) continue; if (api.TD_IsStockSymbolValid(s.symbol)) { string service = GetExchange(s.symbol); api.TD_RequestAsyncLevel1QuoteStreaming(s.symbol, service, this); } } }
void updateMB() { List<string> syms = new List<string>(_symidx.Count); foreach (string sym in _symidx.Keys) syms.Add(sym); string old = _mb.ToString(); _mb = new BasketImpl(syms.ToArray()); bool subscribe = old != _mb.ToString(); if (!subscribe) return; if (_bf.FeedClient == null) return; try { // resubscribe _bf.Subscribe(_mb); } catch (TLServerNotFound) { debug("symbol subscribe failed as no TL server was found."); } }