@page @model BagListModel @{ Layout = null; System.Reflection.PropertyInfo propertyInfo = typeof(Core.Main.DataObjects.PTMagicData.DCALogData).GetProperty(Model.SortFieldId); List 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 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); } 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); 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); } string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive); 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 // Market @if (mps != null && (mps.ActiveSingleSettings == null || mps.ActiveSingleSettings.Count == 0)) { @dcaLogEntry.Market } else { @dcaLogEntry.Market } // Trend @Html.Raw(dcaLogEntry.PercChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))% // Amount @Html.Raw(@dcaLogEntry.Amount) // Value @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")) + ")") // DCA level @if (dcaLogEntry.BoughtTimes > 0) { @dcaLogEntry.BoughtTimes; } // Buy strats @if (buyDisabled) { @Html.Raw(buyStrategyText) } else { @Html.Raw(buyStrategyText) } // BS Value @if (!buyDisabled) { @Html.Raw(currentBuyValueText) } // BS Trigger @if (!buyDisabled && dcaLogEntry.BoughtTimes < Model.Summary.DCALevels) { @Html.Raw(triggerBuyValueText) } else { if (!buyDisabled && dcaLogEntry.BoughtTimes >= Model.Summary.DCALevels) { MAX } else { Disabled! } } // Percent @if(!@lostValue) { @dcaLogEntry.ProfitPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% } else { No Value! } // Sell Strats @Html.Raw(sellStrategyText) // SST @Html.Raw(triggerSellValueText) // Bid and avg price @dcaLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))
@dcaLogEntry.AverageBuyPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) // Details Details }