PTMagic/Monitor/Pages/_get/BagList.cshtml

178 lines
8.1 KiB
Plaintext
Raw Permalink Normal View History

2018-05-22 10:11:50 +02:00
@page
@model BagListModel
@{
Layout = null;
System.Reflection.PropertyInfo propertyInfo = typeof(Core.Main.DataObjects.PTMagicData.DCALogData).GetProperty(Model.SortFieldId);
List<Core.Main.DataObjects.PTMagicData.DCALogData> dcaLogResult = Model.PTData.DCALog.OrderByDescending(d => propertyInfo.GetValue(d, null)).ToList();
if (Model.SortDirection.Equals("ASC")) {
dcaLogResult = Model.PTData.DCALog.OrderBy(d => propertyInfo.GetValue(d, null)).ToList();
}
}
@foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in dcaLogResult) {
// Loop through the pairs preparing the data for display
2018-05-22 10:11:50 +02:00
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null;
if (Model.Summary.MarketSummary.ContainsKey(dcaLogEntry.Market)) {
mps = Model.Summary.MarketSummary[dcaLogEntry.Market];
}
int nextBuyTrigger = dcaLogEntry.BoughtTimes + 1;
double nextBuyTriggerPercent = 0;
if (Model.Summary.DCATriggers.Count >= nextBuyTrigger) {
nextBuyTriggerPercent = Model.Summary.DCATriggers[nextBuyTrigger];
}
bool buyDisabled = false;
string buyTriggerText = dcaLogEntry.BuyTriggerPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%";
if (mps != null) {
if (!mps.IsDCAEnabled) {
nextBuyTriggerPercent = 0;
buyDisabled = true;
buyTriggerText = "";
} else {
if (dcaLogEntry.BuyTriggerPercent == 0) {
dcaLogEntry.BuyTriggerPercent = dcaLogEntry.ProfitPercent;
}
}
} else {
buyDisabled = dcaLogEntry.BuyStrategy == null;
if (dcaLogEntry.BuyTriggerPercent == 0) {
dcaLogEntry.BuyTriggerPercent = dcaLogEntry.ProfitPercent;
}
}
bool isTrailingBuyActive = dcaLogEntry.IsTrailing;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isTrailingBuyActive = (dcaLogEntry.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0);
2018-05-22 10:11:50 +02:00
}
bool isBuyStrategyTrue = dcaLogEntry.IsTrue;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isBuyStrategyTrue = (dcaLogEntry.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0);
}
string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive);
2018-05-22 10:11:50 +02:00
if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) {
buyDisabled = true;
}
string currentBuyValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, dcaLogEntry.CurrentLowBBValue, dcaLogEntry.BuyTriggerPercent, true);
string triggerBuyValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, dcaLogEntry.BuyStrategies, dcaLogEntry.BuyStrategy, dcaLogEntry.BBTrigger, Core.Main.Constants.MinTrendChange, dcaLogEntry.BoughtTimes, true);
bool isTrailingSellActive = false;
if (dcaLogEntry.SellStrategies.Count > 0) {
isTrailingSellActive = (dcaLogEntry.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0);
}
bool isSellStrategyTrue = false;
if (dcaLogEntry.BuyStrategies.Count > 0) {
isSellStrategyTrue = (dcaLogEntry.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0);
2018-05-22 10:11:50 +02:00
}
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
2018-05-22 10:11:50 +02:00
string currentSellValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, dcaLogEntry.CurrentHighBBValue, dcaLogEntry.ProfitPercent, true);
string triggerSellValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, dcaLogEntry.BBTrigger, dcaLogEntry.SellTrigger, 0, true);
double currentFiatValue = Math.Round(dcaLogEntry.Amount * dcaLogEntry.CurrentPrice * Model.Summary.MainMarketPrice, 2);
// Check for when PT loses the value of a pair
bool lostValue = false;
lostValue = (dcaLogEntry.TotalCost == 0.0) || (dcaLogEntry.AverageBuyPrice == 0.0);
// Render the row
<tr @(lostValue ? "class=errorRow" : "" ) >
// Market
2018-05-22 10:11:50 +02:00
@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, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@dcaLogEntry.Market</a></th>
2018-05-22 10:11:50 +02:00
} 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, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@dcaLogEntry.Market</a>
2019-10-19 13:33:02 +02:00
<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>
2018-05-22 10:11:50 +02:00
}
// Trend
<td class="text-autocolor">@Html.Raw((dcaLogEntry.PercChange * 100).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))%</td>
2019-04-13 12:44:42 +02:00
// Amount
<td class="text-left">@Html.Raw(@dcaLogEntry.Amount)</td>
// Value
<td class="text-left">@Html.Raw(@dcaLogEntry.TotalCost.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " (" + Model.MainFiatCurrencySymbol + currentFiatValue.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + ")")</td>
// DCA level
2018-05-22 10:11:50 +02:00
<td class="text-right">
@if (dcaLogEntry.BoughtTimes > 0) {
@dcaLogEntry.BoughtTimes;
}
</td>
// Buy strats
2018-05-22 10:11:50 +02:00
@if (buyDisabled) {
2020-07-20 06:53:36 +02:00
<td class="text">@Html.Raw(buyStrategyText)</td>
2018-05-22 10:11:50 +02:00
} else {
2020-07-20 06:53:36 +02:00
<td class="text">@Html.Raw(buyStrategyText)</td>
2018-05-22 10:11:50 +02:00
}
// BS Value
2018-05-22 10:11:50 +02:00
<td class="text-right text-nowrap">
@if (!buyDisabled) {
@Html.Raw(currentBuyValueText)
}
</td>
// BS Trigger
2018-05-22 10:11:50 +02:00
@if (!buyDisabled && dcaLogEntry.BoughtTimes < Model.Summary.DCALevels) {
<td class="text-right text-nowrap">@Html.Raw(triggerBuyValueText)</td>
} else {
if (!buyDisabled && dcaLogEntry.BoughtTimes >= Model.Summary.DCALevels) {
<td class="text-right text-warning">MAX</td>
} else {
<td class="text-right text-warning">Disabled!</td>
}
}
// Percent
@if(!@lostValue)
{
<td class="text-right text-autocolor">@dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td>
}
else
{
<td class="text-right">No Value!</td>
}
// Sell Strats
2020-07-20 06:53:36 +02:00
<td class="text">@Html.Raw(sellStrategyText)</td>
// SSV
<td class="text-right text-nowrap">@Html.Raw(currentSellValueText)</td>
// SST
2018-05-22 10:11:50 +02:00
<td class="text-right text-nowrap">
@Html.Raw(triggerSellValueText)
</td>
// Bid and avg price
2018-12-19 15:40:44 +01:00
<td class="text-right">@dcaLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))<br>@dcaLogEntry.AverageBuyPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
// Details
2018-05-22 10:11:50 +02:00
<td><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/BagDetails/?m=@dcaLogEntry.Market" data-remote="false" data-toggle="modal" data-target="#dca-chart" class="btn btn-sm btn-ptmagic">Details</a></td>
</tr>
}
<script type="text/javascript">
$(document).ready(function () {
$("#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);
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
});
});
});
</script>