Fix PairsBalance
This commit is contained in:
parent
94e8edd61f
commit
09099a47cd
|
@ -361,7 +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.Leverage = pair.leverage == null ? 0 : 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;
|
||||||
|
|
|
@ -107,7 +107,8 @@
|
||||||
double totalProfitFiat = Math.Round(totalProfit * Model.Summary.MainMarketPrice, 2);
|
double totalProfitFiat = Math.Round(totalProfit * Model.Summary.MainMarketPrice, 2);
|
||||||
double percentGain = Math.Round(totalProfit / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance * 100, 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")) + "%";
|
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 = "<i class=\"fa fa-info-circle text-muted\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"You have added at least one manual transaction, so the total gain percentage cannot be calculated.\"></i>";
|
percentGainText = "<i class=\"fa fa-info-circle text-muted\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"You have added at least one manual transaction, so the total gain percentage cannot be calculated.\"></i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,12 +206,10 @@
|
||||||
.donut(true) //Turn on Donut mode. Makes pie chart look tasty!
|
.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.
|
.donutRatio(0.3) //Configure how big you want the donut hole size to be.
|
||||||
;
|
;
|
||||||
|
|
||||||
d3.select("#AssetDistribution svg")
|
d3.select("#AssetDistribution svg")
|
||||||
.datum(@Html.Raw(Model.AssetDistributionData))
|
.datum(@Html.Raw(Model.AssetDistributionData))
|
||||||
.transition().duration(350)
|
.transition().duration(350)
|
||||||
.call(chart);
|
.call(chart);
|
||||||
|
|
||||||
return chart;
|
return chart;
|
||||||
});
|
});
|
||||||
</text>
|
</text>
|
||||||
|
@ -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)".');
|
$.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)".');
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!Model.TrendChartDataJSON.Equals("")) {
|
@if (!Model.TrendChartDataJSON.Equals("")) {
|
||||||
<text>
|
<text>
|
||||||
nv.addGraph(function () {
|
nv.addGraph(function () {
|
||||||
|
@ -244,7 +242,6 @@
|
||||||
});
|
});
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!Model.ProfitChartDataJSON.Equals("")) {
|
@if (!Model.ProfitChartDataJSON.Equals("")) {
|
||||||
<text>
|
<text>
|
||||||
nv.addGraph(function () {
|
nv.addGraph(function () {
|
||||||
|
@ -256,7 +253,6 @@
|
||||||
lineChart.yAxis.axisLabel('Daily Profit').tickFormat(d3.format(',.2f'));
|
lineChart.yAxis.axisLabel('Daily Profit').tickFormat(d3.format(',.2f'));
|
||||||
d3.select('.profit-chart svg').attr('perserveAspectRatio', 'xMinYMid').datum(chartData).transition().duration(500).call(lineChart);
|
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
|
//nv.utils.windowResize(lineChart.update); v1.3.0 => Removed this line to prevent memory leak
|
||||||
|
|
||||||
return lineChart;
|
return lineChart;
|
||||||
});
|
});
|
||||||
</text>
|
</text>
|
||||||
|
|
|
@ -52,7 +52,6 @@ namespace Monitor.Pages {
|
||||||
BuildMarketTrendChartData();
|
BuildMarketTrendChartData();
|
||||||
BuildProfitChartData();
|
BuildProfitChartData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildMarketTrendChartData() {
|
private void BuildMarketTrendChartData() {
|
||||||
if (MarketTrends.Count > 0) {
|
if (MarketTrends.Count > 0) {
|
||||||
TrendChartDataJSON = "[";
|
TrendChartDataJSON = "[";
|
||||||
|
@ -99,13 +98,10 @@ namespace Monitor.Pages {
|
||||||
MarketTrendChange mtc = latestTickRange.First();
|
MarketTrendChange mtc = latestTickRange.First();
|
||||||
if (trendChartTicks > 0) TrendChartDataJSON += ",\n";
|
if (trendChartTicks > 0) TrendChartDataJSON += ",\n";
|
||||||
if (Double.IsInfinity(mtc.TrendChange)) mtc.TrendChange = 0;
|
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 += "{ 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 += "]";
|
||||||
TrendChartDataJSON += "}";
|
TrendChartDataJSON += "}";
|
||||||
|
|
||||||
mtIndex++;
|
mtIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +139,7 @@ namespace Monitor.Pages {
|
||||||
}
|
}
|
||||||
private void BuildAssetDistributionData()
|
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 PairsBalance = 0.0;
|
||||||
double DCABalance = 0.0;
|
double DCABalance = 0.0;
|
||||||
double PendingBalance = 0.0;
|
double PendingBalance = 0.0;
|
||||||
|
@ -152,14 +149,9 @@ namespace Monitor.Pages {
|
||||||
|
|
||||||
foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog)
|
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;
|
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null;
|
||||||
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
|
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
|
||||||
bool dcaEnabled = true;
|
|
||||||
if (mps != null)
|
|
||||||
{
|
|
||||||
dcaEnabled = mps.IsDCAEnabled;
|
|
||||||
}
|
|
||||||
// Aggregate totals
|
// Aggregate totals
|
||||||
if (dcaLogEntry.Leverage == 0)
|
if (dcaLogEntry.Leverage == 0)
|
||||||
{
|
{
|
||||||
|
@ -167,7 +159,7 @@ namespace Monitor.Pages {
|
||||||
{
|
{
|
||||||
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
||||||
}
|
}
|
||||||
else if (dcaEnabled)
|
else if (dcaLogEntry.BuyStrategies.Count > 0)
|
||||||
{
|
{
|
||||||
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +174,7 @@ namespace Monitor.Pages {
|
||||||
{
|
{
|
||||||
PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
|
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);
|
DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
|
||||||
}
|
}
|
||||||
|
@ -191,22 +183,13 @@ namespace Monitor.Pages {
|
||||||
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
|
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalCurrentValue = PendingBalance + DCABalance + PairsBalance + AvailableBalance;
|
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")) + "'}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue