Esempio n. 1
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);
        }
Esempio n. 2
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 = 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);
        }
Esempio n. 3
0
        public QuoteDispatcherService(IQuoteUpdateService quoteviewupdateservvice, IStrategyQuoteFeedService feedstrategyquoteservice, TickArchiver tickarchiveservice, ILoggerFacade logger, BlockingCollection <Tick> tickqueue)
        {
            this._quoteviewupdateservice   = quoteviewupdateservvice;
            this._feedstrategyquoteservice = feedstrategyquoteservice;
            this._tickarchiveservice       = tickarchiveservice;
            this._tickqueue = tickqueue;
            this._logger    = logger;
            ConfigManager conf = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IConfigManager>() as ConfigManager;

            sampletime_ = conf.TickSampleTime;

            IObservable <MyEventArgs <Tick> > tickObservable = System.Reactive.Linq.Observable.FromEvent <MyEventArgs <Tick> >(
                h => TickReceived += h, h => TickReceived -= h);

            // only select trade
            // .BufferWithTime(TimeSpan.FromMilliseconds(_od))
            // .Where(x => x.Count > 0)
            // .Subscribe(DataReceived, LogError);
            tickObservable.Where(e => e.Value.IsTrade).GroupBy(e => e.Value.FullSymbol)
            .Subscribe(group => group.Sample(TimeSpan.FromSeconds(sampletime_))
                       .Subscribe(QuoteDispatcher));
        }