Esempio n. 1
0
        public void InterOpSpeed()
        {
            const int TESTSIZE = 100;

            count = 0;
            // get some random prices
            Tick[] data = RandomTicks.GenerateSymbol(sym, TESTSIZE);
            // track the time
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            int bad = 0;

            sw.Start();
            for (int i = 0; i < data.Length; i++)
            {
                int err = SendOrder(sym, true, 300, (double)data[i].trade, 0, 1, "TESTACCOUNT", "TESTDEST");
                if (err != 0)
                {
                    bad++;
                }
            }
            sw.Stop();
            long   elapms = sw.ElapsedMilliseconds;
            double elap   = (double)elapms / 1000;
            double rate   = TESTSIZE / elap;

            Console.WriteLine("InterOpSpeed elap: " + elap.ToString("N1") + " rate: " + rate.ToString("N0") + " orders/sec");
            // make sure orders received
            Assert.AreEqual(data.Length, count);
            // make sure no bad orders
            Assert.AreEqual(0, bad);
            // make sure fast
            Assert.LessOrEqual(elap, .5);
        }
Esempio n. 2
0
        public void Basics()
        {
            Tick[] ticks = RandomTicks.GenerateSymbol("TST", 1000);
            bool   v     = true;

            foreach (Tick k in ticks)
            {
                v &= k.isValid;
            }
            Assert.IsTrue(v);
        }
Esempio n. 3
0
        public void CreateRead()
        {
            readdata.Clear();
            readdata2.Clear();
            FILE = TikWriter.SafeFilename(SYM, PATH, DATE);
            TestTikWriterReader.removefile(FILE);
            {
                Tick[] data = RandomTicks.GenerateSymbol(SYM, MAXTICKS);

                TickArchiver ta = new TickArchiver(Environment.CurrentDirectory);
                for (int i = 0; i < data.Length; i++)
                {
                    data[i].date = DATE;
                    data[i].time = Util.DT2FT(DateTime.Now);
                    ta.newTick(data[i]);
                }
                ta.Stop();

                // read file back in from file
                TikReader tr = new TikReader(FILE);
                tr.gotTick += new TickDelegate(tr_gotTick);
                while (tr.NextTick())
                {
                    ;
                }

                // verify length
                Assert.AreEqual(data.Length, readdata.Count);
                // verify content
                bool equal = true;
                for (int i = 0; i < MAXTICKS; i++)
                {
                    equal &= data[i].trade == readdata[i].trade;
                }
                tr.Close();

                readdata.Clear();
                Assert.IsTrue(equal, "ticks did not matched archive.");
                TestTikWriterReader.removefile(FILE);
            }
        }
Esempio n. 4
0
        public void CreateRead()
        {
            _readdata.Clear();
            _readdata2.Clear();
            _file = TikWriter.SafeFilename(Sym, _path, Date);
            TestTikWriterReader.Removefile(_file);
            {
                TickImpl[] data = RandomTicks.GenerateSymbol(Sym, Maxticks).Select(x => (TickImpl)x).ToArray();

                TickArchiver ta = new TickArchiver(Environment.CurrentDirectory);
                for (int i = 0; i < data.Length; i++)
                {
                    data[i].Date = Date;
                    data[i].Time = Util.DT2FT(DateTime.Now);
                    ta.NewTick(data[i]);
                }
                ta.Stop();

                // read file back in from file
                TikReader tr = new TikReader(_file);
                tr.GotTick += tr_gotTick;
                while (tr.NextTick())
                {
                }

                // verify length
                Assert.Equal(data.Length, _readdata.Count);
                // verify content
                bool equal = true;
                for (int i = 0; i < Maxticks; i++)
                {
                    equal &= data[i].Trade == _readdata[i].Trade;
                }
                tr.Close();

                _readdata.Clear();
                Assert.True(equal, "ticks did not matched archive.");
                TestTikWriterReader.Removefile(_file);
            }
        }