Exemple #1
0
        public void InsertBar_HistoricalPlusNewBarsPresent()
        {
            string sym = "FTI";
            int    d   = 20070926;
            // historical bar filename
            string filename = sym + d + TikConst.DOT_EXT;
            // case 3 - middle insertion aka (some historical and some new bars already present)
            var org = BarListImpl.FromTIK(filename);

            Assert.IsTrue(org.isValid, "your original bar is not valid 3");
            var orgcount = org.Count;

            Assert.Greater(orgcount, 0);
            // create bar to insert
            var insert = new BarImpl(30, 30, 30, 30, 10000, d, 75500, sym, (int)BarInterval.FiveMin);

            Assert.IsTrue(insert.isValid, "your bar to insert is not valid 3");
            int insertpos = BarListImpl.GetBarIndexPreceeding(org, insert.Bardate);
            var inserted  = BarListImpl.InsertBar(org, insert, insertpos);

            Assert.AreEqual(inserted.Count, orgcount + 1);
            var actualinsert = inserted[insertpos];

            Assert.IsTrue(actualinsert.isValid);
            Assert.AreEqual(insert.Close, actualinsert.Close);
            Assert.AreEqual(insert.Open, actualinsert.Open);
            Assert.AreEqual(insert.High, actualinsert.High);
            Assert.AreEqual(insert.Low, actualinsert.Low);
            Assert.AreEqual(insert.Symbol, actualinsert.Symbol);
        }
Exemple #2
0
        public void InsertBar_HistoricalBarsPresent()
        {
            string sym = "FTI";
            int    d   = 20070926;
            // historical bar filename
            string filename = sym + d + TikConst.DOT_EXT;

            // unit test case 2 existing bars with front insertion (aka historical bar insert)

            var org = BarListImpl.FromTIK(filename);

            Assert.IsTrue(org.isValid, "your original bar is not valid 2");
            var orgcount = org.Count;

            Assert.Greater(orgcount, 0);
            // create bar to insert
            var insert = new BarImpl(30, 30, 30, 30, 10000, d, 75500, sym, (int)BarInterval.FiveMin);

            Assert.IsTrue(insert.isValid, "your bar to insert is not valid 2");
            var inserted = BarListImpl.InsertBar(org, insert, 0);

            Assert.AreEqual(inserted.Count, orgcount + 1);
            var actualinsert = inserted[0];

            Assert.IsTrue(actualinsert.isValid);
            Assert.AreEqual(insert.Close, actualinsert.Close);
            Assert.AreEqual(insert.Open, actualinsert.Open);
            Assert.AreEqual(insert.High, actualinsert.High);
            Assert.AreEqual(insert.Low, actualinsert.Low);
            Assert.AreEqual(insert.Symbol, actualinsert.Symbol);
        }
Exemple #3
0
        public void ReadAndOverwrite()
        {
            const string tf = @"SPX20070926.TIK";

            // read a barlist
            var bl = BarListImpl.FromTIK(tf);

            // get new bars
            var newbl = BarListImpl.DayFromGoogle("FTI");

            // append
            for (int i = 0; i < newbl.Count; i++)
            {
                foreach (var k in BarImpl.ToTick(newbl[i]))
                {
                    bl.newTick(k);
                }
            }



            // write the barlist
            Assert
            .IsTrue(BarListImpl.ChartSave(bl, Environment.CurrentDirectory, 20070926), "error saving new data");
        }
Exemple #4
0
        public void FromTIK()
        {
            // get sample tick data
            BarList bl = BarListImpl.FromTIK("FTI20070926.TIK");

            // verify expected number of 5min bars exist (78 in 9:30-4p)
            Assert.AreEqual(83, bl.Count);
        }
Exemple #5
0
        public void FromTIK()
        {
            const string tf = "FTI20070926.TIK";
            // get sample tick data
            BarList bl = BarListImpl.FromTIK(tf);

            // verify expected number of 5min bars exist (78 in 9:30-4p)
            Assert.Greater(bl.Count, 82, "not enough bars from: " + tf);
        }
Exemple #6
0
        public void TestMaximumHistory()
        {
            const string tf = @"Common\EURUSD20080826.TIK";

            // get sample tick data
            BarList bl = BarListImpl.FromTIK(tf);

            // verify that the max amount is set to 200
            Assert.True(bl.Count == 200);
        }
Exemple #7
0
        public void FromTIK()
        {
            const string tf = @"Common\EURUSD20080826.TIK";

            // get sample tick data
            BarList bl = BarListImpl.FromTIK(tf);

            // verify expected number of 5min bars exist (78 in 9:30-4p)
            Assert.True(bl.Count > 82);
        }
Exemple #8
0
        private void ChartMain_DragDrop(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            string   f = s[0];

            if (!f.Contains(TikConst.DOT_EXT))
            {
                return;
            }
            BarList bl = BarListImpl.FromTIK(f);

            newChart(bl);
        }
Exemple #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.CheckFileExists = true;
            od.CheckPathExists = true;
            od.DefaultExt      = TikConst.WILDCARD_EXT;
            od.Filter          = "TickFiles|" + TikConst.WILDCARD_EXT;
            od.Multiselect     = false;
            if (od.ShowDialog() == DialogResult.OK)
            {
                BarList bl = BarListImpl.FromTIK(od.FileName, _uselast, _usebid);
                newChart(bl);
            }
        }
Exemple #10
0
        public void InsertBar_OutOfOrderTicks()
        {
            string sym = "TPX";
            int    d   = 20120724;
            // historical bar filename
            string filename = sym + d + TikConst.DOT_EXT;

            //string filename = @"TPX20120724.TIK";

            // unit test case 2 existing bars with front insertion (aka historical bar insert)
            int[]         intervals = { (int)BarInterval.Minute };
            BarInterval[] types     = { BarInterval.Minute };

            BarList org = BarListImpl.FromTIK(filename, true, false, intervals, types);

            Assert.IsTrue(org.isValid, "your original bar is not valid 2");
            var orgcount = org.Count;

            Assert.AreEqual(2, orgcount, "Number of bars constructed doesn't match");
        }
Exemple #11
0
        public void InsertBar_OutOfOrderTicks()
        {
            string sym = "TPX";
            int    d   = 20120724;

            // historical bar filename
            string filename = @"Common\" + sym + d + TikConst.DotExt;

            //string filename = @"TPX20120724.TIK";
            // unit test case 2 existing bars with front insertion (aka historical bar insert)
            int[]         intervals = { (int)BarInterval.Minute };
            BarInterval[] types     = { BarInterval.Minute };

            BarList org = BarListImpl.FromTIK(filename, true, false, intervals, types);

            Assert.True(org.IsValid, "your original bar is not valid 2");
            var orgcount = org.Count;

            //Assert.Equal(2, orgcount);
            Assert.Equal(1, orgcount);
        }