Fixed an issue that caused the trailing flag to appear although the requirements for trailing were not fully met #489

This commit is contained in:
Legedric 2018-06-05 09:40:22 +02:00
parent 12d08f79eb
commit a6a6621ed0
7 changed files with 78 additions and 26 deletions

View File

@ -470,6 +470,7 @@ namespace Core.Main.DataObjects.PTMagicData {
public double CurrentValuePercentage { get; set; }
public int Decimals { get; set; }
public bool IsTrailing { get; set; }
public bool IsTrue { get; set; }
}
public class DCALogData {
@ -479,6 +480,7 @@ namespace Core.Main.DataObjects.PTMagicData {
public double BBTrigger { get; set; }
public double BuyTriggerPercent { get; set; }
public bool IsTrailing { get; set; }
public bool IsTrue { get; set; }
public string Market { get; set; }
public double ProfitPercent { get; set; }
public double AverageBuyPrice { get; set; }
@ -514,6 +516,7 @@ namespace Core.Main.DataObjects.PTMagicData {
public double CurrentHighBBValue { get; set; }
public double BBTrigger { get; set; }
public bool IsTrailing { get; set; }
public bool IsTrue { get; set; }
public string Market { get; set; }
public double ProfitPercent { get; set; }
public double CurrentPrice { get; set; }

View File

@ -148,7 +148,8 @@ namespace Core.Main.DataObjects {
if (dcaLogData.SellStrategy == null) dcaLogData.SellStrategy = "";
if (rdld.positive != null) {
dcaLogData.IsTrailing = rdld.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
dcaLogData.IsTrailing = rdld.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
dcaLogData.IsTrue = rdld.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
} else {
if (rdld.buyStrategies != null) {
foreach (PTStrategy bs in rdld.buyStrategies) {
@ -161,7 +162,8 @@ namespace Core.Main.DataObjects {
buyStrategy.CurrentValue = bs.currentValue;
buyStrategy.CurrentValuePercentage = bs.currentValuePercentage;
buyStrategy.Decimals = bs.decimals;
buyStrategy.IsTrailing = bs.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
buyStrategy.IsTrailing = bs.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
buyStrategy.IsTrue = bs.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
dcaLogData.BuyStrategies.Add(buyStrategy);
}
@ -178,7 +180,8 @@ namespace Core.Main.DataObjects {
sellStrategy.CurrentValue = ss.currentValue;
sellStrategy.CurrentValuePercentage = ss.currentValuePercentage;
sellStrategy.Decimals = ss.decimals;
sellStrategy.IsTrailing = ss.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
sellStrategy.IsTrailing = ss.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
sellStrategy.IsTrue = ss.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
dcaLogData.SellStrategies.Add(sellStrategy);
}
@ -231,7 +234,8 @@ namespace Core.Main.DataObjects {
sellStrategy.CurrentValue = ss.currentValue;
sellStrategy.CurrentValuePercentage = ss.currentValuePercentage;
sellStrategy.Decimals = ss.decimals;
sellStrategy.IsTrailing = ss.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
sellStrategy.IsTrailing = ss.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
sellStrategy.IsTrue = ss.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
dcaLogData.SellStrategies.Add(sellStrategy);
}
@ -271,7 +275,8 @@ namespace Core.Main.DataObjects {
if (buyLogData.BuyStrategy == null) buyLogData.BuyStrategy = "";
if (rbld.positive != null) {
buyLogData.IsTrailing = rbld.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
buyLogData.IsTrailing = rbld.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
buyLogData.IsTrue = rbld.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
} else {
if (rbld.buyStrategies != null) {
foreach (PTStrategy bs in rbld.buyStrategies) {
@ -284,7 +289,8 @@ namespace Core.Main.DataObjects {
buyStrategy.CurrentValue = bs.currentValue;
buyStrategy.CurrentValuePercentage = bs.currentValuePercentage;
buyStrategy.Decimals = bs.decimals;
buyStrategy.IsTrailing = bs.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
buyStrategy.IsTrailing = bs.positive.IndexOf("trailing", StringComparison.InvariantCultureIgnoreCase) > -1;
buyStrategy.IsTrue = bs.positive.IndexOf("true", StringComparison.InvariantCultureIgnoreCase) > -1;
buyLogData.BuyStrategies.Add(buyStrategy);
}

View File

@ -205,10 +205,10 @@ namespace Core.ProfitTrailer {
return result;
}
public static string GetStrategyText(Summary summary, List<Strategy> strategies, string strategyText, bool isTrailingBuyActive) {
public static string GetStrategyText(Summary summary, List<Strategy> strategies, string strategyText, bool isTrue, bool isTrailingBuyActive) {
if (strategies.Count > 0) {
foreach (Strategy strategy in strategies) {
string textClass = (strategy.IsTrailing) ? "label-success" : "label-danger";
string textClass = (strategy.IsTrue) ? "label-success" : "label-danger";
if (!StrategyHelper.IsValidStrategy(strategy.Name)) {
strategyText += "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
} else {
@ -220,9 +220,12 @@ namespace Core.ProfitTrailer {
strategyText += " <i class=\"fa fa-flag text-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Trailing active!\"></i>";
}
} else {
if (isTrailingBuyActive) {
if (isTrue) {
strategyText = "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategyText + "\">" + StrategyHelper.GetStrategyShortcut(strategyText, true) + "</span>";
if (isTrailingBuyActive) {
strategyText += " <i class=\"fa fa-flag text-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Trailing active!\"></i>";
}
} else {
if (StrategyHelper.IsValidStrategy(strategyText)) {
strategyText = "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategyText + "\">" + StrategyHelper.GetStrategyShortcut(strategyText, true) + "</span>";

View File

@ -38,10 +38,15 @@
bool isTrailingBuyActive = Model.DCALogData.IsTrailing;
if (Model.DCALogData.BuyStrategies.Count > 0) {
isTrailingBuyActive = (Model.DCALogData.BuyStrategies.FindAll(bs => !bs.IsTrailing).Count == 0);
isTrailingBuyActive = (Model.DCALogData.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.BuyStrategies, Model.DCALogData.BuyStrategy, isTrailingBuyActive);
bool isBuyStrategyTrue = Model.DCALogData.IsTrue;
if (Model.DCALogData.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (Model.DCALogData.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.BuyStrategies, Model.DCALogData.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
@ -62,10 +67,15 @@
bool isTrailingSellActive = false;
if (Model.DCALogData.SellStrategies.Count > 0) {
isTrailingSellActive = (Model.DCALogData.SellStrategies.FindAll(ss => !ss.IsTrailing).Count == 0);
isTrailingSellActive = (Model.DCALogData.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0);
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, isTrailingSellActive);
bool isSellStrategyTrue = false;
if (Model.DCALogData.BuyStrategies.Count > 0) {
isSellStrategyTrue = (Model.DCALogData.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0);
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
string currentSellValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, Model.DCALogData.CurrentHighBBValue, Model.DCALogData.ProfitPercent, true);
string triggerSellValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, Model.DCALogData.BBTrigger, Model.DCALogData.SellTrigger, 0, true);

View File

@ -44,10 +44,15 @@
bool isTrailingBuyActive = dcaLogEntry.IsTrailing;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrailing).Count == 0);
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isTrailingBuyActive);
bool isBuyStrategyTrue = dcaLogEntry.IsTrue;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
@ -57,10 +62,15 @@
bool isTrailingSellActive = false;
if (dcaLogEntry.SellStrategies.Count > 0) {
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrailing).Count == 0);
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0);
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isTrailingSellActive);
bool isSellStrategyTrue = false;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isSellStrategyTrue = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0);
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
string currentSellValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, dcaLogEntry.CurrentHighBBValue, dcaLogEntry.ProfitPercent, true);
string triggerSellValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, dcaLogEntry.BBTrigger, dcaLogEntry.SellTrigger, 0, true);

View File

@ -18,11 +18,16 @@
bool isTrailingBuyActive = buyLogEntry.IsTrailing;
if (buyLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (buyLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrailing).Count == 0);
isTrailingBuyActive = (buyLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
bool isBuyStrategyTrue = buyLogEntry.IsTrue;
if (buyLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (buyLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
bool buyDisabled = false;
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, buyLogEntry.BuyStrategies, buyLogEntry.BuyStrategy, isTrailingBuyActive);
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, buyLogEntry.BuyStrategies, buyLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}

View File

@ -30,11 +30,16 @@
bool isTrailingBuyActive = buyLogEntry.IsTrailing;
if (buyLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (buyLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrailing) == null);
isTrailingBuyActive = (buyLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
bool isBuyStrategyTrue = buyLogEntry.IsTrue;
if (buyLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (buyLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
bool buyDisabled = false;
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, buyLogEntry.BuyStrategies, buyLogEntry.BuyStrategy, isTrailingBuyActive);
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, buyLogEntry.BuyStrategies, buyLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
@ -98,21 +103,31 @@
bool isTrailingBuyActive = dcaLogEntry.IsTrailing;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrailing) == null);
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
bool isBuyStrategyTrue = dcaLogEntry.IsTrue;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
bool isTrailingSellActive = false;
if (dcaLogEntry.SellStrategies.Count > 0) {
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrailing) == null);
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0);
}
bool isSellStrategyTrue = false;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isSellStrategyTrue = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0);
}
bool buyDisabled = false;
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isTrailingBuyActive);
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isTrailingSellActive);
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
<tr>
@if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) {