Merge pull request #213 from HojouFotytu/develop
Changes to profit calculations
This commit is contained in:
commit
88644ef1d7
|
@ -59,16 +59,21 @@
|
|||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card-box">
|
||||
|
||||
<h4 class="m-t-0 header-title">Sales Analysis</h4>
|
||||
|
||||
@{
|
||||
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 = "<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>";
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
<h4 class="m-t-0 header-title">Balance Prediction <small><i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The balance prediction is based on your daily average gain of @avgDailyGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% and your current approximate balance of @currentTotalBalance.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))"></i></small></h4>
|
||||
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -188,7 +191,6 @@
|
|||
<div class="col-md-6">
|
||||
<div class="card-box">
|
||||
<h4 class="m-t-0 header-title">Last @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries days</h4>
|
||||
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -202,7 +204,15 @@
|
|||
<tbody>
|
||||
@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<Core.Main.DataObjects.PTMagicData.SellLogData> 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<Core.Main.DataObjects.PTMagicData.SellLogData> 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<Core.Main.DataObjects.PTMagicData.SellLogData> 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 @@
|
|||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="card-box">
|
||||
|
||||
<h4 class="m-t-0 header-title"><b>Top @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets Sales Market Analysis</b></h4>
|
||||
|
||||
<table class="tablesaw table m-b-0" data-tablesaw-sortable data-tablesaw-sortable-switch>
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -296,6 +319,10 @@
|
|||
<tbody>
|
||||
@{
|
||||
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<string, double> 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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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<string, double> topMarketsDic = new Dictionary<string, double>();
|
||||
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<string, double>(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',";
|
||||
|
@ -116,27 +123,39 @@ namespace Monitor.Pages
|
|||
for (DateTime salesDate = DateTimeNow.DateTime.Date; salesDate >= MinSellLogDate; salesDate = salesDate.AddDays(-1))
|
||||
{
|
||||
List<SellLogData> 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<Core.Main.DataObjects.PTMagicData.SellLogData> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-5 px-1">
|
||||
<div class="cdev" data-percent="100" data-duration="@Html.Raw(@Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000)" data-color="#aaa,#414d59"></div>
|
||||
<div class="card-box px-2" style="height:305px;">
|
||||
|
@ -109,7 +110,16 @@
|
|||
<br>
|
||||
<h4 class="m-t-0 m-b-20 header-title"><b>Sales Overview</b><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)SalesAnalyzer">more</a></small></h4>
|
||||
@{
|
||||
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 = "<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>";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<div class="col-md-5 px-1">
|
||||
<div class="card-box px-2">
|
||||
<h4 class="m-t-0 m-b-20 header-title"><b>Possible Buys (@Model.PTData.BuyLog.Count)</b><small id="buylist-refresh-icon"></small><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BuyAnalyzer">more</a></small></h4>
|
||||
@if (Model.PTData.BuyLog.Count == 0) {
|
||||
|
||||
@if (Model.PTData.BuyLog.Count == 0)
|
||||
{
|
||||
<p>Your Profit Trailer did not find anything worth buying so far.</p>
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm m-b-0">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -31,9 +31,9 @@
|
|||
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)) {
|
||||
if (Model.Summary.MarketSummary.ContainsKey(buyLogEntry.Market))
|
||||
{
|
||||
mps = Model.Summary.MarketSummary[buyLogEntry.Market];
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
<tr @(lostValue ? "class=errorRow" : "") >
|
||||
@if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) {
|
||||
@if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0)
|
||||
{
|
||||
<th class="align-top"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, dcaLogEntry.Market, Model.Summary.MainMarket)" target="_blank">@dcaLogEntry.Market</a></th>
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
<th class="align-top"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, dcaLogEntry.Market, Model.Summary.MainMarket)" target="_blank">@dcaLogEntry.Market</a> <i class="fa fa-exclamation-triangle text-highlight" data-toggle="tooltip" data-placement="top" data-html="true" title="@await Component.InvokeAsync("PairIcon", mps)" data-template="<div class='tooltip' role='tooltip'><div class='tooltip-arrow'></div><div class='tooltip-inner pair-tooltip'></div></div>"></i></th>
|
||||
}
|
||||
|
||||
<td class="text-autocolor">@Html.Raw((dcaLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))%</td>
|
||||
|
||||
<td class="text-left">@Html.Raw(dcaLogEntry.TotalCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))</td>
|
||||
|
||||
<td class="text-right">
|
||||
@if (dcaEnabled) {
|
||||
@if (dcaLogEntry.BoughtTimes > 0) {
|
||||
@if (dcaEnabled)
|
||||
{
|
||||
@if (dcaLogEntry.BoughtTimes > 0)
|
||||
{
|
||||
@dcaLogEntry.BoughtTimes;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
<span data-toggle="tooltip" data-placement="top" title="DCA is disabled"><i class="fa fa-ban text-highlight"></i></span>
|
||||
}
|
||||
</td>
|
||||
<td>@Html.Raw(buyStrategyText)</td>
|
||||
<td>@Html.Raw(sellStrategyText)</td>
|
||||
|
||||
|
||||
@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)
|
||||
{
|
||||
<td class="@Html.Raw((dcaLogEntry.TargetGainValue.HasValue && (dcaLogEntry.ProfitPercent > dcaLogEntry.TargetGainValue.Value)) ? "text-success" : "text-danger")">@Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? dcaLogEntry.TargetGainValue.Value.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ")</td>
|
||||
}
|
||||
|
@ -233,7 +228,6 @@
|
|||
double leverageTargetGain = leverageValue * dcaLogEntry.TargetGainValue.Value;
|
||||
<td class="@Html.Raw((dcaLogEntry.TargetGainValue.HasValue && (dcaLogEntry.ProfitPercent > dcaLogEntry.TargetGainValue.Value)) ? "text-success" : "text-danger")">@Html.Raw(dcaLogEntry.TargetGainValue.HasValue ? leverageTargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%" : " ")</td>
|
||||
}
|
||||
|
||||
@if (!@lostValue)
|
||||
{
|
||||
<td class="text-autocolor">@dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td>
|
||||
|
@ -242,11 +236,9 @@
|
|||
{
|
||||
<td class="text-left">No Value!</td>
|
||||
}
|
||||
|
||||
<td class="text-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/BagDetails/?m=@dcaLogEntry.Market" data-remote="false" data-toggle="modal" data-target="#dca-chart"><i class="fa fa-plus-circle"></i></a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
<td>Totals:</td>
|
||||
<td></td>
|
||||
<td>@Html.Raw(Model.TotalBagCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))</td>
|
||||
|
@ -254,13 +246,10 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
<td class="text-autocolor">@Html.Raw( (((Model.TotalBagValue - Model.TotalBagCost) / Model.TotalBagCost) * 100).ToString("#0.00", new System.Globalization.CultureInfo("en-US")))%</td>
|
||||
|
||||
<td class="text-autocolor">@Html.Raw((((Model.TotalBagGain) / Model.TotalBagCost) * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))%</td>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if (Model.PTData.DCALog.Count > Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries) {
|
||||
<p class="text-right"><small><i class="fa fa-info-circle"></i> @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries of @Model.PTData.DCALog.Count items listed - <a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BagAnalyzer">View all items</a></small></p>
|
||||
}
|
||||
|
@ -270,11 +259,9 @@
|
|||
</div>
|
||||
|
||||
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/js/jquery.nicescroll.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
$("#dca-chart").on("show.bs.modal", function (e) {
|
||||
$(this).find(".modal-content").html('<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>');
|
||||
var link = $(e.relatedTarget);
|
||||
|
@ -283,7 +270,5 @@
|
|||
$('[data-toggle="tooltip"]').tooltip();
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue