From c2bbc274b5e763c7c8689b195f7b79647d21d8c0 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Sun, 31 Jan 2021 01:32:36 +0900 Subject: [PATCH] Ignore Ouliers --- Core/DataObjects/PTMagicData.cs | 3 +++ Core/Main/PTMagic.cs | 2 +- Core/MarketAnalyzer/BaseAnalyzer.cs | 24 +++++++++++++++++++++++- Monitor/Pages/SettingsAnalyzer.cshtml.cs | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) 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");