diff --git a/.gitignore b/.gitignore index 145c44c..1b5c1db 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,11 @@ _[Ll]ogfiles _[Ll]og _[Ll]ogs _[Dd]ata +_[Rr]eleases _backups LocalProfitTrailer PTMagic/settings.*.json Monitor/appsettings.json -/.vscode/tasks.json @@ -19,6 +19,7 @@ Monitor/appsettings.json .vscode/* !.vscode/settings.json !.vscode/launch.json +!.vscode/tasks.json !.vscode/extensions.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..4039d3e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,109 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "VS build PTMagic", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "PTMagic" + ], + "group": { + "kind":"build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "focus": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "VS build Monitor", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "Monitor" + ], + "presentation": { + "reveal": "always", + "focus": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "VS run PTMagic", + "command": "dotnet", + "type": "process", + "args": [ + "run", + "-p", + "PTMagic" + ], + "dependsOn": [ + "VS build PTMagic" + ], + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "VS run Monitor", + "command": "dotnet", + "type": "process", + "args": [ + "run", + "-p", + "Monitor" + ], + "dependsOn": [ + "VS build Monitor" + ], + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "VS publish PTMagic", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "PTMagic", + "-c", + "Release", + "-o", + "${workspaceFolder}/PTMagic/bin/Release/PublishOutput" + ], + "presentation": { + "reveal": "always", + "panel": "new", + "focus": true + }, + "problemMatcher": "$msCompile" + }, + { + "label": "VS publish Monitor", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "Monitor", + "-c", + "Release", + "-o", + "${workspaceFolder}/PTMagic/bin/Release/PublishOutput/Monitor" + ], + "presentation": { + "reveal": "always", + "panel": "new", + "focus": true + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 73e4f35..61f6495 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -1090,7 +1090,7 @@ namespace Core.Main { // Setting not set => Change setting this.Log.DoLogInfo("Switching global settings to '" + triggeredSetting.SettingName + "'..."); - SettingsHandler.CompileProperties(this.DefaultSettingName, triggeredSetting, this.PTMagicConfiguration, this.PairsLines, this.DCALines, this.IndicatorsLines, this.Log); + SettingsHandler.CompileProperties(this, triggeredSetting); this.GlobalSettingWritten = true; this.Log.DoLogInfo("Setting '" + triggeredSetting.SettingName + "' now active!"); diff --git a/Core/ProfitTrailer/SettingsHandler.cs b/Core/ProfitTrailer/SettingsHandler.cs index b6cea1e..d97486b 100644 --- a/Core/ProfitTrailer/SettingsHandler.cs +++ b/Core/ProfitTrailer/SettingsHandler.cs @@ -79,6 +79,8 @@ namespace Core.ProfitTrailer { fileLines.Insert(0, "# PTMagic_ActiveSetting = " + SystemHelper.StripBadCode(ptmagicInstance.DefaultSettingName, Constants.WhiteListProperties)); fileLines.Insert(0, "# ####### PTMagic Current Setting ########"); fileLines.Insert(0, "# ####################################"); + + ptmagicInstance.GetType().GetProperty(fileType + "Lines").SetValue(ptmagicInstance, fileLines); } public static Dictionary GetPropertiesAsDictionary(List propertyLines) { @@ -112,26 +114,29 @@ namespace Core.ProfitTrailer { return result; } - public static void CompileProperties(string defaultSettingName, GlobalSetting setting, PTMagicConfiguration systemConfiguration, List pairsLines, List dcaLines, List indicatorsLines, LogHelper log) { - SettingsHandler.BuildPropertyLines(ref pairsLines, defaultSettingName, setting, setting.PairsProperties, "pairs", systemConfiguration, log); - SettingsHandler.BuildPropertyLines(ref dcaLines, defaultSettingName, setting, setting.DCAProperties, "dca", systemConfiguration, log); - SettingsHandler.BuildPropertyLines(ref indicatorsLines, defaultSettingName, setting, setting.IndicatorsProperties, "indicators", systemConfiguration, log); + public static void CompileProperties(PTMagic ptmagicInstance, GlobalSetting setting) { + SettingsHandler.BuildPropertyLines("Pairs", ptmagicInstance, setting); + SettingsHandler.BuildPropertyLines("DCA", ptmagicInstance, setting); + SettingsHandler.BuildPropertyLines("Indicators", ptmagicInstance, setting); } - public static void BuildPropertyLines(ref List lines, string defaultSettingName, GlobalSetting setting, Dictionary properties, string propertiesType, PTMagicConfiguration systemConfiguration, LogHelper log) { + public static void BuildPropertyLines(string fileType, PTMagic ptmagicInstance, GlobalSetting setting) { List result = new List(); + List fileLines = (List)ptmagicInstance.GetType().GetProperty(fileType + "Lines").GetValue(ptmagicInstance, null); + + Dictionary properties = (Dictionary)setting.GetType().GetProperty(fileType + "Properties").GetValue(setting, null); if (properties != null) { // Building Properties - if (!setting.SettingName.Equals(defaultSettingName, StringComparison.InvariantCultureIgnoreCase) && systemConfiguration.GeneralSettings.Application.AlwaysLoadDefaultBeforeSwitch && !properties.ContainsKey("File")) { + if (!setting.SettingName.Equals(ptmagicInstance.DefaultSettingName, StringComparison.InvariantCultureIgnoreCase) && ptmagicInstance.PTMagicConfiguration.GeneralSettings.Application.AlwaysLoadDefaultBeforeSwitch && !properties.ContainsKey("File")) { // Load default settings as basis for the switch - GlobalSetting defaultSetting = systemConfiguration.AnalyzerSettings.GlobalSettings.Find(a => a.SettingName.Equals(defaultSettingName, StringComparison.InvariantCultureIgnoreCase)); + GlobalSetting defaultSetting = ptmagicInstance.PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Find(a => a.SettingName.Equals(ptmagicInstance.DefaultSettingName, StringComparison.InvariantCultureIgnoreCase)); if (defaultSetting != null) { Dictionary defaultProperties = new Dictionary(); - switch (propertiesType) { + switch (fileType.ToLower()) { case "pairs": defaultProperties = defaultSetting.PairsProperties; break; @@ -144,18 +149,18 @@ namespace Core.ProfitTrailer { } if (defaultProperties.ContainsKey("File")) { - lines = SettingsFiles.GetPresetFileLinesAsList(defaultSetting.SettingName, defaultProperties["File"].ToString(), systemConfiguration); + fileLines = SettingsFiles.GetPresetFileLinesAsList(defaultSetting.SettingName, defaultProperties["File"].ToString(), ptmagicInstance.PTMagicConfiguration); } } } else { // Check if settings are configured in a seperate file if (properties.ContainsKey("File")) { - lines = SettingsFiles.GetPresetFileLinesAsList(setting.SettingName, properties["File"].ToString(), systemConfiguration); + fileLines = SettingsFiles.GetPresetFileLinesAsList(setting.SettingName, properties["File"].ToString(), ptmagicInstance.PTMagicConfiguration); } } - foreach (string line in lines) { + foreach (string line in fileLines) { if (line.IndexOf("PTMagic_ActiveSetting", StringComparison.InvariantCultureIgnoreCase) > -1) { // Setting current active setting @@ -184,7 +189,7 @@ namespace Core.ProfitTrailer { } } - lines = result; + ptmagicInstance.GetType().GetProperty(fileType + "Lines").SetValue(ptmagicInstance, result); } public static List BuildPropertyLine(List result, string settingName, string line, Dictionary properties, string settingProperty) { diff --git a/PTMagic/_presets/Default/PAIRS.PROPERTIES b/PTMagic/_presets/Default/PAIRS.PROPERTIES index a1bc411..e24c05d 100644 --- a/PTMagic/_presets/Default/PAIRS.PROPERTIES +++ b/PTMagic/_presets/Default/PAIRS.PROPERTIES @@ -1,3 +1,9 @@ +# #################################### +# ####### PTMagic Current Setting ######## +# PTMagic_ActiveSetting = Default +# PTMagic_LastChanged = 23.05.2018 07:27 +# #################################### + # market = USDT diff --git a/_Development/_Releases/PTMagic 2.0.0.zip b/_Development/_Releases/PTMagic 2.0.0.zip deleted file mode 100644 index 6b6b738..0000000 Binary files a/_Development/_Releases/PTMagic 2.0.0.zip and /dev/null differ diff --git a/_Development/_Releases/Raspberry PI PTMagic 2.0.0.zip b/_Development/_Releases/Raspberry PI PTMagic 2.0.0.zip deleted file mode 100644 index 6179d58..0000000 Binary files a/_Development/_Releases/Raspberry PI PTMagic 2.0.0.zip and /dev/null differ