diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index c05e084..3a98e25 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -146,6 +146,9 @@ namespace Core.Main.DataObjects.PTMagicData [DefaultValue("")] public string AllowedMarkets { get; set; } = ""; + [DefaultValue(0)] + public int IgnoreOutlier { get; set; } = 0; + [DefaultValue(true)] public bool ExcludeMainCurrency { get; set; } = true; } diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 7bdf293..2bffb45 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -1310,7 +1310,7 @@ namespace Core.Main // CoinMarketCap this.GlobalMarketTrendChanges = BaseAnalyzer.BuildMarketTrends("CoinMarketCap", this.LastRuntimeSummary.MainMarket, new List(), "", true, this.GlobalMarketTrendChanges, this.PTMagicConfiguration, this.Log); - // Bittrex + // Exchange foreach (MarketTrend marketTrend in this.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.MarketTrends.FindAll(mt => mt.Platform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))) { if (this.SingleMarketTrendChanges.ContainsKey(marketTrend.Name)) diff --git a/Core/MarketAnalyzer/BaseAnalyzer.cs b/Core/MarketAnalyzer/BaseAnalyzer.cs index 411f5c9..9ef9931 100644 --- a/Core/MarketAnalyzer/BaseAnalyzer.cs +++ b/Core/MarketAnalyzer/BaseAnalyzer.cs @@ -429,7 +429,29 @@ namespace Core.MarketAnalyzer if (marketTrendChanges != null && marketTrendChanges.Count > 0) { - double averageTrendChange = marketTrendChanges.Average(mtc => mtc.TrendChange); + + double totalTrendChange = 0; + + foreach (MarketTrendChange marketTrendChange in marketTrendChanges) + { + if (marketTrend.IgnoreOutlier != 0) + { + if ((marketTrendChange.TrendChange > marketTrend.IgnoreOutlier) || (marketTrendChange.TrendChange < (marketTrend.IgnoreOutlier * -1))) + { + log.DoLogWarn("Market trend '" + marketTrend.Name + "' is ignoring the outlier '" + marketTrendChange.Market + "."); + } + else + { + totalTrendChange += marketTrendChange.TrendChange; + } + } + else + { + totalTrendChange += marketTrendChange.TrendChange; + } + } + + double averageTrendChange = totalTrendChange / marketTrendChanges.Count; result.Add(marketTrend.Name, averageTrendChange); diff --git a/Monitor/Pages/SettingsAnalyzer.cshtml.cs b/Monitor/Pages/SettingsAnalyzer.cshtml.cs index a6b1a4b..86a09b4 100644 --- a/Monitor/Pages/SettingsAnalyzer.cshtml.cs +++ b/Monitor/Pages/SettingsAnalyzer.cshtml.cs @@ -77,6 +77,7 @@ namespace Monitor.Pages mt.TrendCurrency = HttpContext.Request.Form[mtFormKey + "TrendCurrency"]; mt.IgnoredMarkets = HttpContext.Request.Form[mtFormKey + "IgnoredMarkets"]; mt.AllowedMarkets = HttpContext.Request.Form[mtFormKey + "AllowedMarkets"]; + mt.IgnoreOutlier = SystemHelper.TextToInteger(HttpContext.Request.Form[mtFormKey + "IgnoreOutlier"], mt.IgnoreOutlier); mt.DisplayGraph = HttpContext.Request.Form[mtFormKey + "DisplayGraph"].Equals("on"); mt.ExcludeMainCurrency = HttpContext.Request.Form[mtFormKey + "ExcludeMainCurrency"].Equals("on");