Merge pull request #91 from djbadders/develop

Fixed Flood Protection logic + house keeping
This commit is contained in:
HojouFotytu 2019-03-13 17:31:55 +09:00 committed by GitHub
commit a411c648cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -741,9 +741,7 @@ namespace Core.Main
Console.ReadLine(); Console.ReadLine();
Environment.Exit(0); Environment.Exit(0);
} }
} }
else else
{ {
this.Log.DoLogWarn("PTMagic disabled, shutting down..."); this.Log.DoLogWarn("PTMagic disabled, shutting down...");
@ -1391,7 +1389,7 @@ namespace Core.Main
} }
// Check if flood protection is active // 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 // Setting not set => Change setting
if (!EnforceSettingsReapply) if (!EnforceSettingsReapply)
@ -2260,7 +2258,6 @@ namespace Core.Main
} }
// Get configured DCA percentages // Get configured DCA percentages
string dcaDefaultPercentageString = SettingsHandler.GetCurrentPropertyValue(dcaProperties, "DEFAULT_DCA_buy_percentage", ""); string dcaDefaultPercentageString = SettingsHandler.GetCurrentPropertyValue(dcaProperties, "DEFAULT_DCA_buy_percentage", "");
double dcaDefaultPercentage = SystemHelper.TextToDouble(dcaDefaultPercentageString, 0, "en-US"); double dcaDefaultPercentage = SystemHelper.TextToDouble(dcaDefaultPercentageString, 0, "en-US");

View File

@ -391,16 +391,17 @@ namespace Core.ProfitTrailer
List<string> newDCALines = new List<string>(); List<string> newDCALines = new List<string>();
List<string> newIndicatorsLines = new List<string>(); List<string> newIndicatorsLines = new List<string>();
// Find the previous single market settings section in the pairs file
foreach (string pairsLine in ptmagicInstance.PairsLines) foreach (string pairsLine in ptmagicInstance.PairsLines)
{ {
if (pairsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) if (pairsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1)
{ {
// Single Market Settings will get overwritten every single run => crop the lines // Single Market Settings will get overwritten every single run => crop the lines
break; break;
} }
else else
{ {
// Copy the line into the new pairs file and keep searching
string globalPairsLine = pairsLine; string globalPairsLine = pairsLine;
globalPairsLines.Add(globalPairsLine); globalPairsLines.Add(globalPairsLine);
@ -412,16 +413,17 @@ namespace Core.ProfitTrailer
newPairsLines.Add("# ########################################################################"); newPairsLines.Add("# ########################################################################");
newPairsLines.Add("#"); newPairsLines.Add("#");
// Find the previous single market settings section in the DCA file
foreach (string dcaLine in ptmagicInstance.DCALines) foreach (string dcaLine in ptmagicInstance.DCALines)
{ {
if (dcaLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) if (dcaLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1)
{ {
// Single Market Settings will get overwritten every single run => crop the lines // Single Market Settings will get overwritten every single run => crop the lines
break; break;
} }
else else
{ {
// Copy the line into the new pairs file and keep searching
string globalDCALine = dcaLine; string globalDCALine = dcaLine;
globalDCALines.Add(globalDCALine); globalDCALines.Add(globalDCALine);
@ -433,16 +435,17 @@ namespace Core.ProfitTrailer
newDCALines.Add("# ########################################################################"); newDCALines.Add("# ########################################################################");
newDCALines.Add("#"); newDCALines.Add("#");
// Find the previous single market settings section in the Indicators file
foreach (string indicatorsLine in ptmagicInstance.IndicatorsLines) foreach (string indicatorsLine in ptmagicInstance.IndicatorsLines)
{ {
if (indicatorsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1) if (indicatorsLine.IndexOf("PTMagic_SingleMarketSettings", StringComparison.InvariantCultureIgnoreCase) > -1)
{ {
// Single Market Settings will get overwritten every single run => crop the lines // Single Market Settings will get overwritten every single run => crop the lines
break; break;
} }
else else
{ {
// Copy the line into the new pairs file and keep searching
string globalIndicatorsLine = indicatorsLine; string globalIndicatorsLine = indicatorsLine;
globalIndicatorsLines.Add(globalIndicatorsLine); globalIndicatorsLines.Add(globalIndicatorsLine);
@ -536,7 +539,11 @@ namespace Core.ProfitTrailer
string appliedSettingsStringList = ""; string appliedSettingsStringList = "";
foreach (SingleMarketSetting sms in appliedSettings) foreach (SingleMarketSetting sms in appliedSettings)
{ {
if (!appliedSettingsStringList.Equals("")) appliedSettingsStringList += ", "; if (!appliedSettingsStringList.Equals(""))
{
appliedSettingsStringList += ", ";
}
appliedSettingsStringList += sms.SettingName; appliedSettingsStringList += sms.SettingName;
} }