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