public void Multiple() { // setup some symbols string[] ab = new string[] { "IBM", "LVS", "T", "GS", "MHS" }; string[] bb = new string[] { "LVS", "MHS" }; // create baskets from our symbols Basket mb = new BasketImpl( ab); Basket rem = new BasketImpl(bb); // verify symbol counts of our baskets Assert.That(mb.Count == ab.Length); Assert.That(rem.Count == bb.Length); // remove one basket from another mb.Remove(rem); // verify count matches Assert.That(mb.Count == 3,mb.Count.ToString()); // add single symbol Basket cb = new BasketImpl("GM"); // add another symbol cb.Add("GOOG"); // verify we have two Assert.AreEqual(2, cb.Count); // attempt to add dupplicate cb.Add("GM"); // verify we have two Assert.AreEqual(2, cb.Count); }
public void BasketBasics() { BasketImpl mb = new BasketImpl(); Assert.That(mb != null); SecurityImpl i = new SecurityImpl("IBM"); mb = new BasketImpl(i); mb.SendDebugEvent += new DebugDelegate(rt.d); Assert.That(mb.isNotEmpty); Assert.That(mb.isSecurityPresent(i), "missing ibm security"); Assert.That(mb.isSymbolPresent("IBM"), "missing ibm symbol"); Assert.IsFalse(mb.isSymbolPresent("LVS"), "had lvs before added"); mb.Remove(i); Assert.That(!mb.isNotEmpty); mb.Add(new SecurityImpl("LVS")); Assert.That(mb[0].symbol=="LVS",mb[0].ToString()); mb.Add(new SecurityImpl("IBM")); Assert.That(mb[1].symbol=="IBM"); mb.Add("CLV8 FUT NYMEX"); Assert.AreEqual(3, mb.Count,"missing futures symbol"); Assert.IsTrue(mb[1].Type == SecurityType.STK, "not a equities type:" + mb[1].Type); Assert.IsTrue(mb[2].Type == SecurityType.FUT, "not a futures type:"+mb[2].Type); Security ts; Assert.IsTrue(mb.TryGetSecurityAnySymbol("IBM", out ts), "ibm fetch failed"); Assert.IsTrue(mb.TryGetSecurityAnySymbol("LVS", out ts), "lvs fetch failed"); Assert.IsTrue(mb.TryGetSecurityAnySymbol("CLV8", out ts), "CLV8 short fetch failed"); Assert.IsTrue(mb.TryGetSecurityAnySymbol("CLV8 NYMEX FUT", out ts), "CLV8 short fetch failed"); BasketImpl newbasket = new BasketImpl(new SecurityImpl("FDX")); newbasket.Add(mb); var orgcount = mb.Count; mb.Clear(); Assert.That(mb.Count==0,"basket clear did not work"); Assert.AreEqual(orgcount+1,newbasket.Count,"new basket missing symbols"); }
public void Multiple() { BasketImpl mb = new BasketImpl(new string[] { "IBM","LVS","T","GS","MHS" } ); BasketImpl rem = new BasketImpl(new string[] { "LVS", "MHS" }); Assert.That(mb.Count == 5); Assert.That(rem.Count == 2); mb.Remove(rem); Assert.That(mb.Count == 3,mb.Count.ToString()); }
public void BasketBasics() { BasketImpl mb = new BasketImpl(); Assert.That(mb != null); SecurityImpl i = new SecurityImpl("IBM"); mb = new BasketImpl(i); Assert.That(mb.hasStock); mb.Remove(i); Assert.That(!mb.hasStock); mb.Add(new SecurityImpl("LVS")); Assert.That(mb[0].Symbol=="LVS",mb[0].ToString()); mb.Add(new SecurityImpl("IBM")); Assert.That(mb[1].Symbol=="IBM"); BasketImpl newbasket = new BasketImpl(new SecurityImpl("FDX")); newbasket.Add(mb); mb.Clear(); Assert.That(mb.Count==0); Assert.That(newbasket.Count==3); }
void bw_DoWork(object sender, DoWorkEventArgs e) { if (!_valid) return; while (_go) { try { if (qc > qr) { // get requested symbols string[] syms = _tmpregister.Split(','); // go through each one foreach (string sym in syms) { // if we don't have subscription already if (!contains(sym)) { // add it to list _mb.Add(sym); // request subscription esig.RequestSymbol(sym, 1); } } if (ReleaseDeadSymbols) { // clone requested basket Basket newbasket = new BasketImpl(syms); // clone existing basket as deadbasket Basket deadbasket = new BasketImpl(_mb); // existing - new = deadsymbols deadbasket.Remove(newbasket); // release dead symbols string symsreleased = string.Empty; foreach (Security dead in deadbasket) { try { esig.ReleaseSymbol(dead.symbol); symsreleased += dead.symbol + " "; } catch { } } if (symsreleased!=string.Empty) verb("released unused symbols: " + symsreleased); } qr = qc; } while (_barrequests.hasItems) { BarRequest br = new BarRequest(); try { br = _barrequests.Read(); BarInterval bi = (BarInterval)br.Interval; string interval = string.Empty; int barsback = DefaultBarsBack; if (bi == BarInterval.CustomTicks) interval = br.CustomInterval + "T"; else if (bi == BarInterval.CustomTime) interval = br.CustomInterval + "S"; else if (bi == BarInterval.CustomVol) interval = br.CustomInterval + "V"; else { if (br.Interval == (int)BarInterval.Day) interval = "D"; else interval = (br.Interval / 60).ToString(); barsback = BarImpl.BarsBackFromDate(bi, br.StartDateTime, br.EndDateTime); } int alldata = BarRequestsGetAllData ? -1 : 0; int hnd = esig.get_RequestHistory(br.symbol, interval, (bi == BarInterval.Day) ? barType.btDAYS : barType.btBARS, barsback, alldata, alldata); verb("requested bar data for " + br.symbol + " on: " + br.Interval.ToString() + " " + br.CustomInterval.ToString() + " reqhandle: " + hnd); // cache request if (!_barhandle2barrequest.ContainsKey(hnd)) _barhandle2barrequest.Add(hnd, br); else verb("already had bar request: " + hnd + " " + _barhandle2barrequest[hnd].ToString()); if (esig.get_IsHistoryReady(hnd) != 0) processhistory(hnd, br); } catch (Exception ex) { debug("error on historical bar request: " + br.ToString()); debug(ex.Message + ex.StackTrace); } } } catch (Exception ex) { if (GotDebug != null) GotDebug(ex.Message + ex.StackTrace); } if (e.Cancel || !_go) break; System.Threading.Thread.Sleep(WaitBetweenEvents); } }