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")) + "'}]"; } - - - - - - } }