コード例 #1
0
        private void UpdateMarketRealTimeQuotes(string providerName, string marketName, string data)
        {
            Configs_Market marketConfigs = this.dbcontext.GetMarketConfig(marketName);

            LOG.Log($">>> MARKET Configs: {marketConfigs.Name}|{marketConfigs.LastSync}|{marketConfigs.NextSync}|{marketConfigs.UTCOffset}|{marketConfigs.QuotesUpdatesActive}|");

            DateTime date = DateTime.UtcNow.AddHours(marketConfigs.UTCOffset);

            if (Configs_Market.QuoteUpdateAvailabe(marketConfigs, this.dbcontext.IsHoliday, date))
            {
                QuotesProvider quotesProvider = QuotesProvider.GetQuotesProviderInstance(providerName);
                Tuple <List <IRealTimeQuote>, List <IHistoricalQuote> > quotes = quotesProvider.GetQuotesFromJson(data);
                this.dbcontext.SaveRealTimeQuoteV1(quotes.Item1);
                this.dbcontext.SaveHistoricalQuoteV1(quotes.Item2);
                this.dbcontext.UpdateConfig($"{marketName}_LastSync", date.ToString());
            }
            this.dbcontext.UpdateConfig($"{marketName}_NextSync", date.AddMinutes(15).ToString());
        }
コード例 #2
0
        private void UpdateMarketRealTimeQuotes(string marketName)
        {
            LOG.Log($"   >> {marketName} Starting - {DateTime.Now}");

            Configs_Market marketConfigs = this.dbcontext.GetMarketConfig(marketName);

            LOG.Log($"      MARKET: {marketConfigs.Name}|{marketConfigs.LastSync}|{marketConfigs.NextSync}|{marketConfigs.UTCOffset}|{marketConfigs.QuotesUpdatesActive}|");

            Configs_QuoteDataProvider dataproviderConfigs = this.dbcontext.GetQuoteDataProviderConfig(marketConfigs.QuoteProviderName);

            LOG.Log($"      QUOTES:{dataproviderConfigs.Name}|{dataproviderConfigs.APIToken}|{dataproviderConfigs.HistoricalURL}|{dataproviderConfigs.RealTimeURL}|");

            List <mdlStock> stocks = this.dbcontext.GetMarketActiveStocks(marketName);

            LOG.Log($"      STOCKS: Count={stocks.Count}|");

            DateTime date = DateTime.UtcNow.AddHours(marketConfigs.UTCOffset);

            if (Configs_Market.QuoteUpdateAvailabe(marketConfigs, this.dbcontext.IsHoliday, date))
            {
                QuotesDataProvider            quotesDataProvider = QuotesDataProvider.GetQuoteDataProvider(dataproviderConfigs, marketConfigs);
                List <HistoricalQuoteDBModel> historical;
                List <RealTimeQuoteDBModel>   realtime = quotesDataProvider.GetRealTimeQuotes(stocks, date, this.dbcontext, out historical);
                LOG.Log($"      REALTIME: Count={realtime.Count}|");
                LOG.Log($"      HISTORICAL: Count={historical.Count}|");
                this.dbcontext.SaveRealTimeQuote(realtime);
                this.dbcontext.SaveHistoricalQuote(historical);
                this.dbcontext.UpdateConfig($"{marketName}_LastSync", date.ToString());
            }
            this.dbcontext.UpdateConfig($"{marketName}_NextSync", date.AddMinutes(15).ToString());

            if (date.Hour == 5)
            {
                string result = this.dbcontext.DeleteIntradiaryQuotes();
                LOG.Log($"      {result}");
            }

            LOG.Log($"   << {marketName} End - {DateTime.Now}");
        }