Exemplo n.º 1
0
        public void AddIntervalWhileRunning()
        {
            OHLCBarStream blt = new OHLCBarStream(new ForexSecurity("TST"));

            blt.AddInterval(BarInterval.Minute);
            blt.AddInterval(BarInterval.FiveMin);
            blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar);

            Tick[] tape = TestBarList.SampleData();
            blt.Initialize();

            // add ticks from tape to tracker
            for (int i = 0; i < tape.Length; i++)
            {
                blt.GotTick(tape[i]);
                if (i == 1)
                {
                    blt.AddInterval(120);
                }
            }

            //make sure we got one symbol as bar events
            Assert.Equal(1, syms.Count);

            // make sure our symbols matched barlist count
            Assert.Equal(blt.SymbolCount, syms.Count);

            // make sure same on individual bars
            Assert.True(blt[120].Count > 0);
        }
Exemplo n.º 2
0
        public void TickInt()
        {
            Tick[]             tape = TestBarList.SampleData();
            BarListTrackerImpl blt  = new BarListTrackerImpl(new[] { 3 }, new BarInterval[] { BarInterval.CustomTicks });

            foreach (Tick k in tape)
            {
                blt.NewTick(k);
            }

            Assert.Equal(4, blt[tape[0].Symbol].Count);
        }
Exemplo n.º 3
0
        public void DefaultInt()
        {
            BarListTrackerImpl blt = new BarListTrackerImpl();

            blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar);

            Tick[] tape = TestBarList.SampleData();
            // get second tape and change symbol
            Tick[] tape2 = new Tick[tape.Length];
            for (int i = 0; i < tape2.Length; i++)
            {
                TickImpl t = (TickImpl)tape[i];
                t.Symbol = "TST2";
                tape2[i] = t;
            }

            // add ticks from both tape to tracker
            for (int i = 0; i < tape.Length; i++)
            {
                blt.NewTick(tape[i]);
                blt.NewTick(tape2[i]);
            }

            //make sure we got two symbols as bar events
            Assert.Equal(2, syms.Count);
            // make sure our symbols matched barlist count
            Assert.Equal(blt.SymbolCount, syms.Count);

            int    secondcount = 0;
            string symstring   = string.Empty;

            foreach (string sym in blt)
            {
                secondcount++;
                symstring += sym;
            }

            // make sure enumeration equals symbol count
            Assert.Equal(syms.Count, secondcount);
            // make sure symbols are there
            Assert.True(symstring.Contains("TST") && symstring.Contains("TST2"));

            // change default interval
            blt.DefaultInterval = BarInterval.Minute;
            // make sure same on individual bars
            Assert.Equal(blt.DefaultInterval, blt["TST"].DefaultInterval);

            Assert.Equal(9, blt["TST"].IntervalCount(BarInterval.Minute));
            Assert.Equal(3, blt["TST"].IntervalCount(BarInterval.FiveMin));
        }
Exemplo n.º 4
0
        public void IntervalRequestDuringRun()
        {
            OHLCBarStream blt = new OHLCBarStream(new ForexSecurity("TST"));

            blt.AddInterval(BarInterval.FiveMin);
            blt.GotNewBar += new SymBarIntervalDelegate(blt_GotNewBar);

            Tick[] tape = TestBarList.SampleData();
            blt.Initialize();

            // add ticks from tape to tracker
            for (int i = 0; i < tape.Length; i++)
            {
                blt.GotTick(tape[i]);
                var value = blt[BarInterval.Minute].RecentBar;
            }

            // Check if the data differs per interval
            Assert.NotEqual(blt[BarInterval.Minute][-2].Close, blt[BarInterval.FiveMin][-2].Close);
        }