diff --git a/Core/MarketAnalyzer/BaseAnalyzer.cs b/Core/MarketAnalyzer/BaseAnalyzer.cs index 1c16fd5..411f5c9 100644 --- a/Core/MarketAnalyzer/BaseAnalyzer.cs +++ b/Core/MarketAnalyzer/BaseAnalyzer.cs @@ -335,25 +335,34 @@ namespace Core.MarketAnalyzer } } - Market recentMarket = recentMarkets[recentMarketPair.Key]; - - List ignoredMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.IgnoredMarkets, ","); - if (ignoredMarkets.Contains(recentMarketPair.Value.Symbol)) + Market recentMarket; + + if (recentMarkets.TryGetValue(recentMarketPair.Key, out recentMarket)) { - log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' is ignored in this trend."); + List ignoredMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.IgnoredMarkets, ","); + if (ignoredMarkets.Contains(recentMarketPair.Value.Symbol)) + { + log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' is ignored in this trend."); + continue; + } + + List allowedMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.AllowedMarkets, ","); + if (allowedMarkets.Count > 0 && !allowedMarkets.Contains(recentMarketPair.Value.Symbol)) + { + log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' is not allowed in this trend."); + continue; + } + } + else + { + // No recent market data + log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' has no recent market trend data."); continue; } - List allowedMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.AllowedMarkets, ","); - if (allowedMarkets.Count > 0 && !allowedMarkets.Contains(recentMarketPair.Value.Symbol)) - { - log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' is not allowed in this trend."); - continue; - } + Market trendMarket; - Market trendMarket = trendMarkets[recentMarketPair.Key]; - - if (trendMarket != null) + if (trendMarkets.TryGetValue(recentMarketPair.Key, out trendMarket)) { double recentMarketPrice = recentMarket.Price; double trendMarketPrice = trendMarket.Price; @@ -384,6 +393,12 @@ namespace Core.MarketAnalyzer marketCount++; } + else + { + // No data market trend data + log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' has no market trend data."); + continue; + } } }