diff --git a/Monitor/Pages/SalesAnalyzer.cshtml b/Monitor/Pages/SalesAnalyzer.cshtml index cdf53d3..96ee537 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml +++ b/Monitor/Pages/SalesAnalyzer.cshtml @@ -59,16 +59,21 @@
-

Sales Analysis

- @{ - double totalProfit = Model.PTData.SellLog.Sum(s => s.Profit); + double totalProfit = 0; + if (Model.PTData.Properties.Shorting) + { + totalProfit = Model.PTData.SellLog.Sum(s => s.Profit * (-1)); + } + else + { + 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); double avgDailyGain = Model.DailyGains.Values.Average(dg => dg); double avgMonthlyGain = Model.MonthlyGains.Values.Average(dg => dg); - string percentGainText = percentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; if (Model.PTData.TransactionData.Transactions.Count > 0) { percentGainText = ""; @@ -123,9 +128,7 @@ double estimatedBalance6Months = Math.Round(currentTotalBalance * Math.Pow((1 + (avgDailyGain / 100)), 180.0), 8); double estimatedBalance1Year = Math.Round(currentTotalBalance * Math.Pow((1 + (avgDailyGain / 100)), 365.0), 8); } -

Balance Prediction

- @@ -188,7 +191,6 @@

Last @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries days

-
@@ -202,7 +204,15 @@ @for (DateTime salesDate = Model.DateTimeNow.DateTime.Date; salesDate >= Model.DateTimeNow.DateTime.AddDays(-Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries) && salesDate >= Model.MinSellLogDate; salesDate = salesDate.AddDays(-1)) { List salesDateSales = Model.PTData.SellLog.FindAll(sl => sl.SoldDate.Date == salesDate); - double salesDateProfit = salesDateSales.Sum(sl => sl.Profit); + double salesDateProfit = 0; + if (Model.PTData.Properties.Shorting) + { + salesDateProfit = salesDateSales.Sum(sl => sl.Profit * (-1)); + } + else + { + salesDateProfit = salesDateSales.Sum(sl => sl.Profit); + } double salesDateProfitFiat = Math.Round(salesDateProfit * Model.Summary.MainMarketPrice, 2); double salesDateStartBalance = Model.PTData.GetSnapshotBalance(salesDate); double salesDateGain = Math.Round(salesDateProfit / salesDateStartBalance * 100, 2); @@ -241,11 +251,18 @@ } @for (DateTime salesMonthDate = salesMonthStartDate.Date; salesMonthDate >= Model.DateTimeNow.DateTime.AddMonths(-Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries) && salesMonthDate >= minSellLogMonthDate; salesMonthDate = salesMonthDate.AddMonths(-1)) { List salesMonthSales = Model.PTData.SellLog.FindAll(sl => sl.SoldDate.Date.Month == salesMonthDate.Month && sl.SoldDate.Date.Year == salesMonthDate.Year); - double salesDateProfit = salesMonthSales.Sum(sl => sl.Profit); + double salesDateProfit = 0; + if (Model.PTData.Properties.Shorting) + { + salesDateProfit = salesMonthSales.Sum(sl => sl.Profit * (-1)); + } + else + { + salesDateProfit = salesMonthSales.Sum(sl => sl.Profit); + } double salesDateProfitFiat = Math.Round(salesDateProfit * Model.Summary.MainMarketPrice, 2); double salesDateStartBalance = Model.PTData.GetSnapshotBalance(salesMonthDate); double salesDateGain = Math.Round(salesDateProfit / salesDateStartBalance * 100, 2); - double salesDateAVGDailyGain = 0; double monthDailyProfit = 0; int days = 0; @@ -254,7 +271,15 @@ if (monthDay <= Model.DateTimeNow) { days++; List monthDaySales = Model.PTData.SellLog.FindAll(sl => sl.SoldDate.Date == monthDay.Date); - double monthDayProfit = monthDaySales.Sum(sl => sl.Profit); + double monthDayProfit = 0; + if (Model.PTData.Properties.Shorting) + { + monthDayProfit = monthDaySales.Sum(sl => sl.Profit * (-1)); + } + else + { + monthDayProfit = monthDaySales.Sum(sl => sl.Profit); + } double monthDayStartBalance = Model.PTData.GetSnapshotBalance(monthDay); monthDailyProfit += Math.Round(monthDayProfit / monthDayStartBalance * 100, 2); } @@ -278,9 +303,7 @@
-

Top @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets Sales Market Analysis

-
@@ -296,6 +319,10 @@ @{ var topMarkets = Model.PTData.SellLog.GroupBy(m => m.Market).Select(mg => mg.Sum(m => m.Profit)); + if (Model.PTData.Properties.Shorting) + { + topMarkets = Model.PTData.SellLog.GroupBy(m => m.Market).Select(mg => mg.Sum(m => m.Profit) * (-1)); + } int marketRank = 0; } @foreach (KeyValuePair marketData in Model.TopMarkets) { @@ -362,7 +389,6 @@ lineChart.yAxis.axisLabel('Daily Sales').tickFormat(d3.format(',')); d3.select('.trades-chart svg').attr('perserveAspectRatio', 'xMinYMid').datum(chartData).transition().duration(500).call(lineChart); nv.utils.windowResize(lineChart.update); - return lineChart; }); @@ -377,7 +403,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); - return lineChart; }); @@ -392,7 +417,6 @@ lineChart.yAxis.axisLabel('Profit').tickFormat(d3.format(',.2f')); d3.select('.balance-chart svg').attr('perserveAspectRatio', 'xMinYMid').datum(chartData).transition().duration(500).call(lineChart); nv.utils.windowResize(lineChart.update); - return lineChart; }); diff --git a/Monitor/Pages/SalesAnalyzer.cshtml.cs b/Monitor/Pages/SalesAnalyzer.cshtml.cs index 7c262bd..9f74924 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml.cs +++ b/Monitor/Pages/SalesAnalyzer.cshtml.cs @@ -28,7 +28,6 @@ namespace Monitor.Pages BindData(); BuildTCV(); } - private void BindData() { PTData = this.PtDataObject; @@ -40,20 +39,25 @@ namespace Monitor.Pages BuildTopMarkets(); BuildSalesChartData(); } - private void BuildTopMarkets() { var markets = PTData.SellLog.GroupBy(m => m.Market); Dictionary topMarketsDic = new Dictionary(); foreach (var market in markets) { - double totalProfit = PTData.SellLog.FindAll(m => m.Market == market.Key).Sum(m => m.Profit); - + double totalProfit = 0; + if (PTData.Properties.Shorting) + { + totalProfit = PTData.SellLog.FindAll(m => m.Market == market.Key).Sum(m => m.Profit * (-1)); + } + else + { + totalProfit = PTData.SellLog.FindAll(m => m.Market == market.Key).Sum(m => m.Profit); + } topMarketsDic.Add(market.Key, totalProfit); } TopMarkets = new SortedDictionary(topMarketsDic).OrderByDescending(m => m.Value).Take(PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets); } - private void BuildSalesChartData() { if (PTData.SellLog.Count > 0) @@ -69,26 +73,29 @@ namespace Monitor.Pages double balance = 0.0; for (DateTime salesDate = graphStartDate; salesDate <= DateTimeNow.DateTime.Date; salesDate = salesDate.AddDays(1)) { - if (tradeDayIndex > 0) { tradesPerDayJSON += ",\n"; profitPerDayJSON += ",\n"; balancePerDayJSON += ",\n"; } - + double profit = 0; int trades = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Count; - double profit = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Sum(t => t.Profit); + if (PTData.Properties.Shorting) + { + profit = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Sum(t => t.Profit * (-1)); + } + else + { + profit = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Sum(t => t.Profit); + } double profitFiat = Math.Round(profit * Summary.MainMarketPrice, 2); balance += profitFiat; - tradesPerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + trades + "}"; profitPerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + profitFiat.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; balancePerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + balance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; - tradeDayIndex++; } - TradesChartDataJSON = "["; TradesChartDataJSON += "{"; TradesChartDataJSON += "key: 'Sales',"; @@ -112,31 +119,43 @@ namespace Monitor.Pages BalanceChartDataJSON += "values: [" + balancePerDayJSON + "]"; BalanceChartDataJSON += "}"; BalanceChartDataJSON += "]"; - + for (DateTime salesDate = DateTimeNow.DateTime.Date; salesDate >= MinSellLogDate; salesDate = salesDate.AddDays(-1)) { List salesDateSales = PTData.SellLog.FindAll(sl => sl.SoldDate.Date == salesDate); - double salesDateProfit = salesDateSales.Sum(sl => sl.Profit); + double salesDateProfit; + if (PTData.Properties.Shorting) + { + salesDateProfit = salesDateSales.Sum(sl => sl.Profit * (-1)); + } + else + { + salesDateProfit = salesDateSales.Sum(sl => sl.Profit); + } double salesDateStartBalance = PTData.GetSnapshotBalance(salesDate); double salesDateGain = Math.Round(salesDateProfit / salesDateStartBalance * 100, 2); - DailyGains.Add(salesDate, salesDateGain); } - DateTime minSellLogMonthDate = new DateTime(MinSellLogDate.Year, MinSellLogDate.Month, 1).Date; DateTime salesMonthStartDate = new DateTime(DateTimeNow.DateTime.Year, DateTimeNow.DateTime.Month, 1).Date; for (DateTime salesMonthDate = salesMonthStartDate.Date; salesMonthDate >= minSellLogMonthDate; salesMonthDate = salesMonthDate.AddMonths(-1)) { List salesMonthSales = PTData.SellLog.FindAll(sl => sl.SoldDate.Date.Month == salesMonthDate.Month && sl.SoldDate.Date.Year == salesMonthDate.Year); - double salesDateProfit = salesMonthSales.Sum(sl => sl.Profit); + double salesDateProfit; + if (PTData.Properties.Shorting) + { + salesDateProfit = salesMonthSales.Sum(sl => sl.Profit * (-1)); + } + else + { + salesDateProfit = salesMonthSales.Sum(sl => sl.Profit); + } double salesDateStartBalance = PTData.GetSnapshotBalance(salesMonthDate); double salesDateGain = Math.Round(salesDateProfit / salesDateStartBalance * 100, 2); - MonthlyGains.Add(salesMonthDate, salesDateGain); } } } - private void BuildTCV() { double AvailableBalance = PTData.GetCurrentBalance(); @@ -146,10 +165,5 @@ namespace Monitor.Pages } totalCurrentValue = totalCurrentValue + AvailableBalance; } - - - - - } } diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 35534aa..4da9493 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -47,6 +47,7 @@ +
@@ -108,8 +109,17 @@

