Пример #1
0
        public void RawPerformanceWithLoad()
        {
            System.ComponentModel.BackgroundWorker bw = new System.ComponentModel.BackgroundWorker();
            bw.DoWork += new System.ComponentModel.DoWorkEventHandler(bw_DoWork);
            bw.WorkerSupportsCancellation = true;
            MultiSimImpl h = new MultiSimImpl(Environment.CurrentDirectory);

            rawbase("raw performance multi w/load", 3, h);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.AreEqual(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.LessOrEqual(h.RunTimeSec, EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            Assert.AreEqual(20080318155843, lasttime);
            RawPerformance();
            bw.CancelAsync();
            run = false;
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.AreEqual(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.LessOrEqual(h.RunTimeSec, EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            Assert.AreEqual(20080318155843, lasttime);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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");
        }
Пример #4
0
        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();
        }
        bool loadsim()
        {
            _historicalSimulator           = new MultiSimImpl(_historicalDataFiles.ToArray());
            _historicalSimulator.CacheWait = _cacheWait;
            _historicalSimulator.GotTick  += historicalSimulator_GotTick;

            _broker = new Broker();
            _broker.UseBidAskFills  = _useBidAskFills;
            _broker.GotOrder       += broker_GotOrder;
            _broker.GotFill        += broker_GotFill;
            _broker.GotOrderCancel += broker_GotOrderCancel;

            try
            {
                StatusUpdate("Loaded tickdata: " + prettyTickDataFiles());
                return(true);
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains("used by another process"))
                {
                    StatusUpdate("Simulation file still in use.");
                    MessageUpdate("Try again, one of following in use: " + string.Join(",", _historicalDataFiles.ToArray()));
                }
                return(false);
            }
        }
Пример #6
0
        public void RawSingleFromZip()
        {
            MultiSimImpl h = new MultiSimImpl(new string[] { @"Common\AUDJPY.zip\AUDJPY20070510.TIK" });

            rawbase("rawsingle", 1, h);
            Assert.Equal(5616, tickcount);
        }
Пример #7
0
        public void RawPerformanceWithLoad()
        {
            System.ComponentModel.BackgroundWorker bw = new System.ComponentModel.BackgroundWorker();
            bw.DoWork += bw_DoWork;
            bw.WorkerSupportsCancellation = true;
            MultiSimImpl h = new MultiSimImpl(new string[] { @"Common\FTI20070926.TIK", @"Common\ABN20080318.TIK", @"Common\SPX20070926.TIK" });

            rawbase("raw performance multi w/load", 3, h);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.Equal(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.True(h.RunTimeSec <= EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            //Assert.Equal(20080318155843, lasttime);
            Assert.Equal(20080318000155843, lasttime);
            RawPerformance();
            bw.CancelAsync();
            run = false;
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.Equal(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.True(h.RunTimeSec <= EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            //Assert.Equal(20080318155843, lasttime);
            Assert.Equal(20080318000155843, lasttime);
        }
Пример #8
0
        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();
        }
Пример #9
0
        public void RawSingle()
        {
            MultiSimImpl h = new MultiSimImpl(new string[] { "FTI20070926.TIK" });

            rawbase("rawsingle", 1, h);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.Greater(tickcount, 40000);
        }
Пример #10
0
        void initializeSim()
        {
            _backgroundWorker    = new BackgroundWorker();
            _historicalSimulator = new MultiSimImpl();
            _broker = new Broker();

            _broker.UseBidAskFills    = _useBidAskFills;
            _backgroundWorker.DoWork += play;
            _backgroundWorker.WorkerReportsProgress      = false;
            _backgroundWorker.WorkerSupportsCancellation = true;
            _backgroundWorker.RunWorkerCompleted        += PlayComplete;
        }
Пример #11
0
        public void RawPerformance()
        {
            MultiSimImpl h = new MultiSimImpl(Environment.CurrentDirectory);

            rawbase("raw performance multi", 3, h);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.AreEqual(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.LessOrEqual(h.RunTimeSec, EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            Assert.AreEqual(20080318155843, lasttime);
        }
Пример #12
0
        public void RawPerformance()
        {
            MultiSimImpl h = new MultiSimImpl(new string[] { "FTI20070926.TIK", "ABN20080318.TIK", "SPX20070926.TIK" });

            rawbase("raw performance multi", 3, h);
            // tick count is = 42610 (FTI) + 5001 (SPX) + 8041 (ABN)
            Assert.AreEqual(42610 + 4991 + 8041, tickcount);
            // check running time
            Assert.LessOrEqual(h.RunTimeSec, EXPECTRAW, "may fail on slow machines");

            // last time is 1649 on SPX
            Assert.AreEqual(20080318155843, lasttime);
        }
Пример #13
0
        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());
        }
Пример #14
0
        public void RawMultiFromZip()
        {
            MultiSimImpl h = new MultiSimImpl(new string[]
            {
                @"Common\EURUSD.zip\EURUSD20070601.TIK",
                @"Common\EURUSD.zip\EURUSD20070531.TIK",
                @"Common\EURUSD.zip\EURUSD20070530.TIK",
                @"Common\EURUSD.zip\EURUSD20070529.TIK",
                @"Common\EURUSD.zip\EURUSD20070528.TIK",
                @"Common\EURUSD.zip\EURUSD20070527.TIK",
                @"Common\EURUSD.zip\EURUSD20070525.TIK",
                @"Common\EURUSD.zip\EURUSD20070524.TIK",
                @"Common\EURUSD.zip\EURUSD20070523.TIK",
                @"Common\EURUSD.zip\EURUSD20070522.TIK",
                @"Common\EURUSD.zip\EURUSD20070521.TIK",
                @"Common\EURUSD.zip\EURUSD20070520.TIK",
                @"Common\EURUSD.zip\EURUSD20070518.TIK",
                @"Common\EURUSD.zip\EURUSD20070517.TIK",
                @"Common\EURUSD.zip\EURUSD20070516.TIK",
                @"Common\EURUSD.zip\EURUSD20070515.TIK",
                @"Common\EURUSD.zip\EURUSD20070514.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070601.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070531.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070530.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070529.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070528.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070527.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070525.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070524.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070523.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070522.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070521.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070520.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070518.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070517.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070516.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070515.TIK",
                @"Common\GBPJPY.zip\GBPJPY20070514.TIK",
            }
                                              );

            rawbase("rawsingle", 2, h);
            Assert.Equal(2840, tickcount);
            Assert.Equal(20070601, Util.ToQLDate(lasttick.TickDateTime));
        }