Beispiel #1
0
 public SingleLoader()
 {
     singleLoadTimer = new Timer(new TimerCallback(ThreadCallBack), null, Timeout.Infinite, Config.GlobalConfig.ThreadConfig.RealtimeReadTime);
     isRunning       = false;
     stockIdChanged  = true;
     stockId         = "-1";
     lastMinutTime   = "09:30";
     current         = DataDefine.GetNewStocksRealtimeTable().NewRow();
     perminut        = DataDefine.GetNewStocksPerminutTable();
 }
Beispiel #2
0
        private void ReadRealTime()
        {
            DataTable bufferTable = DataDefine.GetNewStocksRealtimeTable();

            DataAPIFactory.GetDataAPI(APIConfig.ApiType).GetRealTimeTable(bufferTable, GlobalData.CurrentShowList);
            if (Config.GlobalConfig.WebConfig.ConnectMode)
            {
                GlobalData.StocksTable = bufferTable;
                if (bufferTable.Rows.Count > 0)
                {
                    GlobalData.LastTradeTime = TimeSpan.Parse(bufferTable.Rows[0]["time"].ToString());
                    GlobalData.LastTradeDate = DateTime.Parse(bufferTable.Rows[0]["date"].ToString());
                }
            }
            else
            {
                ReadRealTimeFromDB();
            }
        }
Beispiel #3
0
        public static void SavePerbid(Object stockId)
        {
            if (!Config.GlobalConfig.WebConfig.ConnectMode)
            {
                return;
            }
            DataTable stockPerbid = DataDefine.GetNewStocksPerbidTable();

            string newestPeriBidsInDB = DBHelper.GetNewestPerbidTime(stockId.ToString());

            TimeSpan newestTimeInDB = TimeSpan.Parse(newestPeriBidsInDB);

            if (newestTimeInDB < TimeSpan.Parse("15:00:00"))
            {
                int readCount = (int)(TimeSpan.Parse(GlobalData.LastTradeTime.ToString()) - newestTimeInDB).TotalSeconds / 3;
                if (readCount > 5000)
                {
                    readCount = -1;
                }
                DataAPIFactory.GetDataAPI(APIConfig.ApiType).GetPerbidTable(stockPerbid, stockId.ToString(), readCount);

                DBHelper.InsertIntoPerbid(stockPerbid);
            }
        }
Beispiel #4
0
        public static void SaveHistory(Object stockId)
        {
            if (!Config.GlobalConfig.WebConfig.ConnectMode)
            {
                return;
            }
            DataTable stockHistories = DataDefine.GetNewStocksHistoryTable();
            //string newestHistoryInDB = DBHelper.GetNewestHistoryDate(stockId.ToString());
            int dirtaDay = 365;

            /*if (!newestHistoryInDB.Equals(""))
             * {
             *  DateTime lastHistoryDate = DateTime.Parse(newestHistoryInDB);
             *
             *  if (lastHistoryDate.AddDays(1) >= GlobalData.LastTradeDate)
             *  {
             *      return;
             *  }
             *  dirtaDay = (int)(GlobalData.LastTradeDate - lastHistoryDate).TotalDays;
             * }*/

            DataAPIFactory.GetDataAPI(APIConfig.ApiType).GetHistoriesTable(stockHistories, stockId.ToString(), dirtaDay);
            DBHelper.InsertIntoHistory(stockHistories);
        }