コード例 #1
0
 public static QuotesDataProvider GetQuoteDataProvider(Configs_QuoteDataProvider dataproviderConfigs, Configs_Market marketConfigs)
 {
     if (marketConfigs.QuoteProviderName == "EOD")
     {
         return(new QuotesDataProvider_EOD(dataproviderConfigs, marketConfigs));
     }
     if (marketConfigs.QuoteProviderName == "BOLSAR")
     {
         return(new QuotesDataProvider_BOLSAR(dataproviderConfigs, marketConfigs));
     }
     return(null);
 }
コード例 #2
0
        public Configs_QuoteDataProvider GetQuoteDataProviderConfig(string name)
        {
            Configs_QuoteDataProvider dataprovider = new Configs_QuoteDataProvider();

            dataprovider.Name = name;

            using (SqlConnection connection = new SqlConnection(this.configs.ConnectionString))
            {
                connection.Open();
                string        queryString = $"SELECT ConfigName, ConfigValue FROM Config WHERE ConfigName like '{name}_%'";
                SqlCommand    command     = new SqlCommand(queryString, connection);
                SqlDataReader reader      = command.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["ConfigName"].ToString().EndsWith("_APIToken"))
                    {
                        dataprovider.APIToken = reader["ConfigValue"].ToString();
                    }
                    else if (reader["ConfigName"].ToString().EndsWith("_RealTimeURL"))
                    {
                        dataprovider.RealTimeURL = reader["ConfigValue"].ToString();
                    }
                    else if (reader["ConfigName"].ToString().EndsWith("_HistoricalURL"))
                    {
                        dataprovider.HistoricalURL = reader["ConfigValue"].ToString();
                    }
                    else if (reader["ConfigName"].ToString().EndsWith("_Username"))
                    {
                        dataprovider.Username = reader["ConfigValue"].ToString();
                    }
                    else if (reader["ConfigName"].ToString().EndsWith("_LoginURL"))
                    {
                        dataprovider.LoginURL = reader["ConfigValue"].ToString();
                    }
                    else if (reader["ConfigName"].ToString().EndsWith("_IndexURL"))
                    {
                        dataprovider.IndexURL = reader["ConfigValue"].ToString();
                    }
                }
                reader.Close();
                connection.Close();
            }
            return(dataprovider);
        }
コード例 #3
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}");
        }
コード例 #4
0
 protected QuotesDataProvider(Configs_QuoteDataProvider dataproviderConfigs, Configs_Market marketConfigs)
 {
     this.MarketConfigs            = marketConfigs;
     this.QuoteDataProviderConfigs = dataproviderConfigs;
 }
コード例 #5
0
 public QuotesDataProvider_BOLSAR(Configs_QuoteDataProvider dataproviderConfigs, Configs_Market marketConfigs) : base(dataproviderConfigs, marketConfigs)
 {
 }