Fixed UI issues, exposed buy volume data

This commit is contained in:
djbadders 2020-07-21 22:29:07 +01:00
parent eff9dc03ad
commit 7f8846cd6a
5 changed files with 69 additions and 44 deletions

View File

@ -486,6 +486,7 @@ namespace Core.Main.DataObjects.PTMagicData
public double CurrentPrice { get; set; }
public int BoughtTimes { get; set; }
public double PercChange { get; set; }
public double Volume24h { get; set; }
public List<Strategy> BuyStrategies { get; set; } = new List<Strategy>();
}

View File

@ -453,6 +453,7 @@ namespace Core.Main.DataObjects
buyLogData.ProfitPercent = rbld.profit;
buyLogData.CurrentPrice = rbld.currentPrice;
buyLogData.PercChange = rbld.percChange;
buyLogData.Volume24h = rbld.volume;
if (rbld.positive != null)
{

View File

@ -30,13 +30,15 @@
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: &nbsp; <text class="text-autocolor"> @totalCurrentValueString &nbsp; @Model.Summary.MainMarket &nbsp; </text> </small></div>
<div id="AssetDistribution">
<svg style="height:230px;width:100%"></svg>
<div class="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(((Model.totalCurrentValue - Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) / Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance) * 100, 2) %</text></small>
}
<div id="AssetDistribution" class="container">
<div class="row px1">
<div class="col-3 px-1 text-center"><small>Start:&nbsp;<text class="text-autocolor">@Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance @Model.Summary.MainMarket</text></small></div>
<div class="col-6 px-1 text-center"><small>TCV:&nbsp;<text class="text-autocolor">@totalCurrentValueString @Model.Summary.MainMarket</text></small></div>
<div class="col-3 px-1 text-center"><small>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 class="row px1">
<svg style="height:260px;width:100%"></svg>
</div>
</div>
</div>

View File

@ -8,8 +8,10 @@ using Core.Main.DataObjects;
using Core.Main.DataObjects.PTMagicData;
using Core.MarketAnalyzer;
namespace Monitor.Pages {
public class DashboardBottomModel : _Internal.BasePageModelSecureAJAX {
namespace Monitor.Pages
{
public class DashboardBottomModel : _Internal.BasePageModelSecureAJAX
{
public ProfitTrailerData PTData = null;
public List<MarketTrend> MarketTrends { get; set; } = new List<MarketTrend>();
public string TrendChartDataJSON = "";
@ -22,7 +24,8 @@ namespace Monitor.Pages {
public double TotalBagCost = 0;
public double TotalBagValue = 0;
public double totalCurrentValue = 0;
public void OnGet() {
public void OnGet()
{
// Initialize Config
base.Init();
@ -30,7 +33,8 @@ namespace Monitor.Pages {
BuildAssetDistributionData();
}
private void BindData() {
private void BindData()
{
PTData = this.PtDataObject;
// Cleanup temp files
@ -41,7 +45,8 @@ namespace Monitor.Pages {
DateTimeNow = DateTimeOffset.UtcNow.ToOffset(offsetTimeSpan);
// Get last and current active setting
if (!String.IsNullOrEmpty(HttpContext.Session.GetString("LastGlobalSetting"))) {
if (!String.IsNullOrEmpty(HttpContext.Session.GetString("LastGlobalSetting")))
{
LastGlobalSetting = HttpContext.Session.GetString("LastGlobalSetting");
}
HttpContext.Session.SetString("LastGlobalSetting", Summary.CurrentGlobalSetting.SettingName);
@ -52,23 +57,32 @@ namespace Monitor.Pages {
BuildMarketTrendChartData();
BuildProfitChartData();
}
private void BuildMarketTrendChartData() {
if (MarketTrends.Count > 0) {
private void BuildMarketTrendChartData()
{
if (MarketTrends.Count > 0)
{
TrendChartDataJSON = "[";
int mtIndex = 0;
foreach (MarketTrend mt in MarketTrends) {
if (mt.DisplayGraph) {
foreach (MarketTrend mt in MarketTrends)
{
if (mt.DisplayGraph)
{
string lineColor = "";
if (mtIndex < Constants.ChartLineColors.Length) {
if (mtIndex < Constants.ChartLineColors.Length)
{
lineColor = Constants.ChartLineColors[mtIndex];
} else {
}
else
{
lineColor = Constants.ChartLineColors[mtIndex - 20];
}
if (Summary.MarketTrendChanges.ContainsKey(mt.Name)) {
if (Summary.MarketTrendChanges.ContainsKey(mt.Name))
{
List<MarketTrendChange> marketTrendChangeSummaries = Summary.MarketTrendChanges[mt.Name];
if (marketTrendChangeSummaries.Count > 0) {
if (marketTrendChangeSummaries.Count > 0)
{
if (!TrendChartDataJSON.Equals("[")) TrendChartDataJSON += ",";
TrendChartDataJSON += "{";
@ -81,9 +95,11 @@ namespace Monitor.Pages {
DateTime startDateTime = currentDateTime.AddHours(-PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours);
DateTime endDateTime = currentDateTime;
int trendChartTicks = 0;
for (DateTime tickTime = startDateTime; tickTime <= endDateTime; tickTime = tickTime.AddMinutes(PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes)) {
for (DateTime tickTime = startDateTime; tickTime <= endDateTime; tickTime = tickTime.AddMinutes(PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes))
{
List<MarketTrendChange> tickRange = marketTrendChangeSummaries.FindAll(m => m.TrendDateTime >= tickTime).OrderBy(m => m.TrendDateTime).ToList();
if (tickRange.Count > 0) {
if (tickRange.Count > 0)
{
MarketTrendChange mtc = tickRange.First();
if (tickTime != startDateTime) TrendChartDataJSON += ",\n";
if (Double.IsInfinity(mtc.TrendChange)) mtc.TrendChange = 0;
@ -94,7 +110,8 @@ namespace Monitor.Pages {
}
// Add most recent tick
List<MarketTrendChange> latestTickRange = marketTrendChangeSummaries.OrderByDescending(m => m.TrendDateTime).ToList();
if (latestTickRange.Count > 0) {
if (latestTickRange.Count > 0)
{
MarketTrendChange mtc = latestTickRange.First();
if (trendChartTicks > 0) TrendChartDataJSON += ",\n";
if (Double.IsInfinity(mtc.TrendChange)) mtc.TrendChange = 0;
@ -111,15 +128,19 @@ namespace Monitor.Pages {
}
}
private void BuildProfitChartData() {
private void BuildProfitChartData()
{
int tradeDayIndex = 0;
string profitPerDayJSON = "";
if (PTData.SellLog.Count > 0) {
if (PTData.SellLog.Count > 0)
{
DateTime minSellLogDate = PTData.SellLog.OrderBy(sl => sl.SoldDate).First().SoldDate.Date;
DateTime graphStartDate = DateTime.UtcNow.Date.AddDays(-30);
if (minSellLogDate > graphStartDate) graphStartDate = minSellLogDate;
for (DateTime salesDate = graphStartDate; salesDate <= DateTime.UtcNow.Date; salesDate = salesDate.AddDays(1)) {
if (tradeDayIndex > 0) {
for (DateTime salesDate = graphStartDate; salesDate <= DateTime.UtcNow.Date; salesDate = salesDate.AddDays(1))
{
if (tradeDayIndex > 0)
{
profitPerDayJSON += ",\n";
}
int trades = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate).Count;
@ -144,10 +165,10 @@ namespace Monitor.Pages {
double DCABalance = 0.0;
double PendingBalance = 0.0;
double AvailableBalance = PTData.GetCurrentBalance();
bool isSellStrategyTrue =false;
bool isTrailingSellActive =false;
foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog)
bool isSellStrategyTrue = false;
bool isTrailingSellActive = false;
foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog)
{
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null;
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
@ -157,30 +178,30 @@ namespace Monitor.Pages {
{
if (sellStrategyText.Contains("PENDING"))
{
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
}
else if (dcaLogEntry.BuyStrategies.Count > 0)
else if (dcaLogEntry.BuyStrategies.Count > 0)
{
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
}
else
{
PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
}
}
else
{
if (sellStrategyText.Contains("PENDING"))
{
PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
}
else if (dcaLogEntry.BuyStrategies.Count > 0)
else if (dcaLogEntry.BuyStrategies.Count > 0)
{
DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
}
else
{
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage);
}
}
}

View File

@ -18,9 +18,9 @@
<thead>
<tr>
<th>Market</th>
<th class="text-right" data-toggle="tooltip" data-placement="top" title="Current ask price for this market">Ask</th>
<th class="text-right" data-toggle="tooltip" data-placement="top" title="Current Volume">Volume</th>
<th class="text-right" data-toggle="tooltip" data-placement="top" title="24 Hour Trend">24H</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="Current ask price for this market">Ask</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="Current Volume">Volume</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="24 Hour Trend">24H</th>
<th>Buy Strategies</th>
</tr>
</thead>
@ -59,8 +59,8 @@
} else {
<th class="align-top"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, buyLogEntry.Market, Model.Summary.MainMarket)" target="_blank">@buyLogEntry.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-right">@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text">@string.Format("{0}", (buyLogEntry.Volume).ToString())</td>
<td class="text-left">@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text">@string.Format("{0}", (buyLogEntry.Volume24h).ToString())</td>
<td class="text-autocolor">@string.Format("{0}%", (buyLogEntry.PercChange * 100).ToString("#,#0.00"))</td>
@if (buyDisabled) {
<td>@Html.Raw(buyStrategyText)</td>