Esempio n. 1
0
 private void LoadCurrent()
 {
     if (WebConfig.ConnectMode)
     {
         DataAPIFactory.GetDataAPI(APIConfig.ApiType).GetStockRealTime(current, stockId);
         try
         {
             GlobalData.LastTradeTime = TimeSpan.Parse(current["time"].ToString());
             GlobalData.LastTradeDate = DateTime.Parse(current["date"].ToString());
         }
         catch (Exception e)
         {
         }
     }
     else
     {
         current = DBHelper.GetStockRealTime(stockId);
     }
     if (lastRecord.vol == 0)
     {
         lastRecord.vol = int.Parse(current["volume"].ToString());
         lastRecord.ask = decimal.Parse(current["ask1Price"].ToString());
         lastRecord.bid = decimal.Parse(current["bid1Price"].ToString());
     }
     else if (decimal.Parse(current["volume"].ToString()) != lastRecord.vol)
     {
         CalculatePerbid();
     }
 }
Esempio n. 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();
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }