Fixes to Formula & Level Code
This commit is contained in:
parent
fbebf93d8c
commit
b74c3b3ec4
|
@ -304,12 +304,13 @@ namespace Core.Main.DataObjects
|
||||||
sellLogData.AverageBuyPrice = rsld.avgPrice;
|
sellLogData.AverageBuyPrice = rsld.avgPrice;
|
||||||
sellLogData.TotalCost = sellLogData.SoldAmount * sellLogData.AverageBuyPrice;
|
sellLogData.TotalCost = sellLogData.SoldAmount * sellLogData.AverageBuyPrice;
|
||||||
|
|
||||||
// check if bot is a shortbot via PT API. Losses on short bot showing as gains. Issue #195
|
// 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 soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice);
|
||||||
double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100));
|
double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100));
|
||||||
sellLogData.SoldValue = soldValueAfterFees;
|
sellLogData.SoldValue = soldValueAfterFees;
|
||||||
sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8);
|
sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8);
|
||||||
|
|
||||||
//Convert Unix Timestamp to Datetime
|
//Convert Unix Timestamp to Datetime
|
||||||
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
|
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
|
||||||
|
|
|
@ -234,11 +234,17 @@ namespace Core.ProfitTrailer
|
||||||
{
|
{
|
||||||
result = "CHANGE";
|
result = "CHANGE";
|
||||||
}
|
}
|
||||||
if (result.Contains("LEVERAGE"))
|
if (result.Contains("CROSSED"))
|
||||||
|
{
|
||||||
|
leverage = strategyName.Remove(0, 9);
|
||||||
|
leverage = leverage.Remove(leverage.Length - 1, 1);
|
||||||
|
result = "CROSS" + leverage + "X";
|
||||||
|
}
|
||||||
|
if (result.Contains("ISOLATED"))
|
||||||
{
|
{
|
||||||
leverage = strategyName.Remove(0, 10);
|
leverage = strategyName.Remove(0, 10);
|
||||||
leverage = leverage.Remove(leverage.Length - 1, 1);
|
leverage = leverage.Remove(leverage.Length - 1, 1);
|
||||||
result = leverage + " X";
|
result = "ISOL " + leverage + "X";
|
||||||
}
|
}
|
||||||
// buy/sell strategies beginning with PT 2.3.3 contain the strategy designation letter followed by a colon and space.
|
// buy/sell strategies beginning with PT 2.3.3 contain the strategy designation letter followed by a colon and space.
|
||||||
// remove the letter and colon, change to shortcut, then reapply the letter and colon
|
// remove the letter and colon, change to shortcut, then reapply the letter and colon
|
||||||
|
@ -456,7 +462,6 @@ namespace Core.ProfitTrailer
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
// Prior to PT 2.3.3
|
|
||||||
if (!checkForAnyInvalid)
|
if (!checkForAnyInvalid)
|
||||||
{
|
{
|
||||||
switch (strategyName.ToLower())
|
switch (strategyName.ToLower())
|
||||||
|
@ -503,6 +508,10 @@ namespace Core.ProfitTrailer
|
||||||
case "vwappercentage":
|
case "vwappercentage":
|
||||||
case "mvwappercentage":
|
case "mvwappercentage":
|
||||||
case "btcdominance":
|
case "btcdominance":
|
||||||
|
case "combimagain":
|
||||||
|
case "combimaspread":
|
||||||
|
case "combimacross":
|
||||||
|
case "macdpercentage":
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -583,51 +592,68 @@ namespace Core.ProfitTrailer
|
||||||
isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name);
|
isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name);
|
||||||
if (!isValidStrategy)
|
if (!isValidStrategy)
|
||||||
{
|
{
|
||||||
// Parse Formulas
|
|
||||||
if (strategy.Name.Contains("FORMULA") && !strategy.Name.Contains("STATS") && !strategy.Name.Contains("LEVEL"))
|
if (strategy.Name.Contains("TRIGGERED"))
|
||||||
|
// remove levels already triggered, to show only currently waiting trigger
|
||||||
{
|
{
|
||||||
string expression = strategy.Name.Remove(0, 10);
|
strategyText += "";
|
||||||
expression = expression.Replace("<span class=\"tdgreen\">", "true").Replace("<span class=\"red\">", "false").Replace("</span>", "").Replace("&&", "and").Replace("||", "or");
|
}
|
||||||
expression = regx.Replace(expression, String.Empty);
|
else if (strategy.Name.Contains("STATS"))
|
||||||
var tokens = new Tokenizer(expression).Tokenize();
|
// avoid parsing advanced buy stats
|
||||||
var parser = new Parser(tokens);
|
{
|
||||||
if (parser.Parse())
|
strategyText += "";
|
||||||
|
}
|
||||||
|
else if (strategy.Name.Contains("FORMULA"))
|
||||||
|
// Parse Various PT Formulas
|
||||||
|
{
|
||||||
|
if (strategy.Name.Contains("LEVEL"))
|
||||||
|
// level X
|
||||||
{
|
{
|
||||||
strategyText += "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">(FORM)</span> ";
|
string level = strategy.Name.Substring(5, 2);
|
||||||
|
string expression = strategy.Name.Remove(0, 17);
|
||||||
|
expression = expression.Replace("<span class=\"tdgreen\">", "true").Replace("<span class=\"red\">", "false").Replace("</span>", "").Replace("&&", "and").Replace("||", "or");
|
||||||
|
expression = regx.Replace(expression, String.Empty);
|
||||||
|
var tokens = new Tokenizer(expression).Tokenize();
|
||||||
|
var parser = new Parser(tokens);
|
||||||
|
if (parser.Parse())
|
||||||
|
{
|
||||||
|
strategyText += "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"LEVEL FORMULA\">L " + level + "</span> ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strategyText += "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"LEVEL FORMULA\">L " + level + "</span> ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
// standard formula
|
||||||
{
|
{
|
||||||
strategyText += "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">(FORM)</span> ";
|
string expression = strategy.Name.Remove(0, 10);
|
||||||
|
expression = expression.Replace("<span class=\"tdgreen\">", "true").Replace("<span class=\"red\">", "false").Replace("</span>", "").Replace("&&", "and").Replace("||", "or");
|
||||||
|
expression = regx.Replace(expression, String.Empty);
|
||||||
|
var tokens = new Tokenizer(expression).Tokenize();
|
||||||
|
var parser = new Parser(tokens);
|
||||||
|
if (parser.Parse())
|
||||||
|
{
|
||||||
|
strategyText += "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">FORM</span> ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strategyText += "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">FORM</span> ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strategy.Name.Contains("LEVEL") && !strategy.Name.Contains("TRIGGERED"))
|
else
|
||||||
{
|
{
|
||||||
string level = strategy.Name.Substring(5, 2);
|
strategyText += "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
|
||||||
string expression = strategy.Name.Remove(0, 17);
|
|
||||||
expression = expression.Replace("<span class=\"tdgreen\">", "true").Replace("<span class=\"red\">", "false").Replace("</span>", "").Replace("&&", "and").Replace("||", "or");
|
|
||||||
expression = regx.Replace(expression, String.Empty);
|
|
||||||
var tokens = new Tokenizer(expression).Tokenize();
|
|
||||||
var parser = new Parser(tokens);
|
|
||||||
if (parser.Parse())
|
|
||||||
{
|
|
||||||
strategyText += "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"LEVEL FORMULA\">LEVEL" + level + "</span> ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strategyText += "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"LEVEL FORMULA\">LEVEL" + level + "</span> ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (strategy.Name.Contains("LEVEL") && strategy.Name.Contains("TRIGGERED"))
|
|
||||||
{
|
|
||||||
string level = strategy.Name.Substring(5, 2);
|
|
||||||
strategyText += "<span class=\"label label-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">LEVEL " + level + "TRIG</span> ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strategyText += "<span class=\"label " + textClass + "\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
|
strategyText += "<span class=\"label " + textClass + "\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTrailingBuyActive)
|
if (isTrailingBuyActive)
|
||||||
{
|
{
|
||||||
strategyText += " <i class=\"fa fa-flag text-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Trailing active!\"></i>";
|
strategyText += " <i class=\"fa fa-flag text-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Trailing active!\"></i>";
|
||||||
|
|
Loading…
Reference in New Issue