From b6bba9deeae516753c5904ee975d4488d1d9d315 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 19 Jan 2024 18:40:08 +0900 Subject: [PATCH] Removed Obsolete SellLog code --- Core/DataObjects/PTMagicData.cs | 30 ++-- Core/DataObjects/ProfitTrailerData.cs | 156 +++++++++--------- Monitor/Pages/SalesAnalyzer.cshtml.cs | 2 +- Monitor/Pages/SettingsGeneral.cshtml | 6 +- Monitor/Pages/SettingsGeneral.cshtml.cs | 2 +- Monitor/Pages/_get/BagDetails.cshtml | 4 +- Monitor/Pages/_get/SalesList.cshtml | 86 ---------- Monitor/Pages/_get/SalesList.cshtml.cs | 49 ------ .../settings.general.json | 3 - .../DevSettings/settings.general.json | 5 +- 10 files changed, 101 insertions(+), 242 deletions(-) delete mode 100644 Monitor/Pages/_get/SalesList.cshtml delete mode 100644 Monitor/Pages/_get/SalesList.cshtml.cs diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index 10f4d6b..3f80cd4 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -61,7 +61,7 @@ namespace Core.Main.DataObjects.PTMagicData public int RefreshSeconds { get; set; } = 30; public int BagAnalyzerRefreshSeconds { get; set; } = 5; public int BuyAnalyzerRefreshSeconds { get; set; } = 5; - public int MaxSalesRecords { get; set; } = 99999; + //public int MaxSalesRecords { get; set; } = 99999; public int MaxTopMarkets { get; set; } = 20; public int MaxDailySummaries { get; set; } = 10; public int MaxMonthlySummaries { get; set; } = 10; @@ -399,20 +399,20 @@ namespace Core.Main.DataObjects.PTMagicData public double Last24hVolume { get; set; } = 0; } - public class SellLogData - { - public double SoldAmount { get; set; } - public DateTime SoldDate { get; set; } - public int BoughtTimes { get; set; } - public string Market { get; set; } - public double ProfitPercent { get; set; } - public double Profit { get; set; } - public double AverageBuyPrice { get; set; } - public double TotalCost { get; set; } - public double SoldPrice { get; set; } - public double SoldValue { get; set; } - public double TotalSales { get; set; } - } +// public class SellLogData +// { +// public double SoldAmount { get; set; } +// public DateTime SoldDate { get; set; } +// public int BoughtTimes { get; set; } +// public string Market { get; set; } +// public double ProfitPercent { get; set; } +// public double Profit { get; set; } +// public double AverageBuyPrice { get; set; } +// public double TotalCost { get; set; } +// public double SoldPrice { get; set; } +// public double SoldValue { get; set; } +// public double TotalSales { get; set; } +// } public class StatsData { diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 5891e0c..c96c69d 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -35,7 +35,7 @@ namespace Core.Main.DataObjects get { return _totalSales; } set { _totalSales = value; } } - private List _sellLog = new List(); + //private List _sellLog = new List(); private List _dcaLog = new List(); private List _buyLog = new List(); private string _ptmBasePath = ""; @@ -46,7 +46,7 @@ namespace Core.Main.DataObjects private DateTime _monthlyStatsRefresh = DateTime.UtcNow; private DateTime _statsRefresh = DateTime.UtcNow; private DateTime _buyLogRefresh = DateTime.UtcNow; - private DateTime _sellLogRefresh = DateTime.UtcNow; + //private DateTime _sellLogRefresh = DateTime.UtcNow; private DateTime _dcaLogRefresh = DateTime.UtcNow; private DateTime _miscRefresh = DateTime.UtcNow; private DateTime _propertiesRefresh = DateTime.UtcNow; @@ -585,56 +585,56 @@ namespace Core.Main.DataObjects Order = monthlyStatsDataJson["order"], }; } - public List SellLog - { - get - { +// public List SellLog +// { +// get +// { - if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh)) - { - lock (_sellLock) - { - // Thread double locking - if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh)) - { - _sellLog.Clear(); +// if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh)) +// { +// lock (_sellLock) +// { +// // Thread double locking +// if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh)) +// { +// _sellLog.Clear(); - // Page through the sales data summarizing it. - bool exitLoop = false; - int pageIndex = 1; +// // Page through the sales data summarizing it. +// bool exitLoop = false; +// int pageIndex = 1; - // 1 record per page to allow user to set max records to retrieve - int maxPages = _systemConfiguration.GeneralSettings.Monitor.MaxSalesRecords; - int requestedPages = 0; +// // 1 record per page to allow user to set max records to retrieve +// int maxPages = _systemConfiguration.GeneralSettings.Monitor.MaxSalesRecords; +// int requestedPages = 0; - while (!exitLoop && requestedPages < maxPages) - { - var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?Page=1&perPage=1&sort=SOLDDATE&sortDirection=DESCENDING&page=" + pageIndex); - if (sellDataPage != null && sellDataPage.data.Count > 0) - { - // Add sales data page to collection - this.BuildSellLogData(sellDataPage); - pageIndex++; - requestedPages++; -Console.WriteLine($"Importing salesLog: {pageIndex}"); +// while (!exitLoop && requestedPages < maxPages) +// { +// var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?Page=1&perPage=1&sort=SOLDDATE&sortDirection=DESCENDING&page=" + pageIndex); +// if (sellDataPage != null && sellDataPage.data.Count > 0) +// { +// // Add sales data page to collection +// this.BuildSellLogData(sellDataPage); +// pageIndex++; +// requestedPages++; +// Console.WriteLine($"Importing salesLog: {pageIndex}"); - } - else - { - // All data retrieved - exitLoop = true; - } - } +// } +// else +// { +// // All data retrieved +// exitLoop = true; +// } +// } - // Update sell log refresh time - _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds -1); - } - } - } - return _sellLog; - } - } +// // Update sell log refresh time +// _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds -1); +// } +// } +// } +// return _sellLog; +// } +// } public List DCALog @@ -736,18 +736,18 @@ Console.WriteLine($"Importing salesLog: {pageIndex}"); } - public double GetSnapshotBalance(DateTime snapshotDateTime) - { - double result = _misc.StartBalance; + // public double GetSnapshotBalance(DateTime snapshotDateTime) + // { + // double result = _misc.StartBalance; - result += this.SellLog.FindAll(sl => sl.SoldDate.Date < snapshotDateTime.Date).Sum(sl => sl.Profit); - result += this.TransactionData.Transactions.FindAll(t => t.UTCDateTime < snapshotDateTime).Sum(t => t.Amount); + // result += this.SellLog.FindAll(sl => sl.SoldDate.Date < snapshotDateTime.Date).Sum(sl => sl.Profit); + // result += this.TransactionData.Transactions.FindAll(t => t.UTCDateTime < snapshotDateTime).Sum(t => t.Amount); - // Calculate holdings for snapshot date - result += this.DCALog.FindAll(pairs => pairs.FirstBoughtDate <= snapshotDateTime).Sum(pairs => pairs.CurrentValue); + // // Calculate holdings for snapshot date + // result += this.DCALog.FindAll(pairs => pairs.FirstBoughtDate <= snapshotDateTime).Sum(pairs => pairs.CurrentValue); - return result; - } + // return result; + // } private dynamic GetDataFromProfitTrailer(string callPath, bool arrayReturned = false) { @@ -803,39 +803,39 @@ Console.WriteLine($"Importing salesLog: {pageIndex}"); } - private void BuildSellLogData(dynamic rawSellLogData) - { - foreach (var rsld in rawSellLogData.data) - { - SellLogData sellLogData = new SellLogData(); - sellLogData.SoldAmount = rsld.soldAmount; - sellLogData.BoughtTimes = rsld.boughtTimes; - sellLogData.Market = rsld.market; - sellLogData.ProfitPercent = rsld.profit; - sellLogData.SoldPrice = rsld.currentPrice; - sellLogData.AverageBuyPrice = rsld.avgPrice; - sellLogData.TotalCost = rsld.totalCost; - sellLogData.Profit = rsld.profitCurrency; + // private void BuildSellLogData(dynamic rawSellLogData) + // { + // foreach (var rsld in rawSellLogData.data) + // { + // SellLogData sellLogData = new SellLogData(); + // sellLogData.SoldAmount = rsld.soldAmount; + // sellLogData.BoughtTimes = rsld.boughtTimes; + // sellLogData.Market = rsld.market; + // sellLogData.ProfitPercent = rsld.profit; + // sellLogData.SoldPrice = rsld.currentPrice; + // sellLogData.AverageBuyPrice = rsld.avgPrice; + // sellLogData.TotalCost = rsld.totalCost; + // sellLogData.Profit = rsld.profitCurrency; - //Convert Unix Timestamp to Datetime - System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); - dtDateTime = dtDateTime.AddSeconds((double)rsld.soldDate).ToUniversalTime(); + // //Convert Unix Timestamp to Datetime + // System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); + // dtDateTime = dtDateTime.AddSeconds((double)rsld.soldDate).ToUniversalTime(); - // Profit Trailer sales are saved in UTC - DateTimeOffset ptSoldDate = DateTimeOffset.Parse(dtDateTime.Year.ToString() + "-" + dtDateTime.Month.ToString("00") + "-" + dtDateTime.Day.ToString("00") + "T" + dtDateTime.Hour.ToString("00") + ":" + dtDateTime.Minute.ToString("00") + ":" + dtDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + // // Profit Trailer sales are saved in UTC + // DateTimeOffset ptSoldDate = DateTimeOffset.Parse(dtDateTime.Year.ToString() + "-" + dtDateTime.Month.ToString("00") + "-" + dtDateTime.Day.ToString("00") + "T" + dtDateTime.Hour.ToString("00") + ":" + dtDateTime.Minute.ToString("00") + ":" + dtDateTime.Second.ToString("00"), CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); - // Convert UTC sales time to local offset time + // // Convert UTC sales time to local offset time - ptSoldDate = ptSoldDate.ToOffset(OffsetTimeSpan); + // ptSoldDate = ptSoldDate.ToOffset(OffsetTimeSpan); - sellLogData.SoldDate = ptSoldDate.DateTime; + // sellLogData.SoldDate = ptSoldDate.DateTime; - _sellLog.Add(sellLogData); - } - } + // _sellLog.Add(sellLogData); + // } + // } private void BuildDCALogData(dynamic rawDCALogData, dynamic rawPairsLogData, dynamic rawPendingLogData, dynamic rawWatchModeLogData) { diff --git a/Monitor/Pages/SalesAnalyzer.cshtml.cs b/Monitor/Pages/SalesAnalyzer.cshtml.cs index 8e42c5b..0f58ca4 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml.cs +++ b/Monitor/Pages/SalesAnalyzer.cshtml.cs @@ -30,7 +30,7 @@ namespace Monitor.Pages public string ProfitChartDataJSON = ""; public string SalesChartDataJSON = ""; public IEnumerable> TopMarkets = null; - public DateTime MinSellLogDate = Constants.confMinDate; + //public DateTime MinSellLogDate = Constants.confMinDate; public DateTimeOffset DateTimeNow = Constants.confMinDate; diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml index 4d9b8e8..3b01e47 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml +++ b/Monitor/Pages/SettingsGeneral.cshtml @@ -247,12 +247,12 @@ -
+ @*
-
+
*@
@@ -276,7 +276,7 @@
- +
diff --git a/Monitor/Pages/SettingsGeneral.cshtml.cs b/Monitor/Pages/SettingsGeneral.cshtml.cs index d0444e0..85a10d4 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml.cs +++ b/Monitor/Pages/SettingsGeneral.cshtml.cs @@ -95,7 +95,7 @@ namespace Monitor.Pages PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BagAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds); PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BuyAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds); PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform = HttpContext.Request.Form["Monitor_LinkPlatform"]; - PTMagicConfiguration.GeneralSettings.Monitor.MaxSalesRecords = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxSalesRecords"], PTMagicConfiguration.GeneralSettings.Monitor.MaxSalesRecords); + //PTMagicConfiguration.GeneralSettings.Monitor.MaxSalesRecords = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxSalesRecords"], PTMagicConfiguration.GeneralSettings.Monitor.MaxSalesRecords); PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxTopMarkets"], PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets); PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDailySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries); PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxMonthlySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries); diff --git a/Monitor/Pages/_get/BagDetails.cshtml b/Monitor/Pages/_get/BagDetails.cshtml index 2c5e4f8..aba6d69 100644 --- a/Monitor/Pages/_get/BagDetails.cshtml +++ b/Monitor/Pages/_get/BagDetails.cshtml @@ -82,9 +82,9 @@ 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) { + @* 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); diff --git a/Monitor/Pages/_get/SalesList.cshtml b/Monitor/Pages/_get/SalesList.cshtml deleted file mode 100644 index 2766e68..0000000 --- a/Monitor/Pages/_get/SalesList.cshtml +++ /dev/null @@ -1,86 +0,0 @@ -@page -@model SalesListModel -@{ - Layout = null; -} - - - - - \ No newline at end of file diff --git a/Monitor/Pages/_get/SalesList.cshtml.cs b/Monitor/Pages/_get/SalesList.cshtml.cs deleted file mode 100644 index 12ab483..0000000 --- a/Monitor/Pages/_get/SalesList.cshtml.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Http; -using Core.Main; -using Core.Helper; -using Core.Main.DataObjects; -using Core.Main.DataObjects.PTMagicData; -using Core.MarketAnalyzer; - -namespace Monitor.Pages { - public class SalesListModel : _Internal.BasePageModelSecure { - public ProfitTrailerData PTData = null; - private string salesDateString = ""; - private string salesMonthString = ""; - - public string SalesTimeframe = ""; - public DateTime SalesDate = Constants.confMinDate; - public List SellLog = new List(); - - public void OnGet() { - // Initialize Config - base.Init(); - - BindData(); - } - - private void BindData() { - salesDateString = GetStringParameter("d", ""); - salesMonthString = GetStringParameter("m", ""); - - PTData = this.PtDataObject; - - if (!salesDateString.Equals("")) { - SalesDate = SystemHelper.TextToDateTime(salesDateString, Constants.confMinDate); - if (SalesDate != Constants.confMinDate) { - SalesTimeframe = SalesDate.ToShortDateString(); - SellLog = PTData.SellLog.FindAll(sl => sl.SoldDate.Date == SalesDate.Date).OrderByDescending(sl => sl.SoldDate).ToList(); - } - } else if (!salesMonthString.Equals("")) { - SalesDate = SystemHelper.TextToDateTime(salesMonthString + "-01", Constants.confMinDate); - if (SalesDate != Constants.confMinDate) { - SalesTimeframe = SalesDate.ToString("MMMM yyyy", new System.Globalization.CultureInfo("en-US")); - SellLog = PTData.SellLog.FindAll(sl => sl.SoldDate.Date.Month == SalesDate.Month && sl.SoldDate.Date.Year == SalesDate.Year).OrderByDescending(sl => sl.SoldDate).ToList(); - } - } - } - } -} diff --git a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json index 50a9d5d..650c85b 100644 --- a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json +++ b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json @@ -11,10 +11,8 @@ "ProfitTrailerDefaultSettingName": "default", // Your Profit Trailer default setting name (needed to change your settings) "Exchange": "Bittrex", // The exchange your are running Profit Trailer on "TimezoneOffset": "+0:00", // Your timezone offset from UTC time - //"MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor "FloodProtectionMinutes": 0, // If a price trend is just zig-zagging around its trigger, you may want to protect your settings from getting switched back and forth every minute "InstanceName": "PT Magic", // The name of the instance of this bot. This will be used in your monitor and your Telegram messages. In case you are running more than one bot, you may set different names to separate them - "CoinMarketCapAPIKey": "", //CoinMarketCap Api //"FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key }, "Monitor": { @@ -28,7 +26,6 @@ "ProfitsMaxTimeframeDays": 30, // This will enable you to define the timeframe for your dashboard profits graph in days "RefreshSeconds": 30, // The refresh interval of your monitor main page "LinkPlatform": "TradingView", // The platform to which the pair name will link if you click on it - "MaxSalesRecords": 99999, // The maximum number of sales records pulled from Profit Trailer. Changes require a Monitor Restart. "MaxTopMarkets": 20, // The amount of top markets being shown in your Sales Analyzer "MaxDailySummaries": 10, // The amount of "Last Days" being shown in your Sales Analyzer "MaxMonthlySummaries": 10, // The amount of "Last Months" being shown in your Sales Analyzer diff --git a/_Development/DevSettings/settings.general.json b/_Development/DevSettings/settings.general.json index 50a9d5d..9b8e822 100644 --- a/_Development/DevSettings/settings.general.json +++ b/_Development/DevSettings/settings.general.json @@ -11,11 +11,9 @@ "ProfitTrailerDefaultSettingName": "default", // Your Profit Trailer default setting name (needed to change your settings) "Exchange": "Bittrex", // The exchange your are running Profit Trailer on "TimezoneOffset": "+0:00", // Your timezone offset from UTC time - //"MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor - "FloodProtectionMinutes": 0, // If a price trend is just zig-zagging around its trigger, you may want to protect your settings from getting switched back and forth every minute + "FloodProtectionMinutes": 0, // If a price trend is just zig-zagging around its trigger, you may want to protect your settings from getting switched back and forth every minute "InstanceName": "PT Magic", // The name of the instance of this bot. This will be used in your monitor and your Telegram messages. In case you are running more than one bot, you may set different names to separate them "CoinMarketCapAPIKey": "", //CoinMarketCap Api - //"FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key }, "Monitor": { "IsPasswordProtected": true, // Defines if your monitor will be asking to setup a password on its first start @@ -28,7 +26,6 @@ "ProfitsMaxTimeframeDays": 30, // This will enable you to define the timeframe for your dashboard profits graph in days "RefreshSeconds": 30, // The refresh interval of your monitor main page "LinkPlatform": "TradingView", // The platform to which the pair name will link if you click on it - "MaxSalesRecords": 99999, // The maximum number of sales records pulled from Profit Trailer. Changes require a Monitor Restart. "MaxTopMarkets": 20, // The amount of top markets being shown in your Sales Analyzer "MaxDailySummaries": 10, // The amount of "Last Days" being shown in your Sales Analyzer "MaxMonthlySummaries": 10, // The amount of "Last Months" being shown in your Sales Analyzer