コード例 #1
0
ファイル: TestHistSim.cs プロジェクト: antonywu/tradelink
        public void RawPerformance()
        {
            HistSim h = new HistSim(Environment.CurrentDirectory+"\\");
            h.Initialize();
            h.GotTick += new TradeLink.API.TickDelegate(raw_GotTick);

            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(HistSim.ENDSIM);
            

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

            // make sure ticks arrived in order
            Assert.IsTrue(GOODTIME,"Tick arrived out-of-order.");
            // check running time
            Assert.LessOrEqual(time, EXPECTRAW,"may fail on slow machines");
            Assert.AreEqual(3,syms.Count);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.AreEqual(42610 + 4991 + 8041, tickcount);
            // 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);
            // last time is 1649 on SPX
            Assert.AreEqual(20080318155843, lasttime);
            // printout simulation runtime
            Console.WriteLine("Raw runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTRAW + "sec expected.");
            Console.WriteLine("Raw speed: " + ((double)tickcount / time).ToString("N0") + " ticks/sec");
        }
コード例 #2
0
ファイル: TestHistSim.cs プロジェクト: antonywu/tradelink
        public void BarPerformance()
        {
            HistSim h = new HistSim(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(HistSim.ENDSIM);

            double time = DateTime.Now.Subtract(start).TotalSeconds;
            Assert.GreaterOrEqual(tickcount, 50000);
            Assert.AreEqual(3, bt.SymbolCount);
            Assert.LessOrEqual(time, EXPECTBARS);
            Console.WriteLine("BarList runtime: " + time.ToString("N2") + "sec, versus: " + EXPECTBARS + "sec expected.");
            Console.WriteLine("BarList " + ((double)tickcount / time).ToString("N0") + " ticks/sec");
        }