示例#1
0
        void StockDB()
        {
            StockDBApi api  = new StockDBApi();
            var        date = new DateTime(2018, 01, 31);

            for (int i = 0; i < 360; i++)
            {
                if (i >= DateTime.Now.DayOfYear)
                {
                    break;
                }

                var date1 = date.AddDays(i);
                if (!(date1.DayOfWeek == DayOfWeek.Saturday || date1.DayOfWeek == DayOfWeek.Sunday))
                {
                    Globals.Log.Error($"Downloading data for {date1} {i}");
                    var data = DownloadTodayData(date1);
                    if (data != null)
                    {
                        int count = api.AddOrUpdateEquityInformation(data.Equitys, data.Etfs, data.Indexes);
                        count += api.AddBhavData(date1, data.BhavData, data.deliveryPosition,
                                                 data.IndexBhavData, data.circuitBreaker,
                                                 data.highLow52Week);
                        Globals.Log.Info($"Updated {count} rows");
                    }
                    else
                    {
                        Globals.Log.Error($"Data does not exists for {date1}");
                    }
                }
            }
        }
示例#2
0
        public async Task <int> UpdateStockDataFor(DateTime dateToUpdate)
        {
            int count = 0;
            var data  = await marketApi.GetDailyData(dateToUpdate);

            if (data != null)
            {
                //dbApi.AddOrUpdateEquityInformation(data.Equitys, data.Etfs, data.Indexes);
                count += dbApi.AddBhavData(dateToUpdate, data.BhavData, data.deliveryPosition, data.IndexBhavData,
                                           data.circuitBreaker, data.highLow52Week);
            }
            else
            {
                Globals.Log.Error($"Failed to Update Market data for date {dateToUpdate}");
            }
            return(count);
        }