From 1693b00cf48dada0b3f039cc331fb505593ad329 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Tue, 30 Mar 2021 23:39:27 +0900 Subject: [PATCH] Market trends ignore/allowed --- Core/MarketAnalyzer/BaseAnalyzer.cs | 43 ++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Core/MarketAnalyzer/BaseAnalyzer.cs b/Core/MarketAnalyzer/BaseAnalyzer.cs index 00d784b..4f0ff6d 100644 --- a/Core/MarketAnalyzer/BaseAnalyzer.cs +++ b/Core/MarketAnalyzer/BaseAnalyzer.cs @@ -308,16 +308,51 @@ namespace Core.MarketAnalyzer } Market recentMarket; + string market = recentMarketPair.Value.Symbol.Replace(mainMarket, ""); + string exchange = systemConfiguration.GeneralSettings.Application.Exchange.ToLower(); + switch (exchange) + { + case "bittrex": + market = market.Replace("-", ""); + break; + case "poloniex": + market = market.Replace("-", ""); + break; + } if (recentMarkets.TryGetValue(recentMarketPair.Key, out recentMarket)) { - List ignoredMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.IgnoredMarkets, ","); - if (ignoredMarkets.Any(im => recentMarketPair.Value.Symbol.StartsWith(im, StringComparison.InvariantCultureIgnoreCase))) + // Strip main markets from lists, if exists + string ignored = marketTrend.IgnoredMarkets.ToUpper(); + ignored = ignored.Replace(mainMarket, ""); + switch (exchange) + { + case "bittrex": + ignored = ignored.Replace("-", ""); + break; + case "poloniex": + ignored = ignored.Replace("_", ""); + break; + } + List ignoredMarkets = SystemHelper.ConvertTokenStringToList(ignored, ","); + if (ignoredMarkets.Contains(market)) { 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.Any(am => recentMarketPair.Value.Symbol.StartsWith(am, StringComparison.InvariantCultureIgnoreCase))) + // Strip main markets from lists, if exists + string allowed = marketTrend.AllowedMarkets.ToUpper(); + allowed = allowed.Replace(mainMarket, ""); + switch (exchange) + { + case "bittrex": + allowed = allowed.Replace("-", ""); + break; + case "poloniex": + allowed = allowed.Replace("_", ""); + break; + } + List allowedMarkets = SystemHelper.ConvertTokenStringToList(allowed, ","); + if (allowedMarkets.Count > 0 && !allowedMarkets.Contains(market)) { log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' is not allowed in this trend."); continue;