PTMagic/Core/ProfitTrailer/StrategyHelper.cs

600 lines
20 KiB
C#
Raw Normal View History

2018-05-22 10:11:50 +02:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Core.Main;
using Core.Helper;
using Core.Main.DataObjects.PTMagicData;
2019-05-05 12:17:32 +02:00
using System.Text.RegularExpressions;
2018-05-22 10:11:50 +02:00
namespace Core.ProfitTrailer
{
public static class StrategyHelper
{
public static string GetStrategyShortcut(string strategyName, bool onlyValidStrategies)
{
2018-05-22 10:11:50 +02:00
string result = strategyName;
2019-04-10 06:17:39 +02:00
string time = "";
2020-01-01 16:33:31 +01:00
string leverage = "";
string strategyLetter = "";
string strategyNameOnly = strategyName;
2019-04-10 06:17:39 +02:00
2020-08-08 06:12:54 +02:00
// PT allows for "advanced_stats" to show details of the trailing logic.
2019-05-18 11:23:57 +02:00
if (result.Contains("STATS"))
{
result = "";
}
2020-08-08 06:12:54 +02:00
// strategy labels with variable values
if (result.Contains("BUY TIMEOUT AS"))
2019-04-10 06:17:39 +02:00
{
2020-08-08 06:12:54 +02:00
time = strategyName.Remove(0, 15);
result = "REBUY " + time;
}
if (result.Contains("BUY TIMEOUT"))
{
time = strategyName.Remove(0, 12);
2019-04-10 06:17:39 +02:00
result = "REBUY " + time;
}
if (result.Contains("CHANGE PERC"))
{
result = "CHANGE";
}
2020-07-15 09:10:41 +02:00
if (result.Contains("CROSSED"))
{
leverage = strategyName.Remove(0, 9);
leverage = leverage.Remove(leverage.Length - 1, 1);
result = "CROSS " + leverage + "X";
2020-07-15 09:10:41 +02:00
}
if (result.Contains("ISOLATED"))
2020-01-01 16:33:31 +01:00
{
leverage = strategyName.Remove(0, 10);
leverage = leverage.Remove(leverage.Length - 1, 1);
2020-07-15 09:10:41 +02:00
result = "ISOL " + leverage + "X";
2020-01-01 16:33:31 +01:00
}
// remove the letter and colon, change to shortcut, then reapply the letter and colon
if (strategyName.Contains(":"))
{
int strategyLength = strategyName.Length - 3;
strategyLetter = strategyName.Remove(3, strategyLength);
strategyNameOnly = strategyName.Remove(0, 3);
}
2019-04-23 13:27:12 +02:00
switch (strategyNameOnly.ToLower())
{
2018-05-22 10:11:50 +02:00
case "lowbb":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "LBB");
2018-05-22 10:11:50 +02:00
break;
case "highbb":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "HBB");
2018-05-22 10:11:50 +02:00
break;
case "gain":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "GAIN");
2018-05-22 10:11:50 +02:00
break;
case "loss":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "LOSS");
2018-05-22 10:11:50 +02:00
break;
case "smagain":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SMA-G");
2018-05-22 10:11:50 +02:00
break;
case "emagain":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "EMA-G");
2019-01-24 13:09:45 +01:00
break;
2019-01-24 13:03:19 +01:00
case "hmagain":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "HMA-G");
2019-01-24 13:09:45 +01:00
break;
2019-01-24 13:03:19 +01:00
case "dmagain":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "DMA-G");
2018-05-22 10:11:50 +02:00
break;
case "smaspread":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SMA-S");
2018-05-22 10:11:50 +02:00
break;
case "emaspread":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "EMA-S");
2018-05-22 10:11:50 +02:00
break;
2019-01-24 13:03:19 +01:00
case "hmaspread":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "HMA-S");
2019-01-24 13:09:45 +01:00
break;
2019-01-24 13:03:19 +01:00
case "dmaspread":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "DMA-S");
2019-01-24 13:09:45 +01:00
break;
2018-05-22 10:11:50 +02:00
case "smacross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SMA-C");
2018-05-22 10:11:50 +02:00
break;
case "emacross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "EMA-C");
2018-05-22 10:11:50 +02:00
break;
2019-01-24 13:03:19 +01:00
case "hmacross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "HMA-C");
2019-01-24 13:03:19 +01:00
break;
case "dmacross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "DMA-C");
2019-01-24 13:03:19 +01:00
break;
2018-05-22 10:11:50 +02:00
case "rsi":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "RSI");
2018-05-22 10:11:50 +02:00
break;
case "stoch":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "STOCH");
2018-05-22 10:11:50 +02:00
break;
case "stochrsi":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "SRSI");
2018-05-22 10:11:50 +02:00
break;
2018-12-01 17:55:12 +01:00
case "stochrsik":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SRSI-K");
2018-12-01 17:55:12 +01:00
break;
case "stochrsid":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SRSI-D");
2018-12-01 17:55:12 +01:00
break;
case "stochrsicross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "SRSI-C");
2018-12-01 17:55:12 +01:00
break;
2018-05-22 10:11:50 +02:00
case "macd":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "MACD");
2018-05-22 10:11:50 +02:00
break;
case "obv":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "OBV");
2018-05-22 10:11:50 +02:00
break;
case "bbwidth":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "BBW");
2019-01-24 13:09:45 +01:00
break;
2019-01-24 13:03:19 +01:00
case "pdhigh":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "PDH");
2018-05-22 10:11:50 +02:00
break;
case "anderson":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "AND");
2018-05-22 10:11:50 +02:00
break;
2019-11-03 17:17:28 +01:00
case "pdlow":
result = String.Concat(strategyLetter, "PDL");
break;
case "pdclose":
result = String.Concat(strategyLetter, "PDC");
break;
case "signal":
result = String.Concat(strategyLetter, "SIG");
break;
case "changepercentage":
result = String.Concat(strategyLetter, "CHGPCT");
break;
case "profitpercentage":
result = String.Concat(strategyLetter, "PPCT");
break;
case "lastdcabuy":
result = String.Concat(strategyLetter, "LASTDCA");
break;
case "fixedprice":
result = String.Concat(strategyLetter, "FIXED");
break;
case "lowatrband":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "L-ATR");
2019-11-03 17:17:28 +01:00
break;
case "highatrband":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "H-ATR");
2019-11-03 17:17:28 +01:00
break;
case "atrpercentage":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "ATR-PCT");
2019-11-03 17:17:28 +01:00
break;
case "vwappercentage":
result = String.Concat(strategyLetter, "VWAP");
break;
case "mvwappercentage":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "M-VWAP");
2019-11-03 17:17:28 +01:00
break;
case "btcdominance":
result = String.Concat(strategyLetter, "BTCDOM");
break;
2019-10-15 15:05:53 +02:00
case "config som enabled":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "SOM");
2018-05-22 10:11:50 +02:00
break;
case "max buy times":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "DCAMAX");
2018-05-22 10:11:50 +02:00
break;
case "max pairs":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "PAIRS");
2018-05-22 10:11:50 +02:00
break;
case "max spread":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "SPREAD");
2018-05-22 10:11:50 +02:00
break;
case "price increase":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "INC");
2018-05-22 10:11:50 +02:00
break;
case "min buy volume":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "VOL");
2018-05-22 10:11:50 +02:00
break;
case "min buy balance":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "MIN");
2018-05-22 10:11:50 +02:00
break;
case "coin age":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "AGE");
2018-05-22 10:11:50 +02:00
break;
case "too new":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "NEW");
2018-05-22 10:11:50 +02:00
break;
case "blacklisted":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "BLACK");
2018-05-22 10:11:50 +02:00
break;
case "insufficient balance":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "BAL");
2018-05-22 10:11:50 +02:00
break;
case "max cost reached":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "COST");
2019-03-21 11:13:15 +01:00
break;
case "buy value below dust":
2019-04-23 13:27:12 +02:00
result = String.Concat(strategyLetter, "DUST");
break;
2019-07-06 03:49:28 +02:00
case "sell wall detected":
result = String.Concat(strategyLetter, "WALL");
break;
case "ignoring buy trigger":
result = String.Concat(strategyLetter, "TRIG");
break;
2019-11-09 15:46:35 +01:00
case "no dca buy logic":
2019-11-10 02:12:37 +01:00
result = String.Concat(strategyLetter, "NODCA");
2019-11-09 15:46:35 +01:00
break;
2020-07-14 15:05:49 +02:00
case "combimagain":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "COMBI-G");
2020-07-14 15:05:49 +02:00
break;
case "combimaspread":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "COMBI-S");
2020-07-14 15:05:49 +02:00
break;
case "combimacross":
2020-07-22 06:31:33 +02:00
result = String.Concat(strategyLetter, "COMBI-C");
2020-07-14 15:05:49 +02:00
break;
case "macdpercentage":
result = String.Concat(strategyLetter, "MACDPERC");
break;
2018-05-22 10:11:50 +02:00
default:
break;
}
if (onlyValidStrategies)
{
if (strategyName.IndexOf("SOM") > -1 || strategyName.IndexOf("MAX") > -1 || strategyName.IndexOf("MIN") > -1 || strategyName.IndexOf("PRICE") > -1 || strategyName.IndexOf("BLACK") > -1 || strategyName.IndexOf("INSUFFICIENT") > -1 || strategyName.IndexOf("COST") > -1)
{
2018-05-22 10:11:50 +02:00
result = "";
}
}
return result;
}
public static bool IsValidStrategy(string strategyName)
{
2018-05-22 10:11:50 +02:00
return StrategyHelper.IsValidStrategy(strategyName, false);
}
public static bool IsValidStrategy(string strategyName, bool checkForAnyInvalid)
{
2018-05-22 10:11:50 +02:00
bool result = false;
// buy/sell strategies beginning with PT 2.3.3 contain the letter followed by a colon and space.
2019-04-23 13:27:12 +02:00
if (strategyName.Contains(":"))
2019-04-22 20:50:31 +02:00
{
result = true;
}
if (!checkForAnyInvalid)
{
switch (strategyName.ToLower())
{
2018-05-22 10:11:50 +02:00
case "lowbb":
case "highbb":
case "gain":
case "loss":
case "smagain":
case "emagain":
2019-01-24 13:03:19 +01:00
case "hmagain":
case "dmagain":
2018-05-22 10:11:50 +02:00
case "smaspread":
case "emaspread":
2019-01-24 13:03:19 +01:00
case "hmaspread":
case "dmaspread":
2018-05-22 10:11:50 +02:00
case "smacross":
case "emacross":
2019-01-24 13:03:19 +01:00
case "hmacross":
case "dmacross":
2018-05-22 10:11:50 +02:00
case "rsi":
case "stoch":
case "stochrsi":
2018-12-01 18:06:14 +01:00
case "stochrsik":
case "stochrsid":
case "stochrsicross":
2018-05-22 10:11:50 +02:00
case "macd":
case "obv":
case "bbwidth":
case "anderson":
2019-01-24 13:03:19 +01:00
case "dema":
case "hma":
case "pdhigh":
2019-11-03 17:17:28 +01:00
case "pdlow":
case "pdclose":
2019-02-15 21:26:37 +01:00
case "signal":
2019-11-03 17:17:28 +01:00
case "changepercentage":
case "profitpercentage":
case "lastdcabuy":
case "fixedprice":
case "lowatrband":
case "highatrband":
case "atrpercentage":
case "vwappercentage":
case "mvwappercentage":
case "btcdominance":
2020-07-15 09:10:41 +02:00
case "combimagain":
case "combimaspread":
case "combimacross":
case "macdpercentage":
2018-05-22 10:11:50 +02:00
result = true;
break;
default:
break;
}
}
else
{
2018-05-22 10:11:50 +02:00
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)
{
2018-05-22 10:11:50 +02:00
result = true;
}
}
return result;
}
public static int GetStrategyValueDecimals(string strategyName)
{
2018-05-22 10:11:50 +02:00
int result = 0;
switch (strategyName.ToLower())
{
2018-05-22 10:11:50 +02:00
case "lowbb":
case "highbb":
result = 8;
break;
case "gain":
case "loss":
case "smagain":
case "emagain":
2019-01-24 13:03:19 +01:00
case "hmagain":
case "dmagain":
2018-05-22 10:11:50 +02:00
case "smaspread":
case "emaspread":
2019-01-24 13:03:19 +01:00
case "hmaspread":
case "dmaspread":
2018-05-22 10:11:50 +02:00
case "smacross":
case "emacross":
2019-01-24 13:03:19 +01:00
case "hmacross":
case "dmacross":
case "anderson":
case "pdhigh":
2018-05-22 10:11:50 +02:00
result = 2;
break;
case "rsi":
case "stochrsi":
2018-12-01 18:06:14 +01:00
case "stochrsik":
case "stochrsid":
case "stochrsicross":
2018-05-22 10:11:50 +02:00
case "stoch":
case "macd":
case "obv":
case "bbwidth":
result = 0;
break;
default:
break;
}
return result;
}
public static string GetStrategyText(Summary summary, List<Strategy> strategies, string strategyText, bool isTrue, bool isTrailingBuyActive)
{
bool isValidStrategy = false;
Regex regx = new Regex(@"[ABCDEFGHIJKLMNOPQRSTUVWXYZ]", RegexOptions.Compiled);
if (strategies.Count > 0)
{
foreach (Strategy strategy in strategies)
{
string textClass = (strategy.IsTrue) ? "label-success" : "label-danger";
isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name);
if (!isValidStrategy)
{
2020-07-15 09:10:41 +02:00
if (strategy.Name.Contains("TRIGGERED"))
// remove levels already triggered, to show only currently waiting trigger
2019-04-23 13:27:12 +02:00
{
2020-07-15 09:10:41 +02:00
strategyText += "";
}
else if (strategy.Name.Contains("STATS"))
2020-08-08 05:08:36 +02:00
// Avoid displaying advanced buy stats and completed level formulas
2020-07-15 09:10:41 +02:00
{
2020-07-15 15:51:56 +02:00
strategy.Name = "";
2019-04-23 13:27:12 +02:00
}
2020-07-15 09:10:41 +02:00
else if (strategy.Name.Contains("FORMULA"))
2020-08-08 05:08:36 +02:00
// Avoid displaying formula details
2020-07-14 15:05:49 +02:00
{
2020-07-15 09:10:41 +02:00
if (strategy.Name.Contains("LEVEL"))
2020-07-14 15:05:49 +02:00
{
2020-08-07 19:13:22 +02:00
string level = strategy.Name.Substring(5, 1);
strategyText += "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"LEVEL FORMULA\">L " + level + "</span> ";
2020-07-14 15:05:49 +02:00
}
else
{
2020-08-07 19:13:22 +02:00
strategyText += "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"CONDITIONAL FORMULA\">FORM</span> ";
2020-07-14 15:05:49 +02:00
}
}
2020-07-15 09:10:41 +02:00
else
2019-04-23 13:27:12 +02:00
{
2020-07-15 09:10:41 +02:00
strategyText += "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
2019-04-23 13:27:12 +02:00
}
2020-07-15 09:10:41 +02:00
}
else
{
2018-05-22 10:11:50 +02:00
strategyText += "<span class=\"label " + textClass + "\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategy.Name + "\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + "</span> ";
}
}
2020-07-15 09:10:41 +02:00
if (isTrailingBuyActive)
{
2018-05-22 10:11:50 +02:00
strategyText += " <i class=\"fa fa-flag text-success\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Trailing active!\"></i>";
}
}
else
{
if (isTrue)
{
2020-08-07 19:13:22 +02:00
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
{
isValidStrategy = StrategyHelper.IsValidStrategy(strategyText);
if (isValidStrategy)
{
2020-08-07 19:13:22 +02:00
strategyText = "<span class=\"label label-danger\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategyText + "\">" + StrategyHelper.GetStrategyShortcut(strategyText, true) + "</span> ";
}
else if (strategyText.Equals("") && isValidStrategy == false)
{
strategyText = "<span class=\"label label-muted\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Not Applicable: Not using DCA!\"></span>";
}
else
{
2018-05-22 10:11:50 +02:00
strategyText = "<span class=\"label label-warning\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"" + strategyText + "\">" + StrategyHelper.GetStrategyShortcut(strategyText, false) + "</span> ";
}
}
}
return strategyText;
}
public static string GetCurrentValueText(List<Strategy> strategies, string strategyText, double bbValue, double simpleValue, bool includeShortcut)
{
2018-05-22 10:11:50 +02:00
string result = "";
if (strategies.Count > 0)
{
foreach (Strategy strategy in strategies)
{
if (StrategyHelper.IsValidStrategy(strategy.Name))
{
2018-05-22 10:11:50 +02:00
if (!result.Equals("")) result += "<br />";
string decimalFormat = "";
int decimals = StrategyHelper.GetStrategyValueDecimals(strategy.Name);
for (int d = 1; d <= decimals; d++)
{
2018-05-22 10:11:50 +02:00
decimalFormat += "0";
}
if (includeShortcut)
{
2018-05-22 10:11:50 +02:00
result += "<span class=\"text-muted\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, true) + "</span> ";
}
if (StrategyHelper.GetStrategyShortcut(strategy.Name, true).IndexOf("and", StringComparison.InvariantCultureIgnoreCase) > -1)
{
2018-05-22 10:11:50 +02:00
result += simpleValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
}
else
{
if (decimals == 0)
{
if (!SystemHelper.IsInteger(strategy.CurrentValue))
{
2018-05-22 10:11:50 +02:00
result += strategy.CurrentValue.ToString("#,#", new System.Globalization.CultureInfo("en-US"));
}
else
{
2018-05-22 10:11:50 +02:00
result += strategy.CurrentValue.ToString("#,#0", new System.Globalization.CultureInfo("en-US"));
}
}
else
{
2018-05-22 10:11:50 +02:00
result += strategy.CurrentValue.ToString("#,#0." + decimalFormat, new System.Globalization.CultureInfo("en-US"));
}
}
}
}
}
else
{
if (StrategyHelper.GetStrategyShortcut(strategyText, true).IndexOf("bb", StringComparison.InvariantCultureIgnoreCase) > -1)
{
2018-05-22 10:11:50 +02:00
result = bbValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"));
}
else
{
2018-05-22 10:11:50 +02:00
result = simpleValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%";
}
}
return result;
}
public static string GetTriggerValueText(Summary summary, List<Strategy> strategies, string strategyText, double bbValue, double simpleValue, int buyLevel, bool includeShortcut)
{
2018-05-22 10:11:50 +02:00
string result = "";
if (strategies.Count > 0)
{
foreach (Strategy strategy in strategies)
{
if (StrategyHelper.IsValidStrategy(strategy.Name))
{
2018-05-22 10:11:50 +02:00
if (!result.Equals("")) result += "<br />";
string decimalFormat = "";
int decimals = StrategyHelper.GetStrategyValueDecimals(strategy.Name);
for (int d = 1; d <= decimals; d++)
{
2018-05-22 10:11:50 +02:00
decimalFormat += "0";
}
if (includeShortcut)
{
2018-05-22 10:11:50 +02:00
result += "<span class=\"text-muted\">" + StrategyHelper.GetStrategyShortcut(strategy.Name, true) + "</span> ";
}
if (StrategyHelper.GetStrategyShortcut(strategy.Name, true).IndexOf("and", StringComparison.InvariantCultureIgnoreCase) > -1)
{
2018-05-22 10:11:50 +02:00
result += strategy.TriggerValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
}
else
{
if (decimals == 0)
{
if (!SystemHelper.IsInteger(strategy.EntryValue))
{
2018-05-22 10:11:50 +02:00
result += strategy.EntryValue.ToString(new System.Globalization.CultureInfo("en-US"));
}
else
{
2018-05-22 10:11:50 +02:00
result += strategy.EntryValue.ToString("#,#0", new System.Globalization.CultureInfo("en-US"));
}
}
else
{
2018-05-22 10:11:50 +02:00
result += strategy.EntryValue.ToString("#,#0." + decimalFormat, new System.Globalization.CultureInfo("en-US"));
}
}
}
}
}
else
{
if (StrategyHelper.GetStrategyShortcut(strategyText, true).IndexOf("bb", StringComparison.InvariantCultureIgnoreCase) > -1)
{
2018-05-22 10:11:50 +02:00
result = bbValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"));
}
else
{
if (simpleValue == Constants.MinTrendChange)
{
if (summary.DCATriggers.ContainsKey(buyLevel + 1))
{
2018-05-22 10:11:50 +02:00
simpleValue = summary.DCATriggers[buyLevel + 1];
}
}
result = simpleValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%";
}
}
return result;
}
}
2019-02-15 21:26:37 +01:00
}