From e36fd2ee210664b45a6b240e3e86e973e90d6064 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 20 Mar 2019 01:13:41 +0900 Subject: [PATCH] --- Core/Helper/SystemHelper.cs | 7 ++ Monitor/Pages/MarketAnalyzer.cshtml | 93 ++++++++++++++++++++++++- Monitor/Pages/SalesAnalyzer.cshtml | 29 +++++++- Monitor/Pages/SalesAnalyzer.cshtml.cs | 15 ++++ Monitor/Pages/StatusSummary.cshtml | 2 +- Monitor/Pages/_get/TickerWidgets.cshtml | 2 +- Monitor/wwwroot/assets/css/custom.css | 3 +- 7 files changed, 145 insertions(+), 6 deletions(-) diff --git a/Core/Helper/SystemHelper.cs b/Core/Helper/SystemHelper.cs index 18848d7..f576f9f 100644 --- a/Core/Helper/SystemHelper.cs +++ b/Core/Helper/SystemHelper.cs @@ -611,6 +611,13 @@ namespace Core.Helper return result; } + public static string GetMainCurrencySymbol(string tvSymbol) + { + string result = tvSymbol; + + return result; + } + public static string GetCurrencySymbol(string code) { string result = code; diff --git a/Monitor/Pages/MarketAnalyzer.cshtml b/Monitor/Pages/MarketAnalyzer.cshtml index 31b44fe..95deaf9 100644 --- a/Monitor/Pages/MarketAnalyzer.cshtml +++ b/Monitor/Pages/MarketAnalyzer.cshtml @@ -12,7 +12,97 @@
-

Current   @Model.Summary.MainMarket   Price:    @Html.Raw(Model.MainFiatCurrencySymbol + Model.Summary.MainMarketPrice.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")))  

+ @if (Model.Summary.MainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("TUSD", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USDC", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("PAX", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USD", StringComparison.InvariantCultureIgnoreCase)) + { + string TvSymbol = @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket)+"USD"; +
+
+ +
+ + } + else { + if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Binance", StringComparison.InvariantCultureIgnoreCase)) + { + string TvSymbol = "BINANCE:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT"; +
+
+ +
+ } + else + if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Bittrex", StringComparison.InvariantCultureIgnoreCase)) { + string TvSymbol = "BITTREX:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USD"; +
+
+ +
+ } + else + { + string TvSymbol = "Poloniex:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT"; +
+
+ +
+ } + }
@@ -21,7 +111,6 @@

Market Trend Averages

- diff --git a/Monitor/Pages/SalesAnalyzer.cshtml b/Monitor/Pages/SalesAnalyzer.cshtml index 31a2a0a..4aa8742 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml +++ b/Monitor/Pages/SalesAnalyzer.cshtml @@ -22,7 +22,19 @@ currentBalanceString = Math.Round(currentBalance, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); } } -

Total Account Value:     @currentBalanceString   @Model.Summary.MainMarket  

+

Starting Account Value:     @Model.PTMagicConfiguration.GeneralSettings.Application.StartBalance   @Model.Summary.MainMarket  

+

Estimated Account Value:     @currentBalanceString   @Model.Summary.MainMarket  

+ + + + +
+
+
+

Cumulative Profits

+
+ +
@@ -363,6 +375,21 @@ return lineChart; }); + nv.addGraph(function () { + var lineChart = nv.models.lineChart(); + var height = 400; + /**/ + var chartData = @Html.Raw(Model.BalanceChartDataJSON); + /**/ + lineChart.useInteractiveGuideline(true); + lineChart.xAxis.tickFormat(function (d) { return d3.time.format('%Y/%m/%d')(new Date(d)); }); + lineChart.yAxis.axisLabel('Profit').tickFormat(d3.format(',.2f')); + d3.select('.balance-chart svg').attr('perserveAspectRatio', 'xMinYMid').datum(chartData).transition().duration(500).call(lineChart); + nv.utils.windowResize(lineChart.update); + + return lineChart; + }); + $("#salesList").on("show.bs.modal", function (e) { $(this).find(".modal-content").html(''); var link = $(e.relatedTarget); diff --git a/Monitor/Pages/SalesAnalyzer.cshtml.cs b/Monitor/Pages/SalesAnalyzer.cshtml.cs index 7aa02b8..ee27da1 100644 --- a/Monitor/Pages/SalesAnalyzer.cshtml.cs +++ b/Monitor/Pages/SalesAnalyzer.cshtml.cs @@ -14,6 +14,7 @@ namespace Monitor.Pages public ProfitTrailerData PTData = null; public string TradesChartDataJSON = ""; public string ProfitChartDataJSON = ""; + public string BalanceChartDataJSON = ""; public IEnumerable> TopMarkets = null; public DateTime MinSellLogDate = Constants.confMinDate; public Dictionary DailyGains = new Dictionary(); @@ -63,20 +64,26 @@ namespace Monitor.Pages int tradeDayIndex = 0; string tradesPerDayJSON = ""; string profitPerDayJSON = ""; + string balancePerDayJSON = ""; + double balance = 0.0; for (DateTime salesDate = graphStartDate; salesDate <= DateTimeNow.DateTime.Date; salesDate = salesDate.AddDays(1)) { + if (tradeDayIndex > 0) { tradesPerDayJSON += ",\n"; profitPerDayJSON += ",\n"; + balancePerDayJSON += ",\n"; } int trades = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Count; double profit = PTData.SellLog.FindAll(t => t.SoldDate.Date == salesDate.Date).Sum(t => t.Profit); double profitFiat = Math.Round(profit * Summary.MainMarketPrice, 2); + balance += profitFiat; tradesPerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + trades + "}"; profitPerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + profitFiat.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; + balancePerDayJSON += "{x: new Date('" + salesDate.Date.ToString("yyyy-MM-dd") + "'), y: " + balance.ToString("0.00", new System.Globalization.CultureInfo("en-US")) + "}"; tradeDayIndex++; } @@ -97,6 +104,14 @@ namespace Monitor.Pages ProfitChartDataJSON += "}"; ProfitChartDataJSON += "]"; + BalanceChartDataJSON = "["; + BalanceChartDataJSON += "{"; + BalanceChartDataJSON += "key: 'Profit in " + Summary.MainFiatCurrency + "',"; + BalanceChartDataJSON += "color: '" + Constants.ChartLineColors[1] + "',"; + BalanceChartDataJSON += "values: [" + balancePerDayJSON + "]"; + BalanceChartDataJSON += "}"; + BalanceChartDataJSON += "]"; + for (DateTime salesDate = DateTimeNow.DateTime.Date; salesDate >= MinSellLogDate; salesDate = salesDate.AddDays(-1)) { List salesDateSales = PTData.SellLog.FindAll(sl => sl.SoldDate.Date == salesDate); diff --git a/Monitor/Pages/StatusSummary.cshtml b/Monitor/Pages/StatusSummary.cshtml index 3ab5b73..b3d31fc 100644 --- a/Monitor/Pages/StatusSummary.cshtml +++ b/Monitor/Pages/StatusSummary.cshtml @@ -19,7 +19,7 @@ double intervalSeconds = Model.PTMagicConfiguration.AnalyzerSettings.MarketAnalyzer.IntervalMinutes * 60.0; string ptMagicHealthIcon = ""; - if (elapsedSecondsSinceRuntime > (intervalSeconds + intervalSeconds * 0.2)) { + if (elapsedSecondsSinceRuntime > (intervalSeconds + intervalSeconds)) { ptMagicHealthIcon = ""; } diff --git a/Monitor/Pages/_get/TickerWidgets.cshtml b/Monitor/Pages/_get/TickerWidgets.cshtml index 51c247b..f5a48b1 100644 --- a/Monitor/Pages/_get/TickerWidgets.cshtml +++ b/Monitor/Pages/_get/TickerWidgets.cshtml @@ -22,7 +22,7 @@ string iconColor = "text-success"; string ptMagicHealthIcon = "fa-heartbeat"; string ptMagicHealthTooltip = "PT Magic is alive and healthy!"; - if (elapsedSecondsSinceRuntime > (intervalSeconds + intervalSeconds * 0.5)) { + if (elapsedSecondsSinceRuntime > (intervalSeconds + intervalSeconds)) { ptMagicHealthIcon = "fa-exclamation-triangle"; ptMagicHealthTooltip = "PT Magic seems to have problems, check the logs!"; iconColor = "text-danger"; diff --git a/Monitor/wwwroot/assets/css/custom.css b/Monitor/wwwroot/assets/css/custom.css index ed62771..9b8dcdb 100644 --- a/Monitor/wwwroot/assets/css/custom.css +++ b/Monitor/wwwroot/assets/css/custom.css @@ -154,7 +154,8 @@ .trend-chart .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point, .trades-chart .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point, -.profit-chart .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { +.profit-chart .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point, +.balance-chart .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { fill-opacity: 1 !important; stroke-opacity: 1 !important; }