Beispiel #1
0
        void ASP_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_resskinidx.Count > 0)
            {
                _saveskins_Click(null, null);
            }
            // if we're using another thread to process ticks, stop it
            if (Environment.ProcessorCount > 1)
            {
                _ar.Stop();
            }
            // stop archiving ticks
            _ta.Stop();
            // stop logging
            _log.Stop();
            // save ASP properties
            Properties.Settings.Default.Save();

            // shut down tradelink client
            try
            {
                tl.Disconnect();
            }
            catch (TLServerNotFound) { }
        }
Beispiel #2
0
 void _tlt_GotConnect()
 {
     debug(tl.BrokerName + " " + tl.ServerVersion + " connected.");
     status(tl.BrokerName.ToString());
     try
     {
         // resubscribe
         if (mb.Count > 0)
         {
             tl.Subscribe(mb);
         }
     }
     catch { }
     if (tl.BrokerName == Providers.TradeLink)
     {
         _ta.Stop();
         _tlt.Stop();
     }
 }
        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);
            }
        }
Beispiel #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);
            }
        }
        public void Multiday()
        {
            readdata.Clear();
            readdata2.Clear();
            int           d  = 20100223;
            int           t  = 235900;
            int           t1 = 0;
            const decimal p  = 50;
            int           s  = 100;

            string FILE1 = TikWriter.SafeFilename(SYM, PATH, d);

            TestTikWriterReader.removefile(FILE1);
            string FILE2 = TikWriter.SafeFilename(SYM, PATH, d + 1);

            TestTikWriterReader.removefile(FILE2);


            Tick[] data = new Tick[]
            {
                TickImpl.NewTrade(SYM, d, t++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t++, p, s, string.Empty),
                // day two
                TickImpl.NewTrade(SYM, ++d, t1++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t1++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t1++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t1++, p, s, string.Empty),
                TickImpl.NewTrade(SYM, d, t1++, p, s, string.Empty),
            };


            TickArchiver ta = new TickArchiver(Environment.CurrentDirectory);

            for (int i = 0; i < data.Length; i++)
            {
                ta.newTick(data[i]);
            }
            ta.Stop();

            // read file back in from files
            if (System.IO.File.Exists(FILE1))
            {
                TikReader tr = new TikReader(FILE1);
                tr.gotTick += new TickDelegate(tr_gotTick);
                while (tr.NextTick())
                {
                    ;
                }
                tr.Close();
            }

            if (System.IO.File.Exists(FILE2))
            {
                TikReader tr2 = new TikReader(FILE2);
                tr2.gotTick += new TickDelegate(tr2_gotTick);
                while (tr2.NextTick())
                {
                    ;
                }
                tr2.Close();
            }

            // verify length
            Assert.AreEqual(5, readdata2.Count);
            Assert.AreEqual(5, readdata.Count);

            TestTikWriterReader.removefile(FILE1);
            TestTikWriterReader.removefile(FILE2);
        }
Beispiel #6
0
        public void Multiday()
        {
            _readdata.Clear();
            _readdata2.Clear();
            int           d  = 20100223;
            int           t  = 235900;
            int           t1 = 0;
            const decimal p  = 50;
            int           s  = 100;

            string file1 = TikWriter.SafeFilename(Sym, _path, d);

            TestTikWriterReader.Removefile(file1);
            string file2 = TikWriter.SafeFilename(Sym, _path, d + 1);

            TestTikWriterReader.Removefile(file2);

            Tick[] data =
            {
                TickImpl.NewTrade(Sym, d,   t++,  p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t++,  p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t++,  p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t++,  p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t++,  p, s, string.Empty),
                // day two
                TickImpl.NewTrade(Sym, ++d, t1++, p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t1++, p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t1++, p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t1++, p, s, string.Empty),
                TickImpl.NewTrade(Sym, d,   t1++, p, s, string.Empty),
            };

            TickArchiver ta = new TickArchiver(Environment.CurrentDirectory);

            for (int i = 0; i < data.Length; i++)
            {
                ta.NewTick(data[i]);
            }
            ta.Stop();

            // read file back in from files
            if (System.IO.File.Exists(file1))
            {
                TikReader tr = new TikReader(file1);
                tr.GotTick += tr_gotTick;
                while (tr.NextTick())
                {
                    ;
                }
                tr.Close();
            }

            if (System.IO.File.Exists(file2))
            {
                TikReader tr2 = new TikReader(file2);
                tr2.GotTick += tr2_gotTick;
                while (tr2.NextTick())
                {
                    ;
                }
                tr2.Close();
            }

            // verify length
            Assert.Equal(5, _readdata2.Count);
            Assert.Equal(5, _readdata.Count);

            TestTikWriterReader.Removefile(file1);
            TestTikWriterReader.Removefile(file2);
        }
Beispiel #7
0
 public void Dispose()
 {
     Stop();
     _tickarchiveservice.Stop();
 }