Sales Overviewmore

- @{ - double totalProfit = Model.PTData.SellLog.Sum(s => s.Profit); + @{ + + double totalProfit = 0; + if (Model.PTData.Properties.Shorting) + { + totalProfit = Model.PTData.SellLog.Sum(s => s.Profit * (-1)); + } + else + { + 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); string percentGainText = percentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; @@ -118,23 +128,55 @@ percentGainText = ""; } + double todaysProfit = 0; + if (Model.PTData.Properties.Shorting) + { + todaysProfit = Model.PTData.SellLogToday.Sum(s => s.Profit * (-1)); + } + else + { + todaysProfit = Model.PTData.SellLogToday.Sum(s => s.Profit); + } double todaysStartBalance = Model.PTData.GetSnapshotBalance(Model.DateTimeNow.DateTime); - double todaysProfit = Model.PTData.SellLogToday.Sum(s => s.Profit); double todaysProfitFiat = Math.Round(todaysProfit * Model.Summary.MainMarketPrice, 2); double todaysPercentGain = Math.Round(todaysProfit / todaysStartBalance * 100, 2); + double yesterdaysProfit = 0; + if (Model.PTData.Properties.Shorting) + { + yesterdaysProfit = Model.PTData.SellLogYesterday.Sum(s => s.Profit * (-1)); + } + else + { + yesterdaysProfit = Model.PTData.SellLogYesterday.Sum(s => s.Profit); + } double yesterdaysStartBalance = Model.PTData.GetSnapshotBalance(Model.DateTimeNow.DateTime.AddDays(-1)); - double yesterdaysProfit = Model.PTData.SellLogYesterday.Sum(s => s.Profit); double yesterdaysProfitFiat = Math.Round(yesterdaysProfit * Model.Summary.MainMarketPrice, 2); double yesterdaysPercentGain = Math.Round(yesterdaysProfit / yesterdaysStartBalance * 100, 2); + double last7DaysProfit = 0; + if (Model.PTData.Properties.Shorting) + { + last7DaysProfit = Model.PTData.SellLogLast7Days.Sum(s => s.Profit * (-1)); + } + else + { + last7DaysProfit = Model.PTData.SellLogLast7Days.Sum(s => s.Profit); + } double last7DaysStartBalance = Model.PTData.GetSnapshotBalance(Model.DateTimeNow.DateTime.AddDays(-7)); - double last7DaysProfit = Model.PTData.SellLogLast7Days.Sum(s => s.Profit); double last7DaysProfitFiat = Math.Round(last7DaysProfit * Model.Summary.MainMarketPrice, 2); double last7DaysPercentGain = Math.Round(last7DaysProfit / last7DaysStartBalance * 100, 2); + double last30DaysProfit = 0; + if (Model.PTData.Properties.Shorting) + { + last30DaysProfit = Model.PTData.SellLogLast30Days.Sum(s => s.Profit * (-1)); + } + else + { + last30DaysProfit = Model.PTData.SellLogLast30Days.Sum(s => s.Profit); + } double last30DaysStartBalance = Model.PTData.GetSnapshotBalance(Model.DateTimeNow.DateTime.AddDays(-30)); - double last30DaysProfit = Model.PTData.SellLogLast30Days.Sum(s => s.Profit); double last30DaysProfitFiat = Math.Round(last30DaysProfit * Model.Summary.MainMarketPrice, 2); double last30DaysPercentGain = Math.Round(last30DaysProfit / last30DaysStartBalance * 100, 2); } diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index 54ad18a..eeb3004 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -133,7 +133,10 @@ namespace Monitor.Pages { DateTime minSellLogDate = PTData.SellLog.OrderBy(sl => sl.SoldDate).First().SoldDate.Date; DateTime graphStartDate = DateTime.UtcNow.Date.AddDays(-30); - if (minSellLogDate > graphStartDate) graphStartDate = minSellLogDate; + if (minSellLogDate > graphStartDate) + { + graphStartDate = minSellLogDate; + } for (DateTime salesDate = graphStartDate; salesDate <= DateTime.UtcNow.Date; salesDate = salesDate.AddDays(1)) { if (tradeDayIndex > 0) @@ -142,6 +145,10 @@ namespace Monitor.Pages } int trades = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate).Count; double profit = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate).Sum(t => t.Profit); + if (PTData.Properties.Shorting) + { + profit = profit * (-1); + } double profitFiat = Math.Round(profit * Summary.MainMarketPrice, 2); profitPerDayJSON += "{x: new Date('" + salesDate.ToString("yyyy-MM-dd") + "'), y: " + profitFiat.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; tradeDayIndex++; diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index c743608..db7c2ba 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -8,12 +8,12 @@

Possible Buys (@Model.PTData.BuyLog.Count)more

- @if (Model.PTData.BuyLog.Count == 0) { - + @if (Model.PTData.BuyLog.Count == 0) + {

Your Profit Trailer did not find anything worth buying so far.

- - } else { - + } + else + {
@@ -25,51 +25,51 @@ - @foreach (Core.Main.DataObjects.PTMagicData.BuyLogData buyLogEntry in Model.PTData.BuyLog.OrderBy(b => b.IsSom). - ThenByDescending(b => b.IsTrailing). - ThenByDescending(b => b.IsTrue). - ThenByDescending(b => b.TrueStrategyCount). - ThenByDescending(b => b.PercChange). - Take(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries)) { - - Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; - if (Model.Summary.MarketSummary.ContainsKey(buyLogEntry.Market)) { - mps = Model.Summary.MarketSummary[buyLogEntry.Market]; - } - - bool isTrailingBuyActive = buyLogEntry.IsTrailing; - if (buyLogEntry.BuyStrategies.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, isBuyStrategyTrue, isTrailingBuyActive); - if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) { - buyDisabled = true; - } - - - @if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) { - - } else { - - } - - - - - @if (buyDisabled) { - - } else { - - } - + @foreach (Core.Main.DataObjects.PTMagicData.BuyLogData buyLogEntry in Model.PTData.BuyLog.OrderBy(b => b.IsSom). + ThenByDescending(b => b.IsTrailing). + ThenByDescending(b => b.IsTrue). + ThenByDescending(b => b.TrueStrategyCount). + ThenByDescending(b => b.PercChange). + Take(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries)) { + Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; + if (Model.Summary.MarketSummary.ContainsKey(buyLogEntry.Market)) + { + mps = Model.Summary.MarketSummary[buyLogEntry.Market]; } + + bool isTrailingBuyActive = buyLogEntry.IsTrailing; + if (buyLogEntry.BuyStrategies.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, isBuyStrategyTrue, isTrailingBuyActive); + if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) { + buyDisabled = true; + } + + + @if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) { + + } else { + + } + + + + + @if (buyDisabled) { + + } else { + + } + + }
@buyLogEntry.Market@buyLogEntry.Market @string.Format("{0}%", (buyLogEntry.PercChange * 100).ToString("#,#0.00"))@string.Format("{0}", (buyLogEntry.Volume24h).ToString())@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))@Html.Raw(buyStrategyText)@Html.Raw(buyStrategyText)
@buyLogEntry.Market@buyLogEntry.Market @string.Format("{0}%", (buyLogEntry.PercChange * 100).ToString("#,#0.00"))@string.Format("{0}", (buyLogEntry.Volume24h).ToString())@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))@Html.Raw(buyStrategyText)@Html.Raw(buyStrategyText)
@@ -113,8 +113,6 @@ mps = Model.Summary.MarketSummary[dcaLogEntry.Market]; } - // bool shorting = Model.PTProperties.Shorting; - bool dcaEnabled = true; if (mps != null) { dcaEnabled = mps.IsDCAEnabled; @@ -142,89 +140,86 @@ bool buyDisabled = false; string leverage = ""; - double leverageValue = 0; - + double leverageValue = 1; 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, isSellStrategyTrue, isTrailingSellActive); - - // if leverage, recalculate profit target - if (sellStrategyText.Contains("CROSSED")) - { - string leverageText = sellStrategyText.Remove(0, sellStrategyText.IndexOf("CROSSED")+9); - leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); - leverageValue = double.Parse(leverage); - } - if (sellStrategyText.Contains("ISOLATED")) - { - string leverageText = sellStrategyText.Remove(0, sellStrategyText.IndexOf("ISOLATED")+10); - leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); - leverageValue = double.Parse(leverage); - } // Check for when PT loses the value of a pair bool lostValue = false; lostValue = (dcaLogEntry.TotalCost == 0.0) || (dcaLogEntry.AverageBuyPrice == 0.0); - // Aggregate totals - Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost; - double ExchangeFee = 0; - + double exchangeFee = 0; switch (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.ToLower()) { case "binance": - ExchangeFee = 0.002; + exchangeFee = 0.002; break; case "binanceus": - ExchangeFee = 0.002; + exchangeFee = 0.002; break; case "binancefutures": - ExchangeFee = 0.002; + exchangeFee = 0.002; break; case "bittrex": - ExchangeFee = 0.0025; + exchangeFee = 0.0025; break; case "poloniex": - ExchangeFee = 0.0025; + exchangeFee = 0.0025; break; default: break; } - - double TradingFee = (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) * ExchangeFee; - Model.TotalBagValue = Model.TotalBagValue + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) - TradingFee); - + // Aggregate totals + double tradingFee = (exchangeFee * dcaLogEntry.TotalCost) * 2; + double bagGain = (dcaLogEntry.ProfitPercent / 100) * dcaLogEntry.TotalCost * leverageValue; + Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost; + Model.TotalBagGain = Model.TotalBagGain + bagGain; + // Render the row - @if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) { + @if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) + { @dcaLogEntry.Market - } else { + } else + { @dcaLogEntry.Market } - @Html.Raw((dcaLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))% - @Html.Raw(dcaLogEntry.TotalCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US"))) - - @if (dcaEnabled) { - @if (dcaLogEntry.BoughtTimes > 0) { + @if (dcaEnabled) + { + @if (dcaLogEntry.BoughtTimes > 0) + { @dcaLogEntry.BoughtTimes; } - } else { + } else + { } @Html.Raw(buyStrategyText) @Html.Raw(sellStrategyText) - - - @if (leverageValue == 0) + + @if (sellStrategyText.Contains("CROSSED")) + // if leverage, recalculate profit target + { + string leverageText = sellStrategyText.Remove(0, sellStrategyText.IndexOf("CROSSED")+9); + leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); + leverageValue = double.Parse(leverage); + } + @if (sellStrategyText.Contains("ISOLATED")) + { + string leverageText = sellStrategyText.Remove(0, sellStrategyText.IndexOf("ISOLATED")+10); + leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)")); + leverageValue = double.Parse(leverage); + } + @if (leverageValue == 1) { @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? dcaLogEntry.TargetGainValue.Value.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") } @@ -233,8 +228,7 @@ double leverageTargetGain = leverageValue * dcaLogEntry.TargetGainValue.Value; @Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? leverageTargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ") } - - @if(!@lostValue) + @if (!@lostValue) { @dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% } @@ -242,25 +236,21 @@ { No Value! } - } - Totals: @Html.Raw(Model.TotalBagCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US"))) + @Html.Raw(Model.TotalBagValue.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US"))) - - @Html.Raw( (((Model.TotalBagValue - Model.TotalBagCost) / Model.TotalBagCost) * 100).ToString("#0.00", new System.Globalization.CultureInfo("en-US")))% - + @Html.Raw((((Model.TotalBagGain) / Model.TotalBagCost) * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))%
- @if (Model.PTData.DCALog.Count > Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries) {

@Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries of @Model.PTData.DCALog.Count items listed - View all items

} @@ -270,11 +260,9 @@
- \ No newline at end of file diff --git a/Monitor/Pages/_get/DashboardTop.cshtml.cs b/Monitor/Pages/_get/DashboardTop.cshtml.cs index 06a63ca..0efd6e9 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml.cs +++ b/Monitor/Pages/_get/DashboardTop.cshtml.cs @@ -6,16 +6,15 @@ namespace Monitor.Pages { public class DashboardTopModel : _Internal.BasePageModelSecureAJAX { public ProfitTrailerData PTData = null; public DateTimeOffset DateTimeNow = Constants.confMinDate; - public void OnGet() { // Initialize Config base.Init(); BindData(); } - public double TotalBagCost = 0; public double TotalBagValue = 0; + public double TotalBagGain = 0; private void BindData() { PTData = this.PtDataObject;