Пример #1
0
        public void BarPerformance()
        {
            SingleSimImpl h = new SingleSimImpl(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(SingleSimImpl.Endsim);

            double time = DateTime.Now.Subtract(start).TotalSeconds;

            h.Stop();
            Assert.True(tickcount >= 50000);
            Assert.Equal(3, bt.SymbolCount);
            Assert.True(time <= EXPECTBARS);
            debug("BarList runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTBARS + "sec expected.");
            debug("BarList " + ((double)tickcount / time).ToString("N0") + " ticks/sec");
        }
Пример #2
0
        public void ExecutionPerformance()
        {
            System.Threading.Thread.Sleep(100);
            h = new SingleSimImpl(new string[] { @"Common\FTI20070926.TIK", @"Common\ABN20080318.TIK", @"Common\SPX20070926.TIK" });
            h.Initialize();
            h.GotTick           += execute_GotTick;
            h.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(SingleSimImpl.Endsim);

            double time = DateTime.Now.Subtract(start).TotalSeconds;

            debug("Execution runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTEX + "sec expected.");
            debug("Execution " + ((double)tickcount / time).ToString("N0") + " ticks/sec.  " + ((double)fillcount / time).ToString("N0") + " fills/sec");

            Assert.Equal(desiredfills, fillcount);
            Assert.True(time <= EXPECTEX);
            h.Stop();
        }
Пример #3
0
        //[Test]
        public void BarPerformance()
        {
            SingleSimImpl h = new SingleSimImpl(new string[] { "FTI20070926.TIK", "ABN20080318.TIK", "SPX20070926.TIK" });

            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(SingleSimImpl.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");
        }
Пример #4
0
        //[Test]
        public void ExecutionPerformance()
        {
            System.Threading.Thread.Sleep(100);
            h = new SingleSimImpl(new string[] { "FTI20070926.TIK", "ABN20080318.TIK", "SPX20070926.TIK" });
            h.Initialize();
            h.GotTick           += new TradeLink.API.TickDelegate(execute_GotTick);
            h.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(SingleSimImpl.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();
        }
Пример #5
0
        public void rawbase(string name, int symcount, SingleSimImpl sim)
        {
            rt.d(name.ToUpper());
            SingleSimImpl h = sim;

            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);


            if (Environment.ProcessorCount == 1)
            {
                EXPECTRAW *= 2.5;
            }

            DateTime start = DateTime.Now;

            h.PlayTo(SingleSimImpl.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());
        }