From 0f2cb35fc781f8e64d24dd74ebe590695613b418 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Wed, 19 Aug 2020 19:10:49 +0100 Subject: [PATCH 1/5] Fixed issue settings not refreshing until restart --- Core/Main/PTMagicConfiguration.cs | 28 +++++++++++++++--------- Monitor/Pages/SettingsAnalyzer.cshtml.cs | 3 ++- Monitor/Pages/SettingsGeneral.cshtml.cs | 8 +++++-- Monitor/Pages/SetupPassword.cshtml.cs | 2 +- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Core/Main/PTMagicConfiguration.cs b/Core/Main/PTMagicConfiguration.cs index 2d9c3dd..7d29d14 100644 --- a/Core/Main/PTMagicConfiguration.cs +++ b/Core/Main/PTMagicConfiguration.cs @@ -15,15 +15,23 @@ namespace Core.Main private GeneralSettings _generalSettings = null; private AnalyzerSettings _analyzerSettings = null; private SecureSettings _secureSettings = null; + private string _basePath; public PTMagicConfiguration() { - LoadSettings(Directory.GetCurrentDirectory()); + _basePath = Directory.GetCurrentDirectory(); + LoadSettings(_basePath); } public PTMagicConfiguration(string basePath) { - LoadSettings(basePath); + _basePath = basePath; + LoadSettings(_basePath); + } + + public void RefreshSettings() + { + LoadSettings(_basePath); } private void LoadSettings(string basePath) @@ -100,17 +108,17 @@ namespace Core.Main } } - public void WriteGeneralSettings(string basePath) + public void WriteGeneralSettings() { GeneralSettingsWrapper gsWrapper = new GeneralSettingsWrapper(); gsWrapper.GeneralSettings = this.GeneralSettings; - FileHelper.CreateBackup(basePath + "settings.general.json", basePath, "settings.general.json.backup"); + FileHelper.CreateBackup(_basePath + "settings.general.json", _basePath, "settings.general.json.backup"); - FileHelper.WriteTextToFile(basePath, "settings.general.json", JsonConvert.SerializeObject(gsWrapper, Formatting.Indented)); + FileHelper.WriteTextToFile(_basePath, "settings.general.json", JsonConvert.SerializeObject(gsWrapper, Formatting.Indented)); } - public void WriteAnalyzerSettings(string basePath) + public void WriteAnalyzerSettings() { AnalyzerSettingsWrapper asWrapper = new AnalyzerSettingsWrapper(); asWrapper.AnalyzerSettings = this.AnalyzerSettings; @@ -119,12 +127,12 @@ namespace Core.Main settings.NullValueHandling = NullValueHandling.Ignore; settings.DefaultValueHandling = DefaultValueHandling.Ignore; - FileHelper.CreateBackup(basePath + "settings.analyzer.json", basePath, "settings.analyzer.json.backup"); + FileHelper.CreateBackup(_basePath + "settings.analyzer.json", _basePath, "settings.analyzer.json.backup"); - FileHelper.WriteTextToFile(basePath, "settings.analyzer.json", JsonConvert.SerializeObject(asWrapper, Formatting.Indented, settings)); + FileHelper.WriteTextToFile(_basePath, "settings.analyzer.json", JsonConvert.SerializeObject(asWrapper, Formatting.Indented, settings)); } - public void WriteSecureSettings(string password, string basePath) + public void WriteSecureSettings(string password) { string passwordEncrypted = EncryptionHelper.Encrypt(password); @@ -133,7 +141,7 @@ namespace Core.Main SecureSettingsWrapper ssWrapper = new SecureSettingsWrapper(); ssWrapper.SecureSettings = this.SecureSettings; - FileHelper.WriteTextToFile(basePath, "settings.secure.json", JsonConvert.SerializeObject(ssWrapper, Formatting.Indented)); + FileHelper.WriteTextToFile(_basePath, "settings.secure.json", JsonConvert.SerializeObject(ssWrapper, Formatting.Indented)); } } } diff --git a/Monitor/Pages/SettingsAnalyzer.cshtml.cs b/Monitor/Pages/SettingsAnalyzer.cshtml.cs index 64bd74a..a6b1a4b 100644 --- a/Monitor/Pages/SettingsAnalyzer.cshtml.cs +++ b/Monitor/Pages/SettingsAnalyzer.cshtml.cs @@ -42,7 +42,8 @@ namespace Monitor.Pages SaveGlobalSettings(formKeys); SaveSingleMarketSettings(formKeys); - PTMagicConfiguration.WriteAnalyzerSettings(PTMagicBasePath); + PTMagicConfiguration.WriteAnalyzerSettings(); + PTMagicConfiguration.RefreshSettings(); NotifyHeadline = "Settings saved!"; NotifyMessage = "Settings saved successfully to settings.analyzer.json."; diff --git a/Monitor/Pages/SettingsGeneral.cshtml.cs b/Monitor/Pages/SettingsGeneral.cshtml.cs index ff1df72..7cf9d5c 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml.cs +++ b/Monitor/Pages/SettingsGeneral.cshtml.cs @@ -65,6 +65,7 @@ namespace Monitor.Pages { base.Init(); + // Read the new settings PTMagicConfiguration.GeneralSettings.Application.IsEnabled = HttpContext.Request.Form["Application_IsEnabled"].Equals("on"); PTMagicConfiguration.GeneralSettings.Application.TestMode = HttpContext.Request.Form["Application_TestMode"].Equals("on"); PTMagicConfiguration.GeneralSettings.Application.StartBalance = SystemHelper.TextToDouble(HttpContext.Request.Form["Application_StartBalance"], PTMagicConfiguration.GeneralSettings.Application.StartBalance, "en-US"); @@ -79,7 +80,7 @@ namespace Monitor.Pages PTMagicConfiguration.GeneralSettings.Application.InstanceName = HttpContext.Request.Form["Application_InstanceName"]; PTMagicConfiguration.GeneralSettings.Application.CoinMarketCapAPIKey = HttpContext.Request.Form["Application_CoinMarketCapAPIKey"]; PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey = HttpContext.Request.Form["Application_FreeCurrencyConverterAPIKey"]; - // + PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected = HttpContext.Request.Form["Monitor_IsPasswordProtected"].Equals("on"); PTMagicConfiguration.GeneralSettings.Monitor.OpenBrowserOnStart = HttpContext.Request.Form["Monitor_OpenBrowserOnStart"].Equals("on"); PTMagicConfiguration.GeneralSettings.Monitor.DefaultDCAMode = HttpContext.Request.Form["Monitor_AnalyzerChart"]; @@ -105,8 +106,11 @@ namespace Monitor.Pages PTMagicConfiguration.GeneralSettings.Telegram.ChatId = SystemHelper.TextToInteger64(HttpContext.Request.Form["Telegram_ChatId"], PTMagicConfiguration.GeneralSettings.Telegram.ChatId); PTMagicConfiguration.GeneralSettings.Telegram.SilentMode = HttpContext.Request.Form["Telegram_SilentMode"].Equals("on"); - PTMagicConfiguration.WriteGeneralSettings(PTMagicBasePath); + // Save and reload the settings + PTMagicConfiguration.WriteGeneralSettings(); + PTMagicConfiguration.RefreshSettings(); + // Notify NotifyHeadline = "Settings saved!"; NotifyMessage = "Settings saved successfully to settings.general.json."; NotifyType = "success"; diff --git a/Monitor/Pages/SetupPassword.cshtml.cs b/Monitor/Pages/SetupPassword.cshtml.cs index 0a0910c..eb53c5f 100644 --- a/Monitor/Pages/SetupPassword.cshtml.cs +++ b/Monitor/Pages/SetupPassword.cshtml.cs @@ -26,7 +26,7 @@ namespace Monitor.Pages if (ModelState.IsValid) { base.PreInit(); - PTMagicConfiguration.WriteSecureSettings(password, PTMagicBasePath); + PTMagicConfiguration.WriteSecureSettings(password); Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login"); } From 4ba1725d6a10f55f2619ebd79bc19510af92e7ca Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Thu, 20 Aug 2020 07:16:48 +0100 Subject: [PATCH 2/5] Fixed issue where trend data got stuck --- Core/MarketAnalyzer/BaseAnalyzer.cs | 87 ++++++++++++++--------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/Core/MarketAnalyzer/BaseAnalyzer.cs b/Core/MarketAnalyzer/BaseAnalyzer.cs index 2865926..1c16fd5 100644 --- a/Core/MarketAnalyzer/BaseAnalyzer.cs +++ b/Core/MarketAnalyzer/BaseAnalyzer.cs @@ -138,7 +138,7 @@ namespace Core.MarketAnalyzer string baseUrl = "https://api.github.com/repos/PTMagicians/PTMagic/releases/latest"; Newtonsoft.Json.Linq.JObject jsonObject = GetSimpleJsonObjectFromURL(baseUrl, log, new (string header, string value)[] { ("User-Agent", "PTMagic.Import") }); - + if (jsonObject != null) { result = jsonObject.GetValue("tag_name").ToString(); @@ -337,55 +337,52 @@ namespace Core.MarketAnalyzer Market recentMarket = recentMarkets[recentMarketPair.Key]; - if (trendMarkets.ContainsKey(recentMarketPair.Key)) + List ignoredMarkets = SystemHelper.ConvertTokenStringToList(marketTrend.IgnoredMarkets, ","); + if (ignoredMarkets.Contains(recentMarketPair.Value.Symbol)) { - 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; + } + + Market trendMarket = trendMarkets[recentMarketPair.Key]; + + if (trendMarket != null) + { + double recentMarketPrice = recentMarket.Price; + double trendMarketPrice = trendMarket.Price; + + if (!platform.Equals("CoinMarketCap", StringComparison.InvariantCulture) && marketTrend.TrendCurrency.Equals("Fiat", StringComparison.InvariantCultureIgnoreCase)) { - 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; - } - - Market trendMarket = trendMarkets[recentMarketPair.Key]; - - if (trendMarket != null) - { - double recentMarketPrice = recentMarket.Price; - double trendMarketPrice = trendMarket.Price; - - if (!platform.Equals("CoinMarketCap", StringComparison.InvariantCulture) && marketTrend.TrendCurrency.Equals("Fiat", StringComparison.InvariantCultureIgnoreCase)) + if (recentMarket.MainCurrencyPriceUSD > 0 && trendMarket.MainCurrencyPriceUSD > 0) { - if (recentMarket.MainCurrencyPriceUSD > 0 && trendMarket.MainCurrencyPriceUSD > 0) - { - recentMarketPrice = recentMarketPrice * recentMarket.MainCurrencyPriceUSD; - trendMarketPrice = trendMarketPrice * trendMarket.MainCurrencyPriceUSD; - } + recentMarketPrice = recentMarketPrice * recentMarket.MainCurrencyPriceUSD; + trendMarketPrice = trendMarketPrice * trendMarket.MainCurrencyPriceUSD; } - - double trendMarketChange = (recentMarketPrice - trendMarketPrice) / trendMarketPrice * 100; - - MarketTrendChange mtc = new MarketTrendChange(); - mtc.MarketTrendName = marketTrend.Name; - mtc.TrendMinutes = marketTrend.TrendMinutes; - mtc.TrendChange = trendMarketChange; - mtc.Market = recentMarket.Name; - mtc.LastPrice = recentMarket.Price; - mtc.Volume24h = recentMarket.Volume24h; - mtc.TrendDateTime = DateTime.UtcNow; - - result.Add(mtc); - - log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' (Vol. " + recentMarket.Volume24h.ToString("#,#0.00") + ") is " + trendMarketChange.ToString("#,#0.00") + "% in " + SystemHelper.GetProperDurationTime(marketTrend.TrendMinutes * 60).ToLower() + "."); - - marketCount++; } + + double trendMarketChange = (recentMarketPrice - trendMarketPrice) / trendMarketPrice * 100; + + MarketTrendChange mtc = new MarketTrendChange(); + mtc.MarketTrendName = marketTrend.Name; + mtc.TrendMinutes = marketTrend.TrendMinutes; + mtc.TrendChange = trendMarketChange; + mtc.Market = recentMarket.Name; + mtc.LastPrice = recentMarket.Price; + mtc.Volume24h = recentMarket.Volume24h; + mtc.TrendDateTime = DateTime.UtcNow; + + result.Add(mtc); + + log.DoLogDebug(platform + " - Market trend '" + marketTrend.Name + "' for '" + recentMarketPair.Key + "' (Vol. " + recentMarket.Volume24h.ToString("#,#0.00") + ") is " + trendMarketChange.ToString("#,#0.00") + "% in " + SystemHelper.GetProperDurationTime(marketTrend.TrendMinutes * 60).ToLower() + "."); + + marketCount++; } } } From 42c2210c16b7d5efd504681eaee8428814a3c667 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:39:26 +0900 Subject: [PATCH 3/5] Manage SMS changes --- Monitor/Pages/ManageSMS.cshtml | 295 ++++++++++++++++-------------- Monitor/Pages/ManageSMS.cshtml.cs | 15 ++ PTMagic/Program.cs | 2 +- 3 files changed, 173 insertions(+), 139 deletions(-) diff --git a/Monitor/Pages/ManageSMS.cshtml b/Monitor/Pages/ManageSMS.cshtml index 9daf170..d9200d3 100644 --- a/Monitor/Pages/ManageSMS.cshtml +++ b/Monitor/Pages/ManageSMS.cshtml @@ -11,157 +11,176 @@
- -

Applied Single Market Setting Details

- +

Applied Single Market Settings

+ +


+ + @{ + Model.CreateSmsList(); + foreach (string sms in Model.smsList) + { + int smsCount = 0; + foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries) + { + if (smsSummary.SingleMarketSetting.SettingName == sms) + { + smsCount = smsCount + 1; + } + } + @sms: @smsCount     + } + } + +

+ +
- - - - - - + + + + + + - - @{ - string lastMarket = ""; - } - @foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries.OrderBy(s => s.Market)) { - Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; - if (Model.Summary.MarketSummary.ContainsKey(smsSummary.Market)) { - mps = Model.Summary.MarketSummary[smsSummary.Market]; - } else { - mps = new Core.Main.DataObjects.PTMagicData.MarketPairSummary(); - } + + @{ + string lastMarket = ""; + } + @foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries.OrderBy(s => s.Market)) { + Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; + if (Model.Summary.MarketSummary.ContainsKey(smsSummary.Market)) { + mps = Model.Summary.MarketSummary[smsSummary.Market]; + } else { + mps = new Core.Main.DataObjects.PTMagicData.MarketPairSummary(); + } - bool settingHasOffTriggers = false; - if (smsSummary.SingleMarketSetting.OffTriggers.Count > 0) { - settingHasOffTriggers = true; - } + bool settingHasOffTriggers = false; + if (smsSummary.SingleMarketSetting.OffTriggers.Count > 0) { + settingHasOffTriggers = true; + } - int activeSeconds = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalSeconds); - int activeHours = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalHours); - - + + + + + + - - - - - + - - - lastMarket = smsSummary.Market; - } - -
Market NameLast PriceVolumeActive SettingTriggered timeOff TriggersCurrent ValuesVolumeLast PriceActive Setting Triggered timeOff TriggersCurrent Value
- @if (!lastMarket.Equals(smsSummary.Market)) { - @smsSummary.Market + int activeSeconds = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalSeconds); + int activeHours = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalHours); +
+ @if (!lastMarket.Equals(smsSummary.Market)) { + @smsSummary.Market + } + + @if (!lastMarket.Equals(smsSummary.Market)) { + @Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket + } + + @if (!lastMarket.Equals(smsSummary.Market)) { + @mps.LatestPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket + } + + @Core.Helper.SystemHelper.SplitCamelCase(smsSummary.SingleMarketSetting.SettingName) + + @Core.Helper.SystemHelper.GetProperDurationTime(activeSeconds) + + @if (settingHasOffTriggers) { + foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { + string triggerTextClass = "text-danger"; + if (ot.HoursSinceTriggered > 0) { + triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; +

Hours Since Triggered@ot.HoursSinceTriggered

} - -
- @if (!lastMarket.Equals(smsSummary.Market)) { - @mps.LatestPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket - } - - @if (!lastMarket.Equals(smsSummary.Market)) { - @Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket - } - - @Core.Helper.SystemHelper.SplitCamelCase(smsSummary.SingleMarketSetting.SettingName) - - @Core.Helper.SystemHelper.GetProperDurationTime(activeSeconds) - - @if (settingHasOffTriggers) { - foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { - string triggerTextClass = "text-danger"; - if (ot.HoursSinceTriggered > 0) { - triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; -

Hours Since Triggered@ot.HoursSinceTriggered

- } - if (ot.Min24hVolume > 0 || ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume && mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

- Volume - - @if (ot.Min24hVolume > 0) { - @("min: " + ot.Min24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) - } - @if (ot.Min24hVolume > 0 && ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - @(", ") - } - @if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - @("max: " + ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) - } - -

- } - if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

Max 24h Volume@ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (!ot.MarketTrendName.Equals("")) { - double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); - triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; -

- @Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendName) (@Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendRelation)) - - @if (ot.MinChange > Core.Main.Constants.MinTrendChange) { - @("min: " + ot.MinChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") - } - @if (ot.MinChange > Core.Main.Constants.MinTrendChange && ot.MaxChange < Core.Main.Constants.MaxTrendChange) { - @(", ") - } - @if (ot.MaxChange < Core.Main.Constants.MaxTrendChange) { - @("max: " + ot.MaxChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") - } - -

- } - } - } else { - Not specified - } -
- @if (settingHasOffTriggers) { - foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { - string triggerTextClass = "text-danger"; - if (ot.HoursSinceTriggered > 0) { - triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; -

@activeHours.ToString(new System.Globalization.CultureInfo("en-US"))

- } - if (ot.Min24hVolume > 0) { - triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume) ? "text-success" : "text-danger"; -

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (!ot.MarketTrendName.Equals("")) { - if (mps.MarketTrendChanges.ContainsKey(ot.MarketTrendName)) { - double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); - triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; - string trendChangeOutput = trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); -

@trendChangeOutput%

+ if (ot.Min24hVolume > 0 || ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume && mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

+ Volume + + @if (ot.Min24hVolume > 0) { + @("min: " + ot.Min24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) } - } + @if (ot.Min24hVolume > 0 && ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + @(", ") + } + @if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + @("max: " + ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) + } + +

+ } + if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

Max 24h Volume@ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (!ot.MarketTrendName.Equals("")) { + double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); + triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; +

+ @Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendName) (@Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendRelation)) + + @if (ot.MinChange > Core.Main.Constants.MinTrendChange) { + @("min: " + ot.MinChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") + } + @if (ot.MinChange > Core.Main.Constants.MinTrendChange && ot.MaxChange < Core.Main.Constants.MaxTrendChange) { + @(", ") + } + @if (ot.MaxChange < Core.Main.Constants.MaxTrendChange) { + @("max: " + ot.MaxChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") + } + +

+ } + } + } else { + Not specified + } +
+ @if (settingHasOffTriggers) { + foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { + string triggerTextClass = "text-danger"; + if (ot.HoursSinceTriggered > 0) { + triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; +

@activeHours.ToString(new System.Globalization.CultureInfo("en-US"))

+ } + if (ot.Min24hVolume > 0) { + triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume) ? "text-success" : "text-danger"; +

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (!ot.MarketTrendName.Equals("")) { + if (mps.MarketTrendChanges.ContainsKey(ot.MarketTrendName)) { + double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); + triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; + string trendChangeOutput = trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); +

@trendChangeOutput%

} } -
- @if (settingHasOffTriggers) { - @if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) { - Reset - } else { - Reset - } - } -
- + } + } + + + @if (settingHasOffTriggers) { + @if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) { + Reset + } else { + Reset + } + } + + + lastMarket = smsSummary.Market; + } + +
diff --git a/Monitor/Pages/ManageSMS.cshtml.cs b/Monitor/Pages/ManageSMS.cshtml.cs index f18a520..2153e5b 100644 --- a/Monitor/Pages/ManageSMS.cshtml.cs +++ b/Monitor/Pages/ManageSMS.cshtml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -20,6 +21,20 @@ namespace Monitor.Pages BindData(); } + public List smsList = new List(); + + public void CreateSmsList () + { + + foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in SingleMarketSettingSummaries) + { + if (!smsList.Contains(smsSummary.SingleMarketSetting.SettingName)) + { + smsList.Add(smsSummary.SingleMarketSetting.SettingName); + } + } + } + private void BindData() { if (System.IO.File.Exists(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "SingleMarketSettingSummary.json")) diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index cb5a388..3eb1a30 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -6,7 +6,7 @@ using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.4.5")] +[assembly: AssemblyVersion("2.4.6")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic From fbf133af3cf8196a23f324fdfeb28097a47668ea Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Thu, 17 Sep 2020 13:03:16 +0900 Subject: [PATCH 4/5] Ticker & footer changes --- Monitor/Pages/_Layout.cshtml | 6 +++--- Monitor/Pages/_get/TickerWidgets.cshtml | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Monitor/Pages/_Layout.cshtml b/Monitor/Pages/_Layout.cshtml index 3108b41..ccc4465 100644 --- a/Monitor/Pages/_Layout.cshtml +++ b/Monitor/Pages/_Layout.cshtml @@ -139,11 +139,11 @@
-
+ @Model.PTMagicConfiguration.GeneralSettings.Application.InstanceName +     GitHub - | +   |   Wiki -
diff --git a/Monitor/Pages/_get/TickerWidgets.cshtml b/Monitor/Pages/_get/TickerWidgets.cshtml index 1d31c99..e7fbae8 100644 --- a/Monitor/Pages/_get/TickerWidgets.cshtml +++ b/Monitor/Pages/_get/TickerWidgets.cshtml @@ -8,6 +8,7 @@ if (activeSingleSettings > 0) { singleSettingInfoIcon = "Single Market Settings active for:
-" + Core.Helper.SystemHelper.ConvertListToTokenString(Model.MarketsWithSingleSettings, "
-", true) + "\" data-template=\"\">
"; } + string globalSettingInfoIcon = "Instance: " + Model.PTMagicConfiguration.GeneralSettings.Application.InstanceName + "\" data-template=\"\">"; DateTime lastRuntime = Model.Summary.LastRuntime; double elapsedSecondsSinceRuntime = DateTime.UtcNow.Subtract(lastRuntime).TotalSeconds; @@ -23,12 +24,13 @@ } } -
- @Core.Helper.SystemHelper.SplitCamelCase(Model.Summary.CurrentGlobalSetting.SettingName) +
+ + @Core.Helper.SystemHelper.SplitCamelCase(Model.Summary.CurrentGlobalSetting.SettingName)@Html.Raw(" " + globalSettingInfoIcon)
-
- SMS: @Html.Raw(singleSettingInfoIcon) @activeSingleSettings +
From cb578b1449c4dcc961ffda681f993042159b1a33 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Sun, 8 Nov 2020 12:45:31 +0000 Subject: [PATCH 5/5] Fixed KeyNotFoundException when building trends --- Core/MarketAnalyzer/BaseAnalyzer.cs | 43 +++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) 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; + } } }