diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 1beedc4..6cc70b1 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -335,7 +335,7 @@ namespace Core.Main.DataObjects // check if bot is a shortbot via PT API. Losses on short bot currently showing as gains. Issue #195 // code removed - + double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice); double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100)); sellLogData.SoldValue = soldValueAfterFees; @@ -399,9 +399,11 @@ namespace Core.Main.DataObjects dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy; dcaLogData.IsTrailing = false; - if (pair.buyStrategies != null && processBuyStrategies) + // See if they are using PT 2.5 (buyStrategiesData) or 2.4 (buyStrategies) + var buyStrats = pair.buyStrategies != null ? pair.buyStrategies : pair.buyStrategiesData.data; + if (buyStrats != null && processBuyStrategies) { - foreach (var bs in pair.buyStrategies) + foreach (var bs in buyStrats) { Strategy buyStrategy = new Strategy(); buyStrategy.Type = bs.type; @@ -412,16 +414,18 @@ namespace Core.Main.DataObjects buyStrategy.CurrentValue = bs.currentValue; buyStrategy.CurrentValuePercentage = bs.currentValuePercentage; buyStrategy.Decimals = bs.decimals; - buyStrategy.IsTrailing = ((string)bs.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - buyStrategy.IsTrue = ((string)bs.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; + buyStrategy.IsTrailing = bs.trailing; + buyStrategy.IsTrue = bs.strategyResult; dcaLogData.BuyStrategies.Add(buyStrategy); } } - if (pair.sellStrategies != null) + // See if they are using PT 2.5 (sellStrategiesData) or 2.4 (sellStrategies) + var sellStrats = pair.sellStrategies != null ? pair.sellStrategies : pair.sellStrategiesData.data; + if (sellStrats != null) { - foreach (var ss in pair.sellStrategies) + foreach (var ss in sellStrats) { Strategy sellStrategy = new Strategy(); sellStrategy.Type = ss.type; @@ -432,8 +436,8 @@ namespace Core.Main.DataObjects sellStrategy.CurrentValue = ss.currentValue; sellStrategy.CurrentValuePercentage = ss.currentValuePercentage; sellStrategy.Decimals = ss.decimals; - sellStrategy.IsTrailing = ((string)ss.positive).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - sellStrategy.IsTrue = ((string)ss.positive).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; + sellStrategy.IsTrailing = ss.trailing; + sellStrategy.IsTrue = ss.strategyResult; dcaLogData.SellStrategies.Add(sellStrategy); @@ -495,9 +499,14 @@ namespace Core.Main.DataObjects } else { - if (rbld.buyStrategies != null) + // Parse buy strategies + + // See if they are using PT 2.5 (buyStrategiesData) or 2.4 (buyStrategies) + var buyStrats = rbld.buyStrategies != null ? rbld.buyStrategies : rbld.buyStrategiesData.data; + + if (buyStrats != null) { - foreach (var bs in rbld.buyStrategies) + foreach (var bs in buyStrats) { Strategy buyStrategy = new Strategy(); buyStrategy.Type = bs.type; @@ -508,8 +517,8 @@ namespace Core.Main.DataObjects buyStrategy.CurrentValue = bs.currentValue; buyStrategy.CurrentValuePercentage = bs.currentValuePercentage; buyStrategy.Decimals = bs.decimals; - buyStrategy.IsTrailing = ((string)(bs.positive)).IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1; - buyStrategy.IsTrue = ((string)(bs.positive)).IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1; + buyStrategy.IsTrailing = bs.trailing; + buyStrategy.IsTrue = bs.strategyResult; // Is SOM? buyLogData.IsSom = buyLogData.IsSom || buyStrategy.Name.Contains("som enabled", StringComparison.OrdinalIgnoreCase); diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index e830c38..db866e7 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -261,85 +261,92 @@ namespace Core.ProfitTrailer public static bool IsValidStrategy(string strategyName, bool checkForAnyInvalid) { bool result = false; - // buy/sell strategies beginning with PT 2.3.3 contain the letter followed by a colon and space. - if (strategyName.Contains(":")) + + if (!string.IsNullOrEmpty(strategyName)) { - result = true; - } - if (!checkForAnyInvalid) - { - switch (strategyName.ToLower()) - { - case "lowbb": - case "highbb": - case "gain": - case "loss": - case "smagain": - case "emagain": - case "hmagain": - case "dmagain": - case "smaspread": - case "emaspread": - case "hmaspread": - case "dmaspread": - case "smacross": - case "emacross": - case "hmacross": - case "dmacross": - case "rsi": - case "stoch": - case "stochrsi": - case "stochrsik": - case "stochrsid": - case "stochrsicross": - case "macd": - case "obv": - case "bbwidth": - case "anderson": - case "dema": - case "hma": - case "pdhigh": - case "pdlow": - case "pdclose": - case "signal": - case "changepercentage": - case "profitpercentage": - case "lastdcabuy": - case "fixedprice": - case "lowatrband": - case "highatrband": - case "atrpercentage": - case "vwappercentage": - case "mvwappercentage": - case "btcdominance": - case "combimagain": - case "combimaspread": - case "combimacross": - case "macdpercentage": - result = true; - break; - default: - break; - } - } - else - { - if (strategyName.IndexOf("max", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("min", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("som", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("price", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("black", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("new", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("insufficient", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("timeout", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("spread", StringComparison.InvariantCultureIgnoreCase) == -1 - && strategyName.IndexOf("pairs", StringComparison.InvariantCultureIgnoreCase) == -1) + // buy/sell strategies beginning with PT 2.3.3 contain the letter followed by a colon and space. + if (strategyName.Contains(":")) { result = true; } + if (!checkForAnyInvalid) + { + switch (strategyName.ToLower()) + { + case "lowbb": + case "highbb": + case "gain": + case "loss": + case "smagain": + case "emagain": + case "hmagain": + case "dmagain": + case "smaspread": + case "emaspread": + case "hmaspread": + case "dmaspread": + case "smacross": + case "emacross": + case "hmacross": + case "dmacross": + case "rsi": + case "stoch": + case "stochrsi": + case "stochrsik": + case "stochrsid": + case "stochrsicross": + case "macd": + case "obv": + case "bbwidth": + case "anderson": + case "dema": + case "hma": + case "pdhigh": + case "pdlow": + case "pdclose": + case "signal": + case "changepercentage": + case "profitpercentage": + case "lastdcabuy": + case "fixedprice": + case "lowatrband": + case "highatrband": + case "atrpercentage": + case "vwappercentage": + case "mvwappercentage": + case "btcdominance": + case "combimagain": + case "combimaspread": + case "combimacross": + case "macdpercentage": + result = true; + break; + default: + break; + } + } + else + { + if (strategyName.IndexOf("max", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("min", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("som", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("price", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("black", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("new", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("insufficient", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("timeout", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("spread", StringComparison.InvariantCultureIgnoreCase) == -1 + && strategyName.IndexOf("pairs", StringComparison.InvariantCultureIgnoreCase) == -1) + { + result = true; + } + } } + return result; } + + public static int GetStrategyValueDecimals(string strategyName) { int result = 0; @@ -397,7 +404,7 @@ namespace Core.ProfitTrailer if (!isValidStrategy) { if (strategy.Name.Contains("TRIGGERED")) - // remove levels already triggered, to show only currently waiting trigger + // remove levels already triggered, to show only currently waiting trigger { strategyText += ""; }