From 6116272e7783f398e7fa96fdfc2d28fe72130cea Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Tue, 14 Jul 2020 22:05:49 +0900 Subject: [PATCH 01/11] cdev --- Core/DataObjects/ProfitTrailerData.cs | 13 +----- Core/ProfitTrailer/StrategyHelper.cs | 53 +++++++++++++++++++++-- Monitor/Pages/_get/DashboardBottom.cshtml | 27 ++++-------- Monitor/Pages/_get/DashboardTop.cshtml | 3 +- 4 files changed, 61 insertions(+), 35 deletions(-) diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 631d812..7ecae4b 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -304,21 +304,12 @@ namespace Core.Main.DataObjects sellLogData.AverageBuyPrice = rsld.avgPrice; sellLogData.TotalCost = sellLogData.SoldAmount * sellLogData.AverageBuyPrice; - // check if sale was a short position - if ((sellLogData.ProfitPercent > 0) && (sellLogData.AverageBuyPrice > sellLogData.SoldPrice)) - { - double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice); - double soldValueAfterFees = soldValueRaw + (soldValueRaw * ((double)rsld.fee / 100)); - sellLogData.SoldValue = soldValueAfterFees; - sellLogData.Profit = Math.Abs(Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8)); - } - else - { + // check if bot is a shortbot via PT API. Losses on short bot showing as gains. Issue #195 + double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice); double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100)); sellLogData.SoldValue = soldValueAfterFees; sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8); - } //Convert Unix Timestamp to Datetime System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index 2a902be..2f29e99 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -228,7 +228,7 @@ namespace Core.ProfitTrailer result = ""; } - // strategy labels that are variable, so can't be caught by the switch statement + // strategy labels that are variable value if (result.Contains("REBUY")) { time = strategyName.Remove(0, 14); @@ -423,6 +423,18 @@ namespace Core.ProfitTrailer case "no dca buy logic": result = String.Concat(strategyLetter, "NODCA"); break; + case "combimagain": + result = String.Concat(strategyLetter, "COMBIG"); + break; + case "combimaspread": + result = String.Concat(strategyLetter, "COMBIS"); + break; + case "combimacross": + result = String.Concat(strategyLetter, "COMBIC"); + break; + case "macdpercentage": + result = String.Concat(strategyLetter, "MACDPERC"); + break; default: break; } @@ -588,7 +600,7 @@ namespace Core.ProfitTrailer if (!isValidStrategy) { // Parse Formulas - if (strategy.Name.Contains("FORMULA") && !strategy.Name.Contains("STATS")) + if (strategy.Name.Contains("FORMULA") && !strategy.Name.Contains("STATS") && !strategy.Name.Contains("LEVEL")) { string expression = strategy.Name.Remove(0, 10); expression = expression.Replace("", "true").Replace("", "false").Replace("", "").Replace("&&", "and").Replace("||", "or"); @@ -605,10 +617,43 @@ namespace Core.ProfitTrailer } } - else + //else + //{ + // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; + //} + + + if (strategy.Name.Contains("LEVEL") && !strategy.Name.Contains("TRIGGERED")) { - strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; + string level = strategy.Name.Substring(5, 2); + string expression = strategy.Name.Remove(0, 17); + expression = expression.Replace("", "true").Replace("", "false").Replace("", "").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 += "LEVEL" + level + " "; + } + else + { + strategyText += "LEVEL" + level + " "; + } + } + //else + //{ + // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; + //} + + if (strategy.Name.Contains("LEVEL") && strategy.Name.Contains("TRIGGERED")) + { + string level = strategy.Name.Substring(5, 2); + strategyText += "LEVEL " + level + "TRIG "; + } + + + } else { diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 2e0bd56..7cf7553 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -13,7 +13,6 @@
- @if (!Model.TrendChartDataJSON.Equals("")) {
@@ -25,7 +24,7 @@
-
+ @{ double currentBalance = Model.PTData.GetCurrentBalance(); string currentBalanceString = currentBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); @@ -34,21 +33,14 @@ } }
- - Start balence:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket -
- Current value:   @currentBalanceString @Model.Summary.MainMarket -
- Gain:   @Math.Round(((currentBalance - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) % -
-
+ TCV:   @currentBalanceString   @Model.Summary.MainMarket  
- +
-
+
@if (!Model.ProfitChartDataJSON.Equals("")) { @@ -65,11 +57,9 @@
-
-
-
-

Market Trends at @Model.PTMagicConfiguration.GeneralSettings.Application.Exchangemore

+

Market Trends at @Model.PTMagicConfiguration.GeneralSettings.Application.Exchange + more

@@ -108,12 +98,10 @@
-
-

Sales Overviewmore

- @{ + @{ double totalProfit = Model.PTData.SellLog.Sum(s => s.Profit); double totalProfitFiat = Math.Round(totalProfit * Model.Summary.MainMarketPrice, 2); double percentGain = Math.Round(totalProfit / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance * 100, 2); @@ -190,6 +178,7 @@
+ Starting Balance:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket
diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index b417b9a..90c7de1 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -224,8 +224,9 @@ - @Html.Raw((((Model.TotalBagValue - Model.TotalBagCost) / Model.TotalBagCost) * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))% + @Html.Raw( (((Model.TotalBagValue - Model.TotalBagCost) / Model.TotalBagCost) * 100).ToString("#0.00", new System.Globalization.CultureInfo("en-US")))% +
From 929e8553346e8b942390666ab9862f96a7309be1 Mon Sep 17 00:00:00 2001 From: HojouFotytu Date: Wed, 15 Jul 2020 00:31:23 +0900 Subject: [PATCH 02/11] Update StrategyHelper.cs removed a few empty lines --- Core/ProfitTrailer/StrategyHelper.cs | 32 ---------------------------- 1 file changed, 32 deletions(-) diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index 2f29e99..a133822 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -438,7 +438,6 @@ namespace Core.ProfitTrailer 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) @@ -446,7 +445,6 @@ namespace Core.ProfitTrailer result = ""; } } - return result; } @@ -458,13 +456,11 @@ 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(":")) { result = true; } - // Prior to PT 2.3.3 if (!checkForAnyInvalid) { @@ -534,14 +530,11 @@ namespace Core.ProfitTrailer result = true; } } - return result; } - public static int GetStrategyValueDecimals(string strategyName) { int result = 0; - switch (strategyName.ToLower()) { case "lowbb": @@ -580,10 +573,8 @@ namespace Core.ProfitTrailer default: break; } - return result; } - public static string GetStrategyText(Summary summary, List strategies, string strategyText, bool isTrue, bool isTrailingBuyActive) { bool isValidStrategy = false; @@ -594,9 +585,7 @@ namespace Core.ProfitTrailer foreach (Strategy strategy in strategies) { string textClass = (strategy.IsTrue) ? "label-success" : "label-danger"; - isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name); - if (!isValidStrategy) { // Parse Formulas @@ -615,14 +604,7 @@ namespace Core.ProfitTrailer { strategyText += "(FORM) "; } - } - //else - //{ - // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; - //} - - if (strategy.Name.Contains("LEVEL") && !strategy.Name.Contains("TRIGGERED")) { string level = strategy.Name.Substring(5, 2); @@ -641,26 +623,17 @@ namespace Core.ProfitTrailer } } - //else - //{ - // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; - //} - if (strategy.Name.Contains("LEVEL") && strategy.Name.Contains("TRIGGERED")) { string level = strategy.Name.Substring(5, 2); strategyText += "LEVEL " + level + "TRIG "; } - - - } else { strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; } } - if (isTrailingBuyActive) { strategyText += " "; @@ -679,14 +652,11 @@ namespace Core.ProfitTrailer } else { - isValidStrategy = StrategyHelper.IsValidStrategy(strategyText); - if (isValidStrategy) { strategyText = "" + StrategyHelper.GetStrategyShortcut(strategyText, true) + ""; } - else if (strategyText.Equals("") && isValidStrategy == false) { strategyText = ""; @@ -697,10 +667,8 @@ namespace Core.ProfitTrailer } } } - return strategyText; } - public static string GetCurrentValueText(List strategies, string strategyText, double bbValue, double simpleValue, bool includeShortcut) { string result = ""; From 54e52c49c8647c8ccd525227fab786c7f6eb6d42 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 15 Jul 2020 00:41:35 +0900 Subject: [PATCH 03/11] cleaned up blank lines --- Core/ProfitTrailer/StrategyHelper.cs | 30 ---------------------------- 1 file changed, 30 deletions(-) diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index 2f29e99..2663cb0 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -168,12 +168,9 @@ namespace Core.ProfitTrailer boolean = boolean && nextBoolean; else boolean = boolean || nextBoolean; - } - return boolean; } - throw new Exception("Empty expression"); } @@ -227,7 +224,6 @@ namespace Core.ProfitTrailer { result = ""; } - // strategy labels that are variable value if (result.Contains("REBUY")) { @@ -244,7 +240,6 @@ namespace Core.ProfitTrailer leverage = leverage.Remove(leverage.Length - 1, 1); result = leverage + " X"; } - // 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 if (strategyName.Contains(":")) @@ -446,7 +441,6 @@ namespace Core.ProfitTrailer result = ""; } } - return result; } @@ -534,14 +528,12 @@ namespace Core.ProfitTrailer result = true; } } - return result; } public static int GetStrategyValueDecimals(string strategyName) { int result = 0; - switch (strategyName.ToLower()) { case "lowbb": @@ -580,7 +572,6 @@ namespace Core.ProfitTrailer default: break; } - return result; } @@ -615,14 +606,7 @@ namespace Core.ProfitTrailer { strategyText += "(FORM) "; } - } - //else - //{ - // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; - //} - - if (strategy.Name.Contains("LEVEL") && !strategy.Name.Contains("TRIGGERED")) { string level = strategy.Name.Substring(5, 2); @@ -639,21 +623,12 @@ namespace Core.ProfitTrailer { strategyText += "LEVEL" + level + " "; } - } - //else - //{ - // strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; - //} - if (strategy.Name.Contains("LEVEL") && strategy.Name.Contains("TRIGGERED")) { string level = strategy.Name.Substring(5, 2); strategyText += "LEVEL " + level + "TRIG "; } - - - } else { @@ -761,14 +736,12 @@ namespace Core.ProfitTrailer result = simpleValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; } } - return result; } public static string GetTriggerValueText(Summary summary, List strategies, string strategyText, double bbValue, double simpleValue, int buyLevel, bool includeShortcut) { string result = ""; - if (strategies.Count > 0) { foreach (Strategy strategy in strategies) @@ -783,12 +756,10 @@ namespace Core.ProfitTrailer { decimalFormat += "0"; } - if (includeShortcut) { result += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, true) + " "; } - if (StrategyHelper.GetStrategyShortcut(strategy.Name, true).IndexOf("and", StringComparison.InvariantCultureIgnoreCase) > -1) { result += strategy.TriggerValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); @@ -832,7 +803,6 @@ namespace Core.ProfitTrailer result = simpleValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; } } - return result; } } From b74c3b3ec4b2e27bb10ea81e84e5eccb1b99a793 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:10:41 +0900 Subject: [PATCH 04/11] Fixes to Formula & Level Code --- Core/DataObjects/ProfitTrailerData.cs | 11 ++-- Core/ProfitTrailer/StrategyHelper.cs | 92 +++++++++++++++++---------- 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 7ecae4b..5083c50 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -304,12 +304,13 @@ namespace Core.Main.DataObjects sellLogData.AverageBuyPrice = rsld.avgPrice; 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 soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100)); - sellLogData.SoldValue = soldValueAfterFees; - sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8); + double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice); + double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100)); + sellLogData.SoldValue = soldValueAfterFees; + sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8); //Convert Unix Timestamp to Datetime System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index 27cb49a..e6b3b0a 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -234,11 +234,17 @@ namespace Core.ProfitTrailer { 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 = 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. // remove the letter and colon, change to shortcut, then reapply the letter and colon @@ -456,7 +462,6 @@ namespace Core.ProfitTrailer { result = true; } - // Prior to PT 2.3.3 if (!checkForAnyInvalid) { switch (strategyName.ToLower()) @@ -503,6 +508,10 @@ namespace Core.ProfitTrailer case "vwappercentage": case "mvwappercentage": case "btcdominance": + case "combimagain": + case "combimaspread": + case "combimacross": + case "macdpercentage": result = true; break; default: @@ -583,51 +592,68 @@ namespace Core.ProfitTrailer isValidStrategy = StrategyHelper.IsValidStrategy(strategy.Name); 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); - expression = expression.Replace("", "true").Replace("", "false").Replace("", "").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 += ""; + } + else if (strategy.Name.Contains("STATS")) + // avoid parsing advanced buy stats + { + strategyText += ""; + } + else if (strategy.Name.Contains("FORMULA")) + // Parse Various PT Formulas + { + if (strategy.Name.Contains("LEVEL")) + // level X { - strategyText += "(FORM) "; + string level = strategy.Name.Substring(5, 2); + string expression = strategy.Name.Remove(0, 17); + expression = expression.Replace("", "true").Replace("", "false").Replace("", "").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 += "L " + level + " "; + } + else + { + strategyText += "L " + level + " "; + } } else + // standard formula { - strategyText += "(FORM) "; + string expression = strategy.Name.Remove(0, 10); + expression = expression.Replace("", "true").Replace("", "false").Replace("", "").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 += "FORM "; + } + else + { + strategyText += "FORM "; + } } } - if (strategy.Name.Contains("LEVEL") && !strategy.Name.Contains("TRIGGERED")) + else { - string level = strategy.Name.Substring(5, 2); - string expression = strategy.Name.Remove(0, 17); - expression = expression.Replace("", "true").Replace("", "false").Replace("", "").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 += "LEVEL" + level + " "; - } - else - { - strategyText += "LEVEL" + level + " "; - } - } - if (strategy.Name.Contains("LEVEL") && strategy.Name.Contains("TRIGGERED")) - { - string level = strategy.Name.Substring(5, 2); - strategyText += "LEVEL " + level + "TRIG "; + strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; } + } else { strategyText += "" + StrategyHelper.GetStrategyShortcut(strategy.Name, false) + " "; } } + if (isTrailingBuyActive) { strategyText += " "; From d8130e5d170bccf62f8fe7c8429925e5558bbc98 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 15 Jul 2020 19:04:37 +0900 Subject: [PATCH 05/11] Re-Implement Dashboard Bottom GUI changes --- Core/ProfitTrailer/StrategyHelper.cs | 2 +- Monitor/Pages/_get/DashboardBottom.cshtml | 31 ++++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index e6b3b0a..ab5aa0f 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -238,7 +238,7 @@ namespace Core.ProfitTrailer { leverage = strategyName.Remove(0, 9); leverage = leverage.Remove(leverage.Length - 1, 1); - result = "CROSS" + leverage + "X"; + result = "CROSS " + leverage + "X"; } if (result.Contains("ISOLATED")) { diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 7cf7553..0edb4af 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -10,7 +10,7 @@ }
-
+
@if (!Model.TrendChartDataJSON.Equals("")) { @@ -22,9 +22,9 @@ }
-
-
- +
+
+
@{ double currentBalance = Model.PTData.GetCurrentBalance(); string currentBalanceString = currentBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); @@ -32,16 +32,18 @@ currentBalanceString = Math.Round(currentBalance, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); } } -
- TCV:   @currentBalanceString   @Model.Summary.MainMarket  
+
TCV:   @currentBalanceString   @Model.Summary.MainMarket  
- + +
+ Start:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket + Gain:   @Math.Round(((currentBalance - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) % +
- - +
@if (!Model.ProfitChartDataJSON.Equals("")) {
@@ -53,14 +55,13 @@
- -
+
+

Market Trends at @Model.PTMagicConfiguration.GeneralSettings.Application.Exchange more

- @@ -98,8 +99,9 @@
-
+
+

Sales Overviewmore

@{ double totalProfit = Model.PTData.SellLog.Sum(s => s.Profit); @@ -178,7 +180,6 @@
- Starting Balance:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket
@@ -200,7 +201,7 @@ .x(function(d) { return d.label }) .y(function(d) { return d.value }) .showLabels(true) //Display pie labels - .labelThreshold(.1) //Configure the minimum slice size for labels to show up + .labelThreshold(.1) //Configure the minimum slice size for labels to show up .labelType("percent") //Configure what type of data to show in the label. Can be "key", "value" or "percent" .donut(true) //Turn on Donut mode. Makes pie chart look tasty! .donutRatio(0.3) //Configure how big you want the donut hole size to be. From 21c85c5c56e328f173bf414a0663da5cb02ce9f8 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 15 Jul 2020 22:51:56 +0900 Subject: [PATCH 06/11] fix for STATS being parsed --- Core/ProfitTrailer/StrategyHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs index ab5aa0f..68e7508 100644 --- a/Core/ProfitTrailer/StrategyHelper.cs +++ b/Core/ProfitTrailer/StrategyHelper.cs @@ -601,7 +601,7 @@ namespace Core.ProfitTrailer else if (strategy.Name.Contains("STATS")) // avoid parsing advanced buy stats { - strategyText += ""; + strategy.Name = ""; } else if (strategy.Name.Contains("FORMULA")) // Parse Various PT Formulas From 8516e2557b4d5017797294a8e78034dbe8e2ff8a Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jul 2020 14:02:48 +0900 Subject: [PATCH 07/11] AssetDistribution Futures --- Monitor/Pages/_get/DashboardBottom.cshtml.cs | 44 ++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index 56c8386..5221f1d 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -19,6 +19,8 @@ namespace Monitor.Pages { public string AssetDistributionData = ""; public double currentBalance = 0; public string currentBalanceString = ""; + public double TotalBagCost = 0; + public double TotalBagValue = 0; public void OnGet() { // Initialize Config base.Init(); @@ -140,13 +142,41 @@ namespace Monitor.Pages { } private void BuildAssetDistributionData() { - double PairsBalance = PTData.GetPairsBalance(); - double DCABalance = PTData.GetDCABalance(); - double PendingBalance = PTData.GetPendingBalance(); - double DustBalance = PTData.GetDustBalance(); - double TotalValue = PTData.GetCurrentBalance(); - double AvailableBalance = (TotalValue - PairsBalance - DCABalance - PendingBalance - DustBalance); - + double PairsBalance = 0.0; + double DCABalance = 0.0; + double PendingBalance = 0.0; + double AvailableBalance = PTData.GetCurrentBalance(); + bool isSellStrategyTrue =false; + bool isTrailingSellActive =false; + + foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog) + { + // Loop through the pairs preparing the data for display + Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; + + string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); + + bool dcaEnabled = true; + if (mps != null) + { + dcaEnabled = mps.IsDCAEnabled; + } + + // Aggregate totals + + if (sellStrategyText.Contains("PENDING")) + { + PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } + else if (dcaEnabled) + { + DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } + else + { + PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } + } AssetDistributionData = "["; AssetDistributionData += "{label: 'Pairs',color: '#82E0AA',value: '" + PairsBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'DCA',color: '#D98880',value: '" + DCABalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; From fe32db20c55ded29f049efb889ef0372423ad593 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jul 2020 19:26:33 +0900 Subject: [PATCH 08/11] Target Profit Leverage Adjustment --- Monitor/Pages/_get/DashboardBottom.cshtml.cs | 4 -- Monitor/Pages/_get/DashboardTop.cshtml | 49 ++++++++++++++++---- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index 5221f1d..7fa28c2 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -153,17 +153,13 @@ namespace Monitor.Pages { { // Loop through the pairs preparing the data for display Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; - string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); - bool dcaEnabled = true; if (mps != null) { dcaEnabled = mps.IsDCAEnabled; } - // Aggregate totals - if (sellStrategyText.Contains("PENDING")) { PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index 90c7de1..bcdb82c 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -93,12 +93,12 @@ Market - 24H Trend + 24H Cost - DCA Buy Strats - Sell Strats - Target Profit + DCA + Sell + Target Profit @@ -137,11 +137,35 @@ } bool buyDisabled = false; + string leverage = ""; + double leverageValue = 0; + string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive); - if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) { + + if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) + { buyDisabled = true; } + + + if (buyStrategyText.Contains("CROSSED")) + { + string leverageText = buyStrategyText.Remove(0, buyStrategyText.IndexOf("CROSSED")+9); + leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); + leverageValue = double.Parse(leverage); + Write(leverageValue); + } + if (buyStrategyText.Contains("ISOLATED")) + { + leverage = buyStrategyText.Remove(0, 10); + leverage = leverage.Remove(leverage.Length - 3, 3); + //leverageValue = double.Parse(leverage); + Write(leverage); + } + + + string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); // Check for when PT loses the value of a pair @@ -197,13 +221,20 @@ } - @Html.Raw(buyStrategyText) - @Html.Raw(sellStrategyText) - @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? dcaLogEntry.TargetGainValue.Value.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") - + + @if (leverageValue == 0) + { + @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? dcaLogEntry.TargetGainValue.Value.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") + } + else + { + double leverageTargetGain = leverageValue * dcaLogEntry.TargetGainValue.Value; + @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? leverageTargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") + } + @if(!@lostValue) { @dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% From 4fc5fa6e5146b72dee0ddfa8cbb1fb4f220e1fec Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jul 2020 19:30:42 +0900 Subject: [PATCH 09/11] update code for isolated leverage --- Monitor/Pages/_get/DashboardTop.cshtml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index bcdb82c..c93a6e6 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -147,25 +147,20 @@ buyDisabled = true; } - - + // if leverage, recalculate profit target if (buyStrategyText.Contains("CROSSED")) { string leverageText = buyStrategyText.Remove(0, buyStrategyText.IndexOf("CROSSED")+9); leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); leverageValue = double.Parse(leverage); - Write(leverageValue); } if (buyStrategyText.Contains("ISOLATED")) { - leverage = buyStrategyText.Remove(0, 10); - leverage = leverage.Remove(leverage.Length - 3, 3); - //leverageValue = double.Parse(leverage); - Write(leverage); + string leverageText = buyStrategyText.Remove(0, buyStrategyText.IndexOf("ISOLATED")+10); + leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); + leverageValue = double.Parse(leverage); } - - - + string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); // Check for when PT loses the value of a pair From 94e8edd61fa5331eb234849362f5c93fbc7b6f2d Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jul 2020 20:35:43 +0900 Subject: [PATCH 10/11] Current Balance Calculation --- Core/DataObjects/PTMagicData.cs | 1 + Core/DataObjects/ProfitTrailerData.cs | 7 +--- Monitor/Pages/_get/DashboardBottom.cshtml | 11 +++-- Monitor/Pages/_get/DashboardBottom.cshtml.cs | 43 ++++++++++++++++---- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index d0a0c8c..b847c6c 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -464,6 +464,7 @@ namespace Core.Main.DataObjects.PTMagicData public DateTime FirstBoughtDate { get; set; } public string SellStrategy { get; set; } public string BuyStrategy { get; set; } + public double Leverage { get; set; } public List BuyStrategies { get; set; } = new List(); public List SellStrategies { get; set; } = new List(); } diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 5083c50..02cebd9 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -205,11 +205,7 @@ namespace Core.Main.DataObjects public double GetCurrentBalance() { return - (this.Summary.Balance + - this.Summary.PairsValue + - this.Summary.DCAValue + - this.Summary.PendingValue + - this.Summary.DustValue); + (this.Summary.Balance); } public double GetPairsBalance() { @@ -365,6 +361,7 @@ namespace Core.Main.DataObjects dcaLogData.CurrentPrice = pair.currentPrice; dcaLogData.SellTrigger = pair.triggerValue == null ? 0 : pair.triggerValue; dcaLogData.PercChange = pair.percChange; + dcaLogData.Leverage = pair.leverage; dcaLogData.BuyStrategy = pair.buyStrategy == null ? "" : pair.buyStrategy; dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy; dcaLogData.IsTrailing = false; diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 0edb4af..3d3826e 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -26,18 +26,17 @@
@{ - double currentBalance = Model.PTData.GetCurrentBalance(); - string currentBalanceString = currentBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); - if (currentBalance > 100) { - currentBalanceString = Math.Round(currentBalance, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); + string totalCurrentValueString = Model.totalCurrentValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); + if (Model.totalCurrentValue > 100) { + totalCurrentValueString = Math.Round(Model.totalCurrentValue, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); } } -
TCV:   @currentBalanceString   @Model.Summary.MainMarket  
+
TCV:   @totalCurrentValueString   @Model.Summary.MainMarket  
Start:   @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket - Gain:   @Math.Round(((currentBalance - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) % + Gain:   @Math.Round(((Model.totalCurrentValue - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) %
diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index 7fa28c2..f7654bb 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -21,6 +21,7 @@ namespace Monitor.Pages { public string currentBalanceString = ""; public double TotalBagCost = 0; public double TotalBagValue = 0; + public double totalCurrentValue = 0; public void OnGet() { // Initialize Config base.Init(); @@ -160,24 +161,52 @@ namespace Monitor.Pages { dcaEnabled = mps.IsDCAEnabled; } // Aggregate totals - if (sellStrategyText.Contains("PENDING")) + if (dcaLogEntry.Leverage == 0) { - PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); - } - else if (dcaEnabled) - { - DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + if (sellStrategyText.Contains("PENDING")) + { + PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } + else if (dcaEnabled) + { + DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } + else + { + PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + } } else { - PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); + if (sellStrategyText.Contains("PENDING")) + { + PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); + } + else if (dcaEnabled) + { + DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); + } + else + { + PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); + } } + } + + totalCurrentValue = PendingBalance + DCABalance + PairsBalance + AvailableBalance; + AssetDistributionData = "["; AssetDistributionData += "{label: 'Pairs',color: '#82E0AA',value: '" + PairsBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'DCA',color: '#D98880',value: '" + DCABalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'Pending',color: '#F5B041',value: '" + PendingBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'Balance',color: '#85C1E9',value: '" + AvailableBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'}]"; } + + + + + + } } From 09099a47cdab6af28f6e5088ae2cf16e410fb268 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jul 2020 21:34:07 +0900 Subject: [PATCH 11/11] Fix PairsBalance --- Core/DataObjects/ProfitTrailerData.cs | 2 +- Monitor/Pages/_get/DashboardBottom.cshtml | 8 ++----- Monitor/Pages/_get/DashboardBottom.cshtml.cs | 25 ++++---------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 02cebd9..0e86115 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -361,7 +361,7 @@ namespace Core.Main.DataObjects dcaLogData.CurrentPrice = pair.currentPrice; dcaLogData.SellTrigger = pair.triggerValue == null ? 0 : pair.triggerValue; dcaLogData.PercChange = pair.percChange; - dcaLogData.Leverage = pair.leverage; + dcaLogData.Leverage = pair.leverage == null ? 0 : pair.leverage; dcaLogData.BuyStrategy = pair.buyStrategy == null ? "" : pair.buyStrategy; dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy; dcaLogData.IsTrailing = false; diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 3d3826e..1051b58 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -107,7 +107,8 @@ double totalProfitFiat = Math.Round(totalProfit * Model.Summary.MainMarketPrice, 2); double percentGain = Math.Round(totalProfit / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance * 100, 2); string percentGainText = percentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; - if (Model.PTData.TransactionData.Transactions.Count > 0) { + if (Model.PTData.TransactionData.Transactions.Count > 0) + { percentGainText = ""; } @@ -205,12 +206,10 @@ .donut(true) //Turn on Donut mode. Makes pie chart look tasty! .donutRatio(0.3) //Configure how big you want the donut hole size to be. ; - d3.select("#AssetDistribution svg") .datum(@Html.Raw(Model.AssetDistributionData)) .transition().duration(350) .call(chart); - return chart; }); @@ -228,7 +227,6 @@ $.Notification.notify('success', 'top left', '@Core.Helper.SystemHelper.SplitCamelCase(Model.Summary.CurrentGlobalSetting.SettingName) now active!', 'PTMagic switched Profit Trailer settings to "@Core.Helper.SystemHelper.SplitCamelCase(Model.Summary.CurrentGlobalSetting.SettingName)".'); } - @if (!Model.TrendChartDataJSON.Equals("")) { nv.addGraph(function () { @@ -244,7 +242,6 @@ }); } - @if (!Model.ProfitChartDataJSON.Equals("")) { nv.addGraph(function () { @@ -256,7 +253,6 @@ lineChart.yAxis.axisLabel('Daily Profit').tickFormat(d3.format(',.2f')); d3.select('.profit-chart svg').attr('perserveAspectRatio', 'xMinYMid').datum(chartData).transition().duration(500).call(lineChart); //nv.utils.windowResize(lineChart.update); v1.3.0 => Removed this line to prevent memory leak - return lineChart; }); diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index f7654bb..c291295 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -52,7 +52,6 @@ namespace Monitor.Pages { BuildMarketTrendChartData(); BuildProfitChartData(); } - private void BuildMarketTrendChartData() { if (MarketTrends.Count > 0) { TrendChartDataJSON = "["; @@ -99,13 +98,10 @@ namespace Monitor.Pages { MarketTrendChange mtc = latestTickRange.First(); if (trendChartTicks > 0) TrendChartDataJSON += ",\n"; if (Double.IsInfinity(mtc.TrendChange)) mtc.TrendChange = 0; - TrendChartDataJSON += "{ x: new Date('" + mtc.TrendDateTime.ToString("yyyy-MM-ddTHH:mm:ss").Replace(".", ":") + "'), y: " + mtc.TrendChange.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; } - TrendChartDataJSON += "]"; TrendChartDataJSON += "}"; - mtIndex++; } } @@ -143,6 +139,7 @@ namespace Monitor.Pages { } private void BuildAssetDistributionData() { + // the per PT-Eelroy, the PT API doesn't provide these values when using leverage, so they are calculated here to cover either case. double PairsBalance = 0.0; double DCABalance = 0.0; double PendingBalance = 0.0; @@ -152,14 +149,9 @@ namespace Monitor.Pages { foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog) { - // Loop through the pairs preparing the data for display Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); - bool dcaEnabled = true; - if (mps != null) - { - dcaEnabled = mps.IsDCAEnabled; - } + // Aggregate totals if (dcaLogEntry.Leverage == 0) { @@ -167,7 +159,7 @@ namespace Monitor.Pages { { PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); } - else if (dcaEnabled) + else if (dcaLogEntry.BuyStrategies.Count > 0) { DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); } @@ -182,7 +174,7 @@ namespace Monitor.Pages { { PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); } - else if (dcaEnabled) + else if (dcaLogEntry.BuyStrategies.Count > 0) { DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); } @@ -191,22 +183,13 @@ namespace Monitor.Pages { PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage); } } - } - totalCurrentValue = PendingBalance + DCABalance + PairsBalance + AvailableBalance; - AssetDistributionData = "["; AssetDistributionData += "{label: 'Pairs',color: '#82E0AA',value: '" + PairsBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'DCA',color: '#D98880',value: '" + DCABalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'Pending',color: '#F5B041',value: '" + PendingBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; AssetDistributionData += "{label: 'Balance',color: '#85C1E9',value: '" + AvailableBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'}]"; } - - - - - - } }