Пример #1
0
        public static void ClearTimeOfHistoricalData(object Sender)
        {
            DataTable     dt  = DB.GetDataTable("select QuoteCode from stockdata");
            DBDataManager ddm = new DBDataManager();

            for (int j = 0; j < dt.Rows.Count; j++)
            {
                DataRow dr   = dt.Rows[j];
                string  Code = dr["QuoteCode"].ToString();
                try
                {
                    CommonDataProvider cdp = (CommonDataProvider)ddm[Code];
                    cdp.TrimTime();
                    cdp.SaveBinary(DBDataManager.GetHisDataFile(Code));
                    Thread.Sleep(1);
                    if ((j % 100) == 0)
                    {
                        Tools.Log("Clear time of historical data progress:" + j + "/" + dt.Rows.Count);
                    }
                }
                catch (Exception e)
                {
                    Tools.Log("Clear time of histoical data:" + Code + ";" + e);
                    throw;
                }
            }
        }
Пример #2
0
        static public void DownloadYahooHistory(string Symbol, bool Force, bool AddRealtime)
        {
            string FileName = DBDataManager.GetHisDataFile(Symbol);

            if (Force || !File.Exists(FileName))
            {
                DateTime           d    = DateTime.Now.AddDays(3);
                string             URL  = "http://table.finance.yahoo.com/table.csv?s={0}&d=" + (d.Month - 1) + "&e=" + d.Day + "&f=" + d.Year + "&g=d&a=6&b=30&c=" + Config.HistoricalDataYear + "&ignore=.csv";
                string             s    = string.Format(URL, Symbol);
                byte[]             bs   = DownloadData(s);
                CommonDataProvider cdpn = new YahooDataManager().LoadYahooCSV(bs);
                if (AddRealtime)
                {
                    cdpn.Merge(DataPacket.DownloadFromYahoo(Symbol));
                }
                UpdateRealtime(Symbol, cdpn);
                if (File.Exists(FileName))
                {
                    File.Delete(FileName);
                }
                cdpn.SaveBinary(FileName);
            }
        }