@page @model BagDetailsModel @{ Layout = null; Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; if (Model.Summary.MarketSummary.ContainsKey(Model.DCALogData.Market)) { mps = Model.Summary.MarketSummary[Model.DCALogData.Market]; } int nextBuyTrigger = Model.DCALogData.BoughtTimes + 1; double nextBuyTriggerPercent = 0; if (Model.Summary.DCATriggers.Count >= nextBuyTrigger) { nextBuyTriggerPercent = Model.Summary.DCATriggers[nextBuyTrigger]; } bool buyDisabled = false; string buyTriggerText = Model.DCALogData.BuyTriggerPercent.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%"; if (mps != null) { if (!mps.IsDCAEnabled) { nextBuyTriggerPercent = 0; buyDisabled = true; buyTriggerText = ""; } else { if (Model.DCALogData.BuyTriggerPercent == 0) { Model.DCALogData.BuyTriggerPercent = Model.DCALogData.ProfitPercent; } } } else { buyDisabled = Model.DCALogData.BuyStrategy == null; if (Model.DCALogData.BuyTriggerPercent == 0) { Model.DCALogData.BuyTriggerPercent = Model.DCALogData.ProfitPercent; } } bool isTrailingBuyActive = Model.DCALogData.IsTrailing; if (Model.DCALogData.BuyStrategies.Count > 0) { isTrailingBuyActive = (Model.DCALogData.BuyStrategies.FindAll(bs => bs.IsTrailing).Count > 0); } bool isBuyStrategyTrue = Model.DCALogData.IsTrue; if (Model.DCALogData.BuyStrategies.Count > 0) { isBuyStrategyTrue = (Model.DCALogData.BuyStrategies.FindAll(bs => !bs.IsTrue).Count == 0); } string buyStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.BuyStrategies, Model.DCALogData.BuyStrategy, isBuyStrategyTrue, isTrailingBuyActive); if (!Core.ProfitTrailer.StrategyHelper.IsValidStrategy(buyStrategyText, true)) { buyDisabled = true; } string currentBuyValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(Model.DCALogData.BuyStrategies, Model.DCALogData.BuyStrategy, Model.DCALogData.CurrentLowBBValue, Model.DCALogData.BuyTriggerPercent, true); string triggerBuyValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, Model.DCALogData.BuyStrategies, Model.DCALogData.BuyStrategy, Model.DCALogData.BBTrigger, Core.Main.Constants.MinTrendChange, Model.DCALogData.BoughtTimes, true); string bagAgeText = ""; int bagAgeSeconds = (int)Math.Ceiling(Model.DateTimeNow.Subtract(Model.DCALogData.FirstBoughtDate).TotalSeconds); bagAgeText = Core.Helper.SystemHelper.GetProperDurationTime(bagAgeSeconds); double nextBuyTriggerPrice = 0.0; double nextAvgBoughtPrice = 0.0; if (nextBuyTriggerPercent != 0) { nextBuyTriggerPrice = Model.DCALogData.AverageBuyPrice + (Model.DCALogData.AverageBuyPrice * nextBuyTriggerPercent / 100); nextAvgBoughtPrice = (Model.DCALogData.TotalCost + (Model.DCALogData.Amount * nextBuyTriggerPrice)) / (Model.DCALogData.Amount * 2); } bool isTrailingSellActive = false; if (Model.DCALogData.SellStrategies.Count > 0) { isTrailingSellActive = (Model.DCALogData.SellStrategies.FindAll(ss => ss.IsTrailing).Count > 0); } bool isSellStrategyTrue = false; if (Model.DCALogData.BuyStrategies.Count > 0) { isSellStrategyTrue = (Model.DCALogData.SellStrategies.FindAll(ss => !ss.IsTrue).Count == 0); } string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Model.Summary, Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, isSellStrategyTrue, isTrailingSellActive); string currentSellValueText = Core.ProfitTrailer.StrategyHelper.GetCurrentValueText(Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, Model.DCALogData.CurrentHighBBValue, Model.DCALogData.ProfitPercent, true); string triggerSellValueText = Core.ProfitTrailer.StrategyHelper.GetTriggerValueText(Model.Summary, Model.DCALogData.SellStrategies, Model.DCALogData.SellStrategy, Model.DCALogData.BBTrigger, Model.DCALogData.SellTrigger, 0, true); double sellTriggerPrice = Model.DCALogData.AverageBuyPrice + (Model.DCALogData.AverageBuyPrice * Model.DCALogData.SellTrigger / 100); double averageProfitPercent = 0; @* if (Model.PTData.SellLog.FindAll(m => m.Market == Model.DCALogData.Market).Count > 0) { averageProfitPercent = Model.PTData.SellLog.FindAll(m => m.Market == Model.DCALogData.Market).Average(p => p.ProfitPercent); } *@ double investedFiatValue = Math.Round(Model.DCALogData.TotalCost * Model.Summary.MainMarketPrice, 2); double currentValue = Math.Round(Model.DCALogData.Amount * Model.DCALogData.CurrentPrice, 8); double currentFiatValue = Math.Round(Model.DCALogData.Amount * Model.DCALogData.CurrentPrice * Model.Summary.MainMarketPrice, 2); double currentProfit = Math.Round(currentValue - Model.DCALogData.TotalCost, 8); double currentFiatProfit = Math.Round(currentFiatValue - investedFiatValue, 2); }