From 1b6a05676b9a0bc9f30f5162800b29e57673ffd4 Mon Sep 17 00:00:00 2001 From: Legedric Date: Wed, 23 May 2018 06:23:10 +0200 Subject: [PATCH] First part of fixing issue that leads to global properties not getting written to PT --- Core/Main/PTMagic.cs | 2 +- Core/ProfitTrailer/SettingsHandler.cs | 28 ++++++++++++----------- PTMagic/Program.cs | 2 +- PTMagic/_presets/Default/PAIRS.PROPERTIES | 6 +---- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 173d0af..73e4f35 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -1067,7 +1067,7 @@ namespace Core.Main { } private void ActivateSetting(ref bool headerLinesAdded, ref GlobalSetting triggeredSetting, ref List matchedTriggers) { - string activeSettingName = SettingsHandler.GetActiveSetting(this.PTMagicConfiguration, this.DefaultSettingName, ref headerLinesAdded, this.PairsLines, this.DCALines, this.IndicatorsLines, this.Log); + string activeSettingName = SettingsHandler.GetActiveSetting(this, ref headerLinesAdded); if (activeSettingName.Equals("") && this.PTMagicConfiguration.GeneralSettings.Application.TestMode) { activeSettingName = this.ActiveSetting; } diff --git a/Core/ProfitTrailer/SettingsHandler.cs b/Core/ProfitTrailer/SettingsHandler.cs index 3d5e4ec..b6cea1e 100644 --- a/Core/ProfitTrailer/SettingsHandler.cs +++ b/Core/ProfitTrailer/SettingsHandler.cs @@ -46,10 +46,10 @@ namespace Core.ProfitTrailer { return result; } - public static string GetActiveSetting(PTMagicConfiguration systemConfiguration, string defaultSettingName, ref bool headerLinesAdded, List pairsLines, List dcaLines, List indicatorsLines, LogHelper log) { + public static string GetActiveSetting(PTMagic ptmagicInstance, ref bool headerLinesAdded) { string result = ""; - foreach (string line in pairsLines) { + foreach (string line in ptmagicInstance.PairsLines) { if (line.IndexOf("PTMagic_ActiveSetting", StringComparison.InvariantCultureIgnoreCase) > -1) { result = line.Replace("PTMagic_ActiveSetting", "", StringComparison.InvariantCultureIgnoreCase); result = result.Replace("#", ""); @@ -59,24 +59,26 @@ namespace Core.ProfitTrailer { } } - if (result.Equals("")) { - SettingsHandler.WriteHeaderLines(ref pairsLines, defaultSettingName, systemConfiguration); - SettingsHandler.WriteHeaderLines(ref dcaLines, defaultSettingName, systemConfiguration); - SettingsHandler.WriteHeaderLines(ref indicatorsLines, defaultSettingName, systemConfiguration); + if (result.Equals("Default")) { + SettingsHandler.WriteHeaderLines("Pairs", ptmagicInstance); + SettingsHandler.WriteHeaderLines("DCA", ptmagicInstance); + SettingsHandler.WriteHeaderLines("Indicators", ptmagicInstance); headerLinesAdded = true; } return result; } - public static void WriteHeaderLines(ref List lines, string settingName, PTMagicConfiguration systemConfiguration) { + public static void WriteHeaderLines(string fileType, PTMagic ptmagicInstance) { + List fileLines = (List)ptmagicInstance.GetType().GetProperty(fileType + "Lines").GetValue(ptmagicInstance, null); + // Writing Header lines - lines.Insert(0, ""); - lines.Insert(0, "# ####################################"); - lines.Insert(0, "# PTMagic_LastChanged = " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); - lines.Insert(0, "# PTMagic_ActiveSetting = " + SystemHelper.StripBadCode(settingName, Constants.WhiteListProperties)); - lines.Insert(0, "# ####### PTMagic Current Setting ########"); - lines.Insert(0, "# ####################################"); + fileLines.Insert(0, ""); + fileLines.Insert(0, "# ####################################"); + fileLines.Insert(0, "# PTMagic_LastChanged = " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString()); + fileLines.Insert(0, "# PTMagic_ActiveSetting = " + SystemHelper.StripBadCode(ptmagicInstance.DefaultSettingName, Constants.WhiteListProperties)); + fileLines.Insert(0, "# ####### PTMagic Current Setting ########"); + fileLines.Insert(0, "# ####################################"); } public static Dictionary GetPropertiesAsDictionary(List propertyLines) { diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index 8c623c3..47f624a 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -7,7 +7,7 @@ using Core.Helper; using Core.Main.DataObjects.PTMagicData; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.0.0")] +[assembly: AssemblyVersion("2.0.1")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic { diff --git a/PTMagic/_presets/Default/PAIRS.PROPERTIES b/PTMagic/_presets/Default/PAIRS.PROPERTIES index 65719fa..a1bc411 100644 --- a/PTMagic/_presets/Default/PAIRS.PROPERTIES +++ b/PTMagic/_presets/Default/PAIRS.PROPERTIES @@ -1,8 +1,4 @@ -# #################################### -# ####### PTMagic Current Setting ######## -# PTMagic_ActiveSetting = Default -# PTMagic_LastChanged = 3/26/2018 11:52 AM -# #################################### + # market = USDT #