Fixed an issue that made SMS not getting applied properly

This commit is contained in:
Legedric 2018-05-22 13:04:53 +02:00
parent d401d508a0
commit 6c0bcc41a7
5 changed files with 124 additions and 112 deletions

View File

@ -1568,7 +1568,7 @@ namespace Core.Main {
// Write single market settings
this.Log.DoLogInfo("Building single market settings for '" + this.TriggeredSingleMarketSettings.Count.ToString() + "' markets...");
SettingsHandler.CompileSingleMarketProperties(this.ProfitTrailerMajorVersion, this.LastRuntimeSummary.MainMarket, this.TriggeredSingleMarketSettings, matchedMarketTriggers, this.PTMagicConfiguration, this.PairsLines, this.DCALines, this.IndicatorsLines, this.Log);
SettingsHandler.CompileSingleMarketProperties(this, matchedMarketTriggers);
this.SingleMarketSettingWritten = true;
this.Log.DoLogInfo("Building single market settings completed.");
@ -1576,7 +1576,7 @@ namespace Core.Main {
this.Log.DoLogInfo("No settings triggered for single markets.");
// Remove single market settings if no triggers are met - if necessary
this.SingleMarketSettingWritten = SettingsHandler.RemoveSingleMarketSettings(this.PTMagicConfiguration, this.PairsLines, this.DCALines, this.IndicatorsLines, this.Log);
this.SingleMarketSettingWritten = SettingsHandler.RemoveSingleMarketSettings(this);
}
} else {

View File

@ -247,7 +247,7 @@ namespace Core.ProfitTrailer {
return result;
}
public static void CompileSingleMarketProperties(int ptMajorVersion, string mainMarket, Dictionary<string, List<SingleMarketSetting>> singleMarketSettings, Dictionary<string, List<string>> matchedTriggers, PTMagicConfiguration systemConfiguration, List<string> pairsLines, List<string> dcaLines, List<string> indicatorsLines, LogHelper log) {
public static void CompileSingleMarketProperties(PTMagic ptmagicInstance, Dictionary<string, List<string>> matchedTriggers) {
try {
List<string> globalPairsLines = new List<string>();
List<string> globalDCALines = new List<string>();
@ -257,7 +257,7 @@ namespace Core.ProfitTrailer {
List<string> newDCALines = new List<string>();
List<string> newIndicatorsLines = new List<string>();
foreach (string pairsLine in pairsLines) {
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
@ -273,7 +273,7 @@ namespace Core.ProfitTrailer {
newPairsLines.Add("# ########################################################################");
newPairsLines.Add("");
foreach (string dcaLine in dcaLines) {
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
@ -289,7 +289,7 @@ namespace Core.ProfitTrailer {
newDCALines.Add("# ########################################################################");
newDCALines.Add("");
foreach (string indicatorsLine in indicatorsLines) {
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
@ -309,14 +309,14 @@ namespace Core.ProfitTrailer {
newIndicatorsLines.Add("# ########################################################################");
newIndicatorsLines.Add("");
foreach (string marketPair in singleMarketSettings.Keys.OrderBy(k => k)) {
foreach (string marketPair in ptmagicInstance.TriggeredSingleMarketSettings.Keys.OrderBy(k => k)) {
Dictionary<string, object> pairsPropertiesToApply = new Dictionary<string, object>();
Dictionary<string, object> dcaPropertiesToApply = new Dictionary<string, object>();
Dictionary<string, object> indicatorsPropertiesToApply = new Dictionary<string, object>();
// Build Properties as a whole list so that a single coin also has only one block with single market settings applied to it
foreach (SingleMarketSetting setting in singleMarketSettings[marketPair]) {
log.DoLogInfo("Building single market settings '" + setting.SettingName + "' for '" + marketPair + "'...");
foreach (SingleMarketSetting setting in ptmagicInstance.TriggeredSingleMarketSettings[marketPair]) {
ptmagicInstance.Log.DoLogInfo("Building single market settings '" + setting.SettingName + "' for '" + marketPair + "'...");
foreach (string settingPairsProperty in setting.PairsProperties.Keys) {
if (!pairsPropertiesToApply.ContainsKey(settingPairsProperty)) {
@ -342,12 +342,12 @@ namespace Core.ProfitTrailer {
}
}
log.DoLogInfo("Built single market settings '" + setting.SettingName + "' for '" + marketPair + "'.");
ptmagicInstance.Log.DoLogInfo("Built single market settings '" + setting.SettingName + "' for '" + marketPair + "'.");
}
newPairsLines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptMajorVersion, mainMarket, marketPair, singleMarketSettings[marketPair], pairsPropertiesToApply, matchedTriggers, globalPairsProperties, newPairsLines, systemConfiguration, log);
newDCALines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptMajorVersion, mainMarket, marketPair, singleMarketSettings[marketPair], dcaPropertiesToApply, matchedTriggers, globalDCAProperties, newDCALines, systemConfiguration, log);
newIndicatorsLines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptMajorVersion, mainMarket, marketPair, singleMarketSettings[marketPair], indicatorsPropertiesToApply, matchedTriggers, globalIndicatorsProperties, newIndicatorsLines, systemConfiguration, log);
newPairsLines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptmagicInstance.ProfitTrailerMajorVersion, ptmagicInstance.LastRuntimeSummary.MainMarket, marketPair, ptmagicInstance.TriggeredSingleMarketSettings[marketPair], pairsPropertiesToApply, matchedTriggers, globalPairsProperties, newPairsLines, ptmagicInstance.PTMagicConfiguration, ptmagicInstance.Log);
newDCALines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptmagicInstance.ProfitTrailerMajorVersion, ptmagicInstance.LastRuntimeSummary.MainMarket, marketPair, ptmagicInstance.TriggeredSingleMarketSettings[marketPair], dcaPropertiesToApply, matchedTriggers, globalDCAProperties, newDCALines, ptmagicInstance.PTMagicConfiguration, ptmagicInstance.Log);
newIndicatorsLines = SettingsHandler.BuildPropertyLinesForSingleMarketSetting(ptmagicInstance.ProfitTrailerMajorVersion, ptmagicInstance.LastRuntimeSummary.MainMarket, marketPair, ptmagicInstance.TriggeredSingleMarketSettings[marketPair], indicatorsPropertiesToApply, matchedTriggers, globalIndicatorsProperties, newIndicatorsLines, ptmagicInstance.PTMagicConfiguration, ptmagicInstance.Log);
}
// Combine global settings lines with single market settings lines
@ -355,11 +355,11 @@ namespace Core.ProfitTrailer {
globalDCALines.AddRange(newDCALines);
globalIndicatorsLines.AddRange(newIndicatorsLines);
pairsLines = globalPairsLines;
dcaLines = globalDCALines;
indicatorsLines = globalIndicatorsLines;
ptmagicInstance.PairsLines = globalPairsLines;
ptmagicInstance.DCALines = globalDCALines;
ptmagicInstance.IndicatorsLines = globalIndicatorsLines;
} catch (Exception ex) {
log.DoLogCritical("Critical error while writing settings!", ex);
ptmagicInstance.Log.DoLogCritical("Critical error while writing settings!", ex);
throw (ex);
}
}
@ -446,7 +446,7 @@ namespace Core.ProfitTrailer {
return newPropertyLines;
}
public static bool RemoveSingleMarketSettings(PTMagicConfiguration systemConfiguration, List<string> pairsLines, List<string> dcaLines, List<string> indicatorsLines, LogHelper log) {
public static bool RemoveSingleMarketSettings(PTMagic ptmagicInstance) {
bool result = false;
try {
List<string> cleanedUpPairsLines = new List<string>();
@ -454,7 +454,7 @@ namespace Core.ProfitTrailer {
List<string> cleanedUpIndicatorsLines = new List<string>();
bool removedPairsSingleMarketSettings = false;
foreach (string pairsLine in pairsLines) {
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
@ -468,7 +468,7 @@ namespace Core.ProfitTrailer {
}
bool removedDCASingleMarketSettings = false;
foreach (string dcaLine in dcaLines) {
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
@ -482,7 +482,7 @@ namespace Core.ProfitTrailer {
}
bool removedIndicatorsSingleMarketSettings = false;
foreach (string indicatorsLine in indicatorsLines) {
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
@ -495,13 +495,13 @@ namespace Core.ProfitTrailer {
}
}
pairsLines = cleanedUpPairsLines;
dcaLines = cleanedUpDCALines;
indicatorsLines = cleanedUpIndicatorsLines;
ptmagicInstance.PairsLines = cleanedUpPairsLines;
ptmagicInstance.DCALines = cleanedUpDCALines;
ptmagicInstance.IndicatorsLines = cleanedUpIndicatorsLines;
result = removedPairsSingleMarketSettings && removedDCASingleMarketSettings && removedIndicatorsSingleMarketSettings;
} catch (Exception ex) {
log.DoLogCritical("Critical error while writing settings!", ex);
ptmagicInstance.Log.DoLogCritical("Critical error while writing settings!", ex);
}
return result;

View File

@ -1,60 +1,68 @@
# ####################################
# ####### PTMagic Current Setting ########
# PTMagic_ActiveSetting = ReadyForLiftOff
# PTMagic_LastChanged = 28.03.2018 13:54
# PTMagic_ActiveSetting = Default
# PTMagic_LastChanged = 3/26/2018 11:52 AM
# ####################################
#
DCA_keep_balance = 0
DCA_keep_balance_percentage = 0
DEFAULT_DCA_max_cost = 10
DEFAULT_DCA_max_buy_times = 7
#----------------------------#
DEFAULT_DCA_A_buy_strategy = ANDERSON
#
DEFAULT_DCA_max_cost = 0
DEFAULT_DCA_max_buy_times = 20
#
DEFAULT_DCA_A_buy_strategy = LOWBB
DEFAULT_DCA_A_buy_value = 5
DEFAULT_DCA_A_buy_value_limit = -2.5
#
DEFAULT_DCA_B_buy_strategy = RSI
DEFAULT_DCA_B_buy_value = 30
DEFAULT_DCA_B_buy_value_limit = 0
DEFAULT_DCA_trailing_buy = 0.2
#---------------------------------
DEFAULT_DCA_buy_percentage = 100
DEFAULT_DCA_buy_trigger_1 = -1
DEFAULT_DCA_buy_trigger_2 = -2
DEFAULT_DCA_buy_trigger_3 = -4
DEFAULT_DCA_buy_trigger_4 = -8
DEFAULT_DCA_buy_trigger_5 = -16
DEFAULT_DCA_buy_trigger_6 = -87.6
DEFAULT_DCA_buy_trigger_7 = -98.7
DEFAULT_DCA_B_buy_value = 33
DEFAULT_DCA_B_buy_value_limit = 5
#
DEFAULT_DCA_trailing_buy = 0
#
DEFAULT_DCA_buy_trigger = 0
#
DEFAULT_DCA_buy_percentage_1 = 100
DEFAULT_DCA_buy_percentage_2 = 50
DEFAULT_DCA_buy_percentage_3 = 50
DEFAULT_DCA_buy_percentage_4 = 25
DEFAULT_DCA_buy_percentage_5 = 30
DEFAULT_DCA_buy_percentage_6 = 25
DEFAULT_DCA_buy_percentage_7 = 20
DEFAULT_DCA_buy_percentage_8 = 15.5
DEFAULT_DCA_buy_percentage_9 = 12.11
DEFAULT_DCA_buy_percentage_10 = 10
DEFAULT_DCA_buy_percentage_11 = 8
DEFAULT_DCA_buy_percentage_12 = 7
DEFAULT_DCA_buy_percentage_13 = 6
DEFAULT_DCA_buy_percentage_14 = 6
DEFAULT_DCA_buy_percentage_15 = 5
DEFAULT_DCA_buy_percentage_16 = 5
DEFAULT_DCA_buy_percentage_17 = 5
DEFAULT_DCA_buy_percentage_18 = 5
DEFAULT_DCA_buy_percentage_19 = 5
DEFAULT_DCA_buy_percentage_20 = 5
#
DEFAULT_DCA_A_sell_strategy = GAIN
# PTMagic changed line for setting 'ReadyForLiftOff' on 28.03.2018 13:53
DEFAULT_DCA_A_sell_value = 1.65
DEFAULT_DCA_A_sell_value = 1
#
DEFAULT_DCA_B_sell_strategy = RSI
DEFAULT_DCA_B_sell_value = 60
DEFAULT_DCA_trailing_profit = 0.3
DEFAULT_DCA_B_sell_value = 40
#
DEFAULT_DCA_trailing_profit = 0.147
DEFAULT_DCA_max_profit = 0
#DEFAULT_DCA_min_buy_volume = 300
DEFAULT_DCA_min_order_book_volume_percentage = 150
#
DEFAULT_DCA_min_order_book_volume_percentage = 100
#
DEFAULT_DCA_ignore_sell_only_mode = true
#
DEFAULT_DCA_max_buy_spread = 2
DEFAULT_DCA_rebuy_timeout = 10
#
DEFAULT_DCA_stop_loss_trigger = 0
DEFAULT_DCA_stop_loss_timeout = 0
DEFAULT_DCA_pending_order_wait_time = 0
#
DEFAULT_DCA_buy_min_price_increase = 0
DEFAULT_DCA_buy_max_price_increase = 0
# PTMagic_SingleMarketSettings - Written on 28.03.2018 14:01:45
# ########################################################################
#

View File

@ -1,29 +1,30 @@
# ####################################
# ####### PTMagic Current Setting ########
# PTMagic_ActiveSetting = Default2
# PTMagic_LastChanged = 26.03.2018 10:58
# PTMagic_ActiveSetting = Default
# PTMagic_LastChanged = 3/26/2018 11:52 AM
# ####################################
#
BB_std = 2
BB_candle_period = 300
BB_length = 20
#
SMA_cross_candles = 2
SMA_candle_period = 300
SMA_fast_length = 12
SMA_slow_length = 24
#
EMA_cross_candles = 3
EMA_candle_period = 1800
EMA_fast_length = 12
EMA_candle_period = 300
EMA_fast_length = 3
EMA_slow_length = 24
#
RSI_candle_period = 300
RSI_length = 14
#
STOCH_length = 14
#
MACD_candle_period = 300
MACD_fast_length = 12
MACD_slow_length = 26
MACD_signal = 9
#

View File

@ -1,62 +1,65 @@
# ####################################
# ####### PTMagic Current Setting ########
# PTMagic_ActiveSetting = Default2
# PTMagic_LastChanged = 26.03.2018 10:59
# PTMagic_ActiveSetting = Default
# PTMagic_LastChanged = 3/26/2018 11:52 AM
# ####################################
#
market = USDT
start_balance = 500.98
enabled_pairs = ADA, BCC, BTG, ETH, LTC, NEO, OMG, XMR, XRP, ZEC
#
start_balance = 1105.17429444
USDT_dust = 3.50
#
enabled_pairs = ADA, BCC, BTC, BTG, ETH, LTC, NEO, OMG, XMR, XRP, ZEC
hidden_pairs = ALL
#
max_trading_pairs = 5
#
keep_balance = 0
keep_balance_percentage = 0
coin_min_age = 0
#
consecutive_buy_trigger = 0
consecutive_sell_trigger = 0
#
DEFAULT_trading_enabled = true
DEFAULT_sell_only_mode_enabled = true
DEFAULT_max_trading_pairs = 4
DEFAULT_DCA_enabled = -1
#
pair_min_listed_days = 14
DEFAULT_DCA_enabled = true
#
DEFAULT_initial_cost = 10
DEFAULT_initial_cost_percentage = 0
DEFAULT_min_buy_volume = 200000
DEFAULT_min_buy_volume = 300000
DEFAULT_min_buy_price = 0
DEFAULT_max_buy_spread = 0
DEFAULT_max_buy_spread = 1
DEFAULT_min_order_book_volume_percentage = 100
DEFAULT_A_buy_strategy = EMAGAIN
DEFAULT_A_buy_value = -0.5
DEFAULT_A_buy_value_limit = 0
#
DEFAULT_A_buy_strategy = LOWBB
DEFAULT_A_buy_value = 5
DEFAULT_A_buy_value_limit = -2.5
#
DEFAULT_B_buy_strategy = RSI
DEFAULT_B_buy_value = 33
DEFAULT_B_buy_value_limit = 0
DEFAULT_trailing_buy = 0.2
#
DEFAULT_trailing_buy = 0
#
DEFAULT_A_sell_strategy = GAIN
DEFAULT_A_sell_value = 1.5
DEFAULT_trailing_profit = 0.15
DEFAULT_A_sell_value = 1
#
DEFAULT_B_sell_strategy = RSI
DEFAULT_B_sell_value = 40
#
DEFAULT_trailing_profit = 0.16
DEFAULT_max_profit = 0
#
DEFAULT_stop_loss_trigger = 0
DEFAULT_stop_loss_timeout = 0
DEFAULT_panic_sell_enabled = false
DEFAULT_rebuy_timeout = 5
#
DEFAULT_buy_min_price_increase = 0
DEFAULT_buy_max_price_increase = 0
# Rename me?
#
DEFAULT_pending_order_wait_time = 0
DEFAULT_combined_cancel_pending_trigger = 0
#------------------------------------
#