Current Balance Calculation
This commit is contained in:
parent
4fc5fa6e51
commit
94e8edd61f
|
@ -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<Strategy> BuyStrategies { get; set; } = new List<Strategy>();
|
||||
public List<Strategy> SellStrategies { get; set; } = new List<Strategy>();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -26,18 +26,17 @@
|
|||
<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>
|
||||
@{
|
||||
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"));
|
||||
}
|
||||
}
|
||||
<div class="text-center"><small>TCV: <text class="text-autocolor"> @currentBalanceString @Model.Summary.MainMarket </text> </small></div>
|
||||
<div class="text-center"><small>TCV: <text class="text-autocolor"> @totalCurrentValueString @Model.Summary.MainMarket </text> </small></div>
|
||||
<div id="AssetDistribution">
|
||||
<svg style="height:230px;width:100%"></svg>
|
||||
<div class="text">
|
||||
<small>Start: <text class="text-autocolor"> @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket </text>
|
||||
<text class="pull-right">Gain: <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: <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>
|
||||
|
|
|
@ -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")) + "'}]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue