Current Balance Calculation

This commit is contained in:
HojouFotytu 2020-07-17 20:35:43 +09:00
parent 4fc5fa6e51
commit 94e8edd61f
4 changed files with 44 additions and 18 deletions

View File

@ -464,6 +464,7 @@ namespace Core.Main.DataObjects.PTMagicData
public DateTime FirstBoughtDate { get; set; } public DateTime FirstBoughtDate { get; set; }
public string SellStrategy { get; set; } public string SellStrategy { get; set; }
public string BuyStrategy { get; set; } public string BuyStrategy { get; set; }
public double Leverage { get; set; }
public List<Strategy> BuyStrategies { get; set; } = new List<Strategy>(); public List<Strategy> BuyStrategies { get; set; } = new List<Strategy>();
public List<Strategy> SellStrategies { get; set; } = new List<Strategy>(); public List<Strategy> SellStrategies { get; set; } = new List<Strategy>();
} }

View File

@ -205,11 +205,7 @@ namespace Core.Main.DataObjects
public double GetCurrentBalance() public double GetCurrentBalance()
{ {
return return
(this.Summary.Balance + (this.Summary.Balance);
this.Summary.PairsValue +
this.Summary.DCAValue +
this.Summary.PendingValue +
this.Summary.DustValue);
} }
public double GetPairsBalance() public double GetPairsBalance()
{ {
@ -365,6 +361,7 @@ namespace Core.Main.DataObjects
dcaLogData.CurrentPrice = pair.currentPrice; dcaLogData.CurrentPrice = pair.currentPrice;
dcaLogData.SellTrigger = pair.triggerValue == null ? 0 : pair.triggerValue; dcaLogData.SellTrigger = pair.triggerValue == null ? 0 : pair.triggerValue;
dcaLogData.PercChange = pair.percChange; dcaLogData.PercChange = pair.percChange;
dcaLogData.Leverage = pair.leverage;
dcaLogData.BuyStrategy = pair.buyStrategy == null ? "" : pair.buyStrategy; dcaLogData.BuyStrategy = pair.buyStrategy == null ? "" : pair.buyStrategy;
dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy; dcaLogData.SellStrategy = pair.sellStrategy == null ? "" : pair.sellStrategy;
dcaLogData.IsTrailing = false; dcaLogData.IsTrailing = false;

View File

@ -26,18 +26,17 @@
<div class="card-box px-3" style="height:305px;"> <div class="card-box px-3" style="height:305px;">
<div class="cdev" data-percent="100" data-duration="@Html.Raw(@Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000)" data-color="#aaa,#414d59"></div> <div class="cdev" data-percent="100" data-duration="@Html.Raw(@Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000)" data-color="#aaa,#414d59"></div>
@{ @{
double currentBalance = Model.PTData.GetCurrentBalance(); string totalCurrentValueString = Model.totalCurrentValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"));
string currentBalanceString = currentBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); if (Model.totalCurrentValue > 100) {
if (currentBalance > 100) { totalCurrentValueString = Math.Round(Model.totalCurrentValue, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
currentBalanceString = Math.Round(currentBalance, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
} }
} }
<div class="text-center"><small>TCV: &nbsp; <text class="text-autocolor"> @currentBalanceString &nbsp; @Model.Summary.MainMarket &nbsp; </text> </small></div> <div class="text-center"><small>TCV: &nbsp; <text class="text-autocolor"> @totalCurrentValueString &nbsp; @Model.Summary.MainMarket &nbsp; </text> </small></div>
<div id="AssetDistribution"> <div id="AssetDistribution">
<svg style="height:230px;width:100%"></svg> <svg style="height:230px;width:100%"></svg>
<div class="text"> <div class="text">
<small>Start: &nbsp; <text class="text-autocolor"> @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket </text> <small>Start: &nbsp; <text class="text-autocolor"> @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket </text>
<text class="pull-right">Gain: &nbsp; <text class="text-autocolor"> @Math.Round(((currentBalance - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) %</text></small> <text class="pull-right">Gain: &nbsp; <text class="text-autocolor"> @Math.Round(((Model.totalCurrentValue - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) %</text></small>
</div> </div>
</div> </div>
</div> </div>

View File

@ -21,6 +21,7 @@ namespace Monitor.Pages {
public string currentBalanceString = ""; public string currentBalanceString = "";
public double TotalBagCost = 0; public double TotalBagCost = 0;
public double TotalBagValue = 0; public double TotalBagValue = 0;
public double totalCurrentValue = 0;
public void OnGet() { public void OnGet() {
// Initialize Config // Initialize Config
base.Init(); base.Init();
@ -160,24 +161,52 @@ namespace Monitor.Pages {
dcaEnabled = mps.IsDCAEnabled; dcaEnabled = mps.IsDCAEnabled;
} }
// Aggregate totals // Aggregate totals
if (sellStrategyText.Contains("PENDING")) if (dcaLogEntry.Leverage == 0)
{ {
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); if (sellStrategyText.Contains("PENDING"))
} {
else if (dcaEnabled) PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
{ }
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice); else if (dcaEnabled)
{
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
}
else
{
PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
}
} }
else 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 = "[";
AssetDistributionData += "{label: 'Pairs',color: '#82E0AA',value: '" + PairsBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'},"; 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: '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: '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")) + "'}]"; AssetDistributionData += "{label: 'Balance',color: '#85C1E9',value: '" + AvailableBalance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "'}]";
} }
} }
} }