示例#1
0
        public void TestYahooDownloadCSV()
        {
            var yahoo = new YahooDownload();

            yahoo.Precision = 2;
            yahoo.LoadAllData("yhoo", OutputName.ToString(), CSVFormat.English,
                              new DateTime(2000, 01, 01),
                              new DateTime(2000, 01, 10));
            var tr = new StreamReader(OutputName.ToString());

            Assert.AreEqual(
                "date,time,open price,high price,low price,close price,volume,adjusted price",
                tr.ReadLine());
            Assert.AreEqual(
                "20000110,0,432.5,451.25,420,436.06,61022400,109.02",
                tr.ReadLine());
            Assert.AreEqual("20000107,0,366.75,408,363,407.25,48999600,101.81",
                            tr.ReadLine());
            Assert.AreEqual("20000106,0,406.25,413,361,368.19,71301200,92.05",
                            tr.ReadLine());
            Assert.AreEqual(
                "20000105,0,430.5,431.12,402,410.5,83194800,102.62",
                tr.ReadLine());
            tr.Close();
        }
示例#2
0
        private void button12_Click(object sender, EventArgs e)
        {
            IEnumerable <Stock> stocks = new List <Stock>();
            YahooDownload       yd     = new YahooDownload();

            yd.LowPrice  = int.Parse(textBox2.Text);
            yd.HighPrice = int.Parse(textBox3.Text);;
            yd.LowVol    = int.Parse(textBox4.Text);;
            yd.Url       = @"https://tw.stock.yahoo.com/d/i/rank.php?t=up&e=tse&n=100";
            yd.stockType = "1";
            stocks       = yd.GetStocks();
            yd.Url       = @"https://tw.stock.yahoo.com/d/i/rank.php?t=down&e=tse&n=100";
            yd.stockType = "1";
            stocks       = stocks.Concat(yd.GetStocks());
            yd.Url       = @"https://tw.stock.yahoo.com/d/i/rank.php?t=up&e=otc&n=100";
            yd.stockType = "2";
            stocks       = stocks.Concat(yd.GetStocks());
            yd.Url       = @"https://tw.stock.yahoo.com/d/i/rank.php?t=down&e=otc&n=100";
            yd.stockType = "2";
            stocks       = stocks.Concat(yd.GetStocks());
            this.Stocks  = stocks;
            this.iStock  = -1;
            InitListView();
            button1_Click(sender, e);
        }
示例#3
0
        public void TestYahooDownloadError()
        {
            try
            {
                var yahoo = new YahooDownload();
                yahoo.Precision = 2;
                // load a non-sense ticker, should throw error
                yahoo.LoadAllData("sdfhusdhfuish", OutputName.ToString(), CSVFormat.English,
                                  new DateTime(2000, 01, 01),
                                  new DateTime(2000, 01, 10));

                // bad!
                Assert.IsTrue(false);
            }
            catch (QuantError)
            {
                // good!
            }
        }