Fixed compatability with PT 2.5 beta UI

This commit is contained in:
djbadders 2021-02-07 22:54:47 +00:00
parent a8e018097d
commit 1b2908d8a8
2 changed files with 102 additions and 86 deletions

View File

@ -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);

View File

@ -261,6 +261,9 @@ namespace Core.ProfitTrailer
public static bool IsValidStrategy(string strategyName, bool checkForAnyInvalid)
{
bool result = false;
if (!string.IsNullOrEmpty(strategyName))
{
// buy/sell strategies beginning with PT 2.3.3 contain the letter followed by a colon and space.
if (strategyName.Contains(":"))
{
@ -338,8 +341,12 @@ namespace Core.ProfitTrailer
result = true;
}
}
}
return result;
}
public static int GetStrategyValueDecimals(string strategyName)
{
int result = 0;