public void BarPerformance() { MultiSimImpl h = new MultiSimImpl(Environment.CurrentDirectory); h.GotTick += new TradeLink.API.TickDelegate(h_GotTick); h.Initialize(); tickcount = 0; lasttime = 0; Assert.AreEqual(0, lasttime); Assert.Greater(h.TicksPresent, 0); if (Environment.ProcessorCount == 1) { EXPECTBARS *= 2.5; } DateTime start = DateTime.Now; h.PlayTo(MultiSimImpl.ENDSIM); double time = DateTime.Now.Subtract(start).TotalSeconds; h.Stop(); Assert.GreaterOrEqual(tickcount, 50000); Assert.AreEqual(3, bt.SymbolCount); Assert.LessOrEqual(time, EXPECTBARS); rt.d("BarList runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTBARS + "sec expected."); rt.d("BarList " + ((double)tickcount / time).ToString("N0") + " ticks/sec"); }
public void ExecutionPerformance() { System.Threading.Thread.Sleep(100); h = new MultiSimImpl(Environment.CurrentDirectory); h.Initialize(); h.GotTick += new TradeLink.API.TickDelegate(execute_GotTick); SimBroker.GotFill += new TradeLink.API.FillDelegate(SimBroker_GotFill); tickcount = 0; lasttime = 0; Assert.AreEqual(0, tickcount); Assert.AreEqual(0, syms.Count); Assert.AreEqual(0, lasttime); Assert.Greater(h.TicksPresent, 0); if (Environment.ProcessorCount == 1) { EXPECTEX *= 2.5; } DateTime start = DateTime.Now; h.PlayTo(MultiSimImpl.ENDSIM); double time = DateTime.Now.Subtract(start).TotalSeconds; rt.d("Execution runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTEX + "sec expected."); rt.d("Execution " + ((double)tickcount / time).ToString("N0") + " ticks/sec. " + ((double)fillcount / time).ToString("N0") + " fills/sec"); Assert.AreEqual(desiredfills, fillcount); Assert.LessOrEqual(time, EXPECTEX); h.Stop(); }
public void BarPerformance() { MultiSimImpl h = new MultiSimImpl(new string[] { @"Common\FTI20070926.TIK", @"Common\ABN20080318.TIK", @"Common\SPX20070926.TIK" }); h.GotTick += h_GotTick; h.Initialize(); tickcount = 0; lasttime = 0; Assert.Equal(0, lasttime); Assert.True(h.TicksPresent > 0); if (Environment.ProcessorCount == 1) { EXPECTBARS *= 2.5; } DateTime start = DateTime.Now; h.PlayTo(MultiSimImpl.Endsim); double time = DateTime.Now.Subtract(start).TotalSeconds; h.Stop(); Assert.True(tickcount >= 50000); Assert.Equal(3, bt.SymbolCount); Assert.True(time <= EXPECTBARS); }
public void ExecutionPerformance() { System.Threading.Thread.Sleep(100); h = new MultiSimImpl(new string[] { @"Common\FTI20070926.TIK", @"Common\ABN20080318.TIK", @"Common\SPX20070926.TIK" }); h.Initialize(); h.GotTick += execute_GotTick; SimBroker.GotFill += SimBroker_GotFill; tickcount = 0; lasttime = 0; Assert.Equal(0, tickcount); Assert.Equal(0, syms.Count); Assert.Equal(0, lasttime); Assert.True(h.TicksPresent > 0); if (Environment.ProcessorCount == 1) { EXPECTEX *= 2.5; } DateTime start = DateTime.Now; h.PlayTo(MultiSimImpl.Endsim); double time = DateTime.Now.Subtract(start).TotalSeconds; Assert.Equal(desiredfills, fillcount); Assert.True(time <= EXPECTEX); h.Stop(); }
void play(object sender, DoWorkEventArgs e) { PlayTo type = (PlayTo)e.Argument; if (e.Cancel) { return; } int time = (int)(_historicalSimulator.NextTickTime % 100000); long date = (_historicalSimulator.NextTickTime / 100000) * 100000; int t = (int)type; long val = 0; _playTo = type; switch (type) { case PlayTo.End: val = MultiSimImpl.ENDSIM; break; case PlayTo.FiveMin: case PlayTo.OneMin: case PlayTo.TenMin: case PlayTo.HalfHour: val = date + Util.FTADD(time, (t / 10) * 60); break; case PlayTo.Hour: val = date + Util.FTADD(time, (t / 1000) * 3600); break; case PlayTo.TwoHour: val = date + Util.FTADD(time, 2 * 60 * 60); break; case PlayTo.FourHour: val = date + Util.FTADD(time, 4 * 60 * 60); break; case PlayTo.OneSec: case PlayTo.ThirtySec: val = date + Util.FTADD(time, t); break; //case PlayTo.Custom: // ctime = getcusttime(); // if (ctime == 0) // { // _playTo = PlayTo.OneSec; // val = 0; // status("Invalid custom time, playing to next second."); // } // else // val = date + ctime; // break; } _historicalSimulator.PlayTo(val); }
public void rawbase(string name, int symcount, MultiSimImpl sim) { rt.d(name.ToUpper()); MultiSimImpl h = sim; h.Initialize(); h.GotTick += new TradeLink.API.TickDelegate(raw_GotTick); h.GotDebug += new DebugDelegate(h_GotDebug); tickcount = 0; syms.Clear(); lasttime = 0; Assert.AreEqual(0, tickcount); Assert.AreEqual(0, syms.Count); Assert.AreEqual(0, lasttime); Assert.Greater(h.TicksPresent, 0); if (Environment.ProcessorCount == 1) { EXPECTRAW *= 2.5; } DateTime start = DateTime.Now; h.PlayTo(MultiSimImpl.ENDSIM); // printout simulation runtime rt.d("Ticks received: " + tickcount + " sent: " + h.TicksProcessed + " estimate: " + h.TicksPresent); rt.d("Raw runtime: " + h.RunTimeSec.ToString("N2") + "sec, versus: " + EXPECTRAW + "sec expected."); rt.d("Raw speed: " + h.RunTimeTicksPerSec.ToString("N0") + " ticks/sec"); // make sure ticks arrived in order Assert.IsTrue(h.isTickPlaybackOrdered, "Tick arrived out-of-order."); // ensure got expected number of symbols Assert.AreEqual(symcount, syms.Count); // variance from approximate count should be less than 1% Assert.Less((tickcount - h.TicksPresent) / h.TicksPresent, .01); // actual count should equal simulation count Assert.AreEqual(h.TicksProcessed, tickcount); h.Stop(); rt.d(name.ToUpper()); }