PTMagic/Monitor/Pages/_get/DashboardTop.cshtml

288 lines
17 KiB
Plaintext
Raw Normal View History

2018-05-22 10:11:50 +02:00
@page
@model DashboardTopModel
@{
Layout = null;
}
@{
bool sideBySide = true;
}
<div class="@(sideBySide ? "row" : "col-md-12")">
2021-10-19 09:13:50 +02:00
@if (Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries>0)
{
<div class="col-md 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"><i class="fa fa-info-circle text-muted" style="font-size x-small" data-toggle="tooltip" data-placement="top" title="Set 'Max Dashboard Buy Entries' to zero in Monitor Settings, to hide this table."></i></small><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BuyAnalyzer">more</a></small></h4>
2020-07-26 16:28:37 +02:00
@if (Model.PTData.BuyLog.Count == 0)
{
2018-05-22 10:11:50 +02:00
<p>Your Profit Trailer did not find anything worth buying so far.</p>
2020-07-26 16:28:37 +02:00
}
else
{
2018-05-22 10:11:50 +02:00
<table class="table table-sm m-b-0">
<thead>
<tr>
<th><strong>Market </strong><i class="fa fa-info-circle text-muted" style="font-size: x-small" data-toggle="tooltip" data-placement="top" title="Market and 24h CHANGE"></i></th>
<th><strong>Volume </strong><i class="fa fa-info-circle text-muted" style="font-size: x-small" data-toggle="tooltip" data-placement="top" title="24h VOLUME"></i></th>
<th><strong>Ask </strong></th>
<th><strong>Buy Strategies </strong></th>
2018-05-22 10:11:50 +02:00
</tr>
</thead>
<tbody>
2020-07-26 16:28:37 +02:00
@foreach (Core.Main.DataObjects.PTMagicData.BuyLogData buyLogEntry in Model.PTData.BuyLog.OrderBy(b => b.IsSom).
ThenByDescending(b => b.IsTrailing).
ThenByDescending(b => b.IsTrue).
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))
{
mps = Model.Summary.MarketSummary[buyLogEntry.Market];
}
2020-07-26 16:28:37 +02:00
bool isTrailingBuyActive = buyLogEntry.IsTrailing;
if (buyLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (buyLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
2018-05-22 10:11:50 +02:00
2020-07-26 16:28:37 +02:00
bool isBuyStrategyTrue = buyLogEntry.IsTrue;
if (buyLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (buyLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
2018-05-22 10:11:50 +02:00
2020-07-26 16:28:37 +02:00
bool buyDisabled = false;
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, buyLogEntry.BuyStrategies, buyLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
2020-07-23 20:28:19 +02:00
2020-07-26 16:28:37 +02:00
<tr>
@if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0) {
<th>
<span style="font-size: 1.3em;"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, buyLogEntry.Market, Model.Summary.MainMarket, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@buyLogEntry.Market</span>
<br><span class="text-autocolor">@Html.Raw((buyLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))) % </span>
</th>
2020-07-26 16:28:37 +02:00
} else {
<th>
<div style="white-space: nowrap;">
<span style="font-size: 1.3em;"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, buyLogEntry.Market, Model.Summary.MainMarket, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@buyLogEntry.Market</a></span>
&nbsp;<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>
</div>
<span class="text-autocolor">@Html.Raw((buyLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))) % </span>
</th>
2020-07-26 16:28:37 +02:00
}
<td >@string.Format("{0}", (buyLogEntry.Volume24h).ToString())</td>
<td >@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2020-07-26 16:28:37 +02:00
@if (buyDisabled) {
<td>@Html.Raw(buyStrategyText)</td>
} else {
<td>@Html.Raw(buyStrategyText)</td>
}
</tr>
}
2018-05-22 10:11:50 +02:00
</tbody>
</table>
@if (Model.PTData.BuyLog.Count > Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries) {
<p class="text-right"><small><i class="fa fa-info-circle"></i> @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries of @Model.PTData.BuyLog.Count items listed - <a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BuyAnalyzer">View all items</a></small></p>
}
}
</div>
</div>
2021-10-19 09:13:50 +02:00
}
<div class="col-md px-1">
<div class="card-box px-2">
<h4 class="m-t-0 m-b-20 header-title"><b>Positions (@Model.PTData.DCALog.Count)</b><small id="baglist-refresh-icon"></small><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BagAnalyzer">more</a></small></h4>
2018-05-22 10:11:50 +02:00
@if (Model.PTData.DCALog.Count == 0)
{
2019-05-04 14:11:29 +02:00
<p>Profit Trailer is not reporting any holdings on your exchange.</p>
}
else
{
<div class="table-responsive">
<table class="table table-sm m-b-0 table-auto-width">
<thead>
<tr>
<th><strong>Market </strong><i class="fa fa-info-circle text-muted" style="font-size: x-small" data-toggle="tooltip" data-placement="top" title="Market and 24h CHANGE"></i></th>
<th><strong>Cost </strong><i class="fa fa-info-circle text-muted" style="font-size: x-small" data-toggle="tooltip" data-placement="top" title="Total COST and TIME HELD"></i></th>
<th></th>
<th><strong>DCA </strong></th>
<th><strong>Sell </strong></th>
<th><strong>Profit </strong><i class="fa fa-info-circle text-muted" style="font-size: x-small" data-toggle="tooltip" data-placement="top" title="Proft TARGET and CURRENT Profit"></i></th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in Model.PTData.DCALog.OrderByDescending(d => d.ProfitPercent).Take(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries)) {
// Loop through the pairs preparing the data for display
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null;
2023-06-26 10:23:47 +02:00
if (Model.Summary.MarketSummary.ContainsKey(dcaLogEntry.Market)) {
mps = Model.Summary.MarketSummary[dcaLogEntry.Market];
}
2018-05-22 10:11:50 +02:00
string bagAgeText = Core.Helper.SystemHelper.GetProperDurationTime((int)Math.Ceiling(Model.DateTimeNow.Subtract(dcaLogEntry.FirstBoughtDate).TotalSeconds), true, true);
bool dcaEnabled = true;
if (mps != null) {
dcaEnabled = mps.IsDCAEnabled;
}
2018-05-22 10:11:50 +02:00
bool isTrailingBuyActive = dcaLogEntry.IsTrailing;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
}
bool isBuyStrategyTrue = dcaLogEntry.IsTrue;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
2018-05-22 10:11:50 +02:00
bool isTrailingSellActive = false;
if (dcaLogEntry.SellStrategies.Count > 0) {
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0);
}
bool isSellStrategyTrue = false;
2020-03-25 19:02:59 +01:00
if (dcaLogEntry.SellStrategies.Count > 0) {
isSellStrategyTrue = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0);
}
2020-07-17 12:26:33 +02:00
string leverage = "";
2020-07-26 16:28:37 +02:00
double leverageValue = 1;
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
2020-07-19 05:02:01 +02:00
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
2020-07-17 12:30:42 +02:00
// Check for when PT loses the value of a pair
bool lostValue = false;
2023-06-26 10:23:47 +02:00
lostValue = !(sellStrategyText.Contains("WATCHMODE")) && !(sellStrategyText.Contains("PENDING")) && ((dcaLogEntry.TotalCost == 0.0) || (dcaLogEntry.AverageBuyPrice == 0.0));
// Profit percentage
var profitPercentage = dcaLogEntry.ProfitPercent;
2020-07-26 16:28:37 +02:00
// Render the row
if (!sellStrategyText.Contains("PENDING-BUY"))
2023-06-26 10:23:47 +02:00
{
<tr @(lostValue ? "class=errorRow" : "") >
<!-- Market -->
2021-03-03 07:23:42 +01:00
<td class="align-top; text-nowrap">
2021-03-01 15:16:13 +01:00
<b>
@if (mps == null || mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0)
{
<span style="font-size: 1.3em;"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, dcaLogEntry.Market, Model.Summary.MainMarket, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@dcaLogEntry.Market</a></span>
2021-03-01 15:16:13 +01:00
} else
{
<span style="font-size: 1.3em;"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, dcaLogEntry.Market, Model.Summary.MainMarket, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@dcaLogEntry.Market &nbsp;</a></span><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>
2021-03-01 15:16:13 +01:00
}
</b>
<br><span class="text-autocolor">@Html.Raw((dcaLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))) %</span>
2021-03-01 15:16:13 +01:00
</td>
<!-- Cost -->
<td class="text-left">@Html.Raw(dcaLogEntry.TotalCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))<br><span class="text-highlight">@bagAgeText</span></td>
<!-- DCA Count -->
<td class="text-right">
2020-07-26 16:28:37 +02:00
@if (dcaEnabled)
{
if (dcaLogEntry.BoughtTimes > 0)
2020-07-26 16:28:37 +02:00
{
@dcaLogEntry.BoughtTimes;
}
2020-07-26 16:28:37 +02:00
} else
{
<span data-toggle="tooltip" data-placement="top" title="DCA disabled"><i class="fa fa-ban text-highlight"></i></span>
}
</td>
<!-- DCA Strategy -->
<td>@Html.Raw(buyStrategyText)</td>
<!-- Sell Strategy -->
<td>@Html.Raw(sellStrategyText)</td>
2021-04-21 12:29:42 +02:00
<!-- Target/Profit -->
@if (!@lostValue)
2020-07-26 16:28:37 +02:00
{
2023-06-26 10:23:47 +02:00
//@if (!sellStrategyText.Contains("WATCHMODE"))
//{
2021-04-21 12:29:42 +02:00
@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);
}
2023-06-26 10:23:47 +02:00
//profitPercentage = profitPercentage * leverageValue;
@if ( !(sellStrategyText.Contains("WATCHMODE")) && !(sellStrategyText.Contains("PENDING")))
{
double TargetGain = leverageValue * dcaLogEntry.TargetGainValue.GetValueOrDefault();
2023-06-26 10:23:47 +02:00
<td>@TargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%
<br>
2024-01-27 18:39:47 +01:00
<div class="text-autocolor" style="font-size: 1.2em; white-space: nowrap;">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</div>
2023-06-26 10:23:47 +02:00
</td>
}
else
{
<td>
<div class="text-left">None</div>
<br>
<div class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</div>
2023-06-26 10:23:47 +02:00
</td>
}
//}
2021-04-21 12:29:42 +02:00
}
else
{
2023-06-26 10:23:47 +02:00
<td class="text-left">Lost Value!</td>
}
<!-- Bag details -->
<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>
{
// Aggregate totals
double bagGain = (profitPercentage / 100) * dcaLogEntry.TotalCost;
Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost;
Model.TotalBagGain = Model.TotalBagGain + bagGain;
}
2023-06-26 10:23:47 +02:00
}
}
<td style="font-size: 1.2em;"><strong>Totals:</strong></td>
<td style="font-size: 1.2em;"><strong>@Html.Raw(Model.TotalBagCost.ToString("#,#0.000000", new System.Globalization.CultureInfo("en-US")))</strong></td>
<td></td>
<td></td>
<td></td>
<td class="text-autocolor; font-size: 1.2em;"><strong>@Html.Raw((((Model.TotalBagGain) / Model.TotalBagCost) * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))) %</strong></td>
<td></td>
</tbody>
</table>
</div>
2018-05-22 10:11:50 +02:00
@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>
}
}
</div>
</div>
</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);
$(this).find(".modal-content").load(link.attr("href"), function () {
$('.text-autocolor').autocolor(false);
$('[data-toggle="tooltip"]').tooltip();
});
});
})(jQuery);
</script>