From 67bbfb7580b2d81e85072a2733f010ff04003777 Mon Sep 17 00:00:00 2001 From: djbadders <34887832+djbadders@users.noreply.github.com> Date: Tue, 12 Mar 2019 21:22:48 +0000 Subject: [PATCH] Fixed Flood Protection logic + house keeping --- Core/Main/PTMagic.cs | 5 +---- Core/ProfitTrailer/SettingsHandler.cs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 43a6be9..9c88b8a 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -738,9 +738,7 @@ namespace Core.Main { this.Log.DoLogError("PTM failed to read the Config File. That means something in the File is either missing or incorrect. If this happend after an update please take a look at the release notes at: https://github.com/PTMagicians/PTMagic/releases"); } - } - else { this.Log.DoLogWarn("PTMagic disabled, shutting down..."); @@ -1388,7 +1386,7 @@ namespace Core.Main } // Check if flood protection is active - if (this.EnforceSettingsReapply || !this.LastSetting.Equals(triggeredSetting.SettingName, StringComparison.InvariantCultureIgnoreCase) || this.LastSettingsChange <= DateTime.UtcNow.AddMinutes(-PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes)) + if (this.EnforceSettingsReapply || this.LastSettingsChange <= DateTime.UtcNow.AddMinutes(-PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes)) { // Setting not set => Change setting if (!EnforceSettingsReapply) @@ -2257,7 +2255,6 @@ namespace Core.Main } // Get configured DCA percentages - string dcaDefaultPercentageString = SettingsHandler.GetCurrentPropertyValue(dcaProperties, "DEFAULT_DCA_buy_percentage", ""); double dcaDefaultPercentage = SystemHelper.TextToDouble(dcaDefaultPercentageString, 0, "en-US"); diff --git a/Core/ProfitTrailer/SettingsHandler.cs b/Core/ProfitTrailer/SettingsHandler.cs index 90e883f..39a5d1c 100644 --- a/Core/ProfitTrailer/SettingsHandler.cs +++ b/Core/ProfitTrailer/SettingsHandler.cs @@ -391,16 +391,17 @@ namespace Core.ProfitTrailer List newDCALines = new List(); List newIndicatorsLines = new List(); + // Find the previous single market settings section in the pairs file foreach (string pairsLine in ptmagicInstance.PairsLines) { if (pairsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) { - // Single Market Settings will get overwritten every single run => crop the lines break; } else { + // Copy the line into the new pairs file and keep searching string globalPairsLine = pairsLine; globalPairsLines.Add(globalPairsLine); @@ -412,16 +413,17 @@ namespace Core.ProfitTrailer newPairsLines.Add("# ########################################################################"); newPairsLines.Add("#"); + // Find the previous single market settings section in the DCA file foreach (string dcaLine in ptmagicInstance.DCALines) { if (dcaLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) { - // Single Market Settings will get overwritten every single run => crop the lines break; } else { + // Copy the line into the new pairs file and keep searching string globalDCALine = dcaLine; globalDCALines.Add(globalDCALine); @@ -433,16 +435,17 @@ namespace Core.ProfitTrailer newDCALines.Add("# ########################################################################"); newDCALines.Add("#"); + // Find the previous single market settings section in the Indicators file foreach (string indicatorsLine in ptmagicInstance.IndicatorsLines) { if (indicatorsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) { - // Single Market Settings will get overwritten every single run => crop the lines break; } else { + // Copy the line into the new pairs file and keep searching string globalIndicatorsLine = indicatorsLine; globalIndicatorsLines.Add(globalIndicatorsLine); @@ -536,7 +539,11 @@ namespace Core.ProfitTrailer string appliedSettingsStringList = ""; foreach (SingleMarketSetting sms in appliedSettings) { - if (!appliedSettingsStringList.Equals("")) appliedSettingsStringList += ", "; + if (!appliedSettingsStringList.Equals("")) + { + appliedSettingsStringList += ", "; + } + appliedSettingsStringList += sms.SettingName; }