From f93677b55ad380feb89b446f72ce370134b1fde9 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Sun, 19 Jul 2020 20:07:52 +0900 Subject: [PATCH 1/3] get API properties --- Core/DataObjects/PTMagicData.cs | 24 +++++++++++ Core/DataObjects/ProfitTrailerData.cs | 40 ++++++++++++++++-- _Development/ApiProperties.txt | 61 +++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 _Development/ApiProperties.txt diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index b847c6c..0e7d8a3 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -361,6 +361,19 @@ namespace Core.Main.DataObjects.PTMagicData } #endregion + #region Properties Objects + public class Properties + { + public string Currency { get; set; } = ""; + public bool Shorting { get; set; } = false; + public bool Margin { get; set; } = false; + public string UpTime { get; set; } = ""; + public int Port { get; set; } = 0; + public bool IsLeverageExchange { get; set; } = false; + public string BaseUrl { get; set; } = ""; + } + #endregion + #region Transaction Objects public class Transaction { @@ -486,6 +499,7 @@ namespace Core.Main.DataObjects.PTMagicData public double CurrentPrice { get; set; } public int BoughtTimes { get; set; } public double PercChange { get; set; } + public double Volume { get; set; } public List BuyStrategies { get; set; } = new List(); } @@ -499,5 +513,15 @@ namespace Core.Main.DataObjects.PTMagicData public double DustValue { get; set; } public string Market { get; set; } } + public class PropertiesData + { + public string Currency { get; set; } + public bool Shorting { get; set; } + public bool Margin { get; set; } + public string UpTime { get; set; } + public int Port { get; set; } + public bool IsLeverageExchange { get; set; } + public string BaseUrl { get; set; } + } #endregion } diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 0e86115..42ef74f 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -15,14 +15,15 @@ namespace Core.Main.DataObjects public class ProfitTrailerData { private SummaryData _summary = null; + private PropertiesData _properties = null; private List _sellLog = new List(); private List _dcaLog = new List(); private List _buyLog = new List(); private string _ptmBasePath = ""; private PTMagicConfiguration _systemConfiguration = null; private TransactionData _transactionData = null; - private DateTime _buyLogRefresh = DateTime.UtcNow, _sellLogRefresh = DateTime.UtcNow, _dcaLogRefresh = DateTime.UtcNow, _summaryRefresh = DateTime.UtcNow; - private volatile object _buyLock = new object(), _sellLock = new object(), _dcaLock = new object(), _summaryLock = new object(); + private DateTime _buyLogRefresh = DateTime.UtcNow, _sellLogRefresh = DateTime.UtcNow, _dcaLogRefresh = DateTime.UtcNow, _summaryRefresh = DateTime.UtcNow, _propertiesRefresh = DateTime.UtcNow; + private volatile object _buyLock = new object(), _sellLock = new object(), _dcaLock = new object(), _summaryLock = new object(), _propertiesLock = new object(); private TimeSpan? _offsetTimeSpan = null; // Constructor @@ -75,6 +76,26 @@ namespace Core.Main.DataObjects return _summary; } } + public PropertiesData Properties + { + get + { + if (_properties == null || (DateTime.UtcNow > _propertiesRefresh)) + { + lock (_propertiesLock) + { + // Thread double locking + if (_properties == null || (DateTime.UtcNow > _propertiesRefresh)) + { + _properties = BuildSummaryData(GetDataFromProfitTrailer("api/v2/data/properties")); + _propertiesRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + } + } + } + + return _properties; + } + } public List SellLog { get @@ -286,7 +307,19 @@ namespace Core.Main.DataObjects DustValue = PTData.totalDustCurrentValue }; } - + private PropertiesData BuildProptertiesData(dynamic PTProperties) + { + return new PropertiesData() + { + Currency = PTProperties.currency, + Shorting = PTProperties.shorting, + Margin = PTProperties.margin, + UpTime = PTProperties.upTime, + Port = PTProperties.port, + IsLeverageExchange = PTProperties.isLeverageExchange, + BaseUrl = PTProperties.baseUrl + }; + } private void BuildSellLogData(dynamic rawSellLogData) { foreach (var rsld in rawSellLogData.data) @@ -453,6 +486,7 @@ namespace Core.Main.DataObjects buyLogData.ProfitPercent = rbld.profit; buyLogData.CurrentPrice = rbld.currentPrice; buyLogData.PercChange = rbld.percChange; + buyLogData.Volume = rbld.volume; if (rbld.positive != null) { diff --git a/_Development/ApiProperties.txt b/_Development/ApiProperties.txt new file mode 100644 index 0000000..01887ca --- /dev/null +++ b/_Development/ApiProperties.txt @@ -0,0 +1,61 @@ + +PT API properties (unavailable via swagger UI) +-------------------------------------------- + +{"sellOnlyMode":false +"role":"A" +"enableConfig":true +"enableShutdown":true +"passwordSet":true +"language":"ENUS" +"currency":"USD" +"skin":"dark" +"testMode":false +"shorting":true +"margin":false +"testnet":false +"activeConfig":"MyConfig1" +"availableConfigs":"[\"MyConfig1\" +\"MyConfig2\" +\"MyConfig3\" +\"MyConfig4\" +\"MyConfig5\"]" +"availableSignalProviders":"[]" +"publicConfigs":"[\"public-ProfitTrailer_Three_Amigos-V4\" +\"public-ProfitTrailer_Conners2RSI-V2\" +\"public-ProfitTrailer_Fibonacci_Day_Trader-V1\" +\"public-ProfitTrailer_Signals_Template-V2\" +\"public-AwesomeSignals_Starter-V1\" +\"public-ProfitTrailer_Nifty_Fifty-V1\" +\"public-CryptosetSignal_ADVconfig-V5\" +\"public-ProfitTrailer_Trade_Panther-V1\" +\"public-Collective_Signals_Template-V4\" +\"public-ProfitTrailer_Fibonacci_Swing_Trader-V2\" +\"public-ProfitTrailer_RocketMan-V2\" +\"public-ProfitTrailer_OldFaithful-V6\" +\"public-ProfitTrailer_FrankenStrategy-V8\" +\"public-ProfitTrailer_Jobbing_The_Market-V5\" +\"public-ProfitTrailer_Golden_Cross-V3\" +\"public-ProfitTrailer_Spanish_Cross-V5\" +\"public-ProfitTrailer_Monte_Carlo-V8\" +\"public-ProfitTrailer_Bride_of_FrankenStrategy-V5\" +\"public-ProfitTrailer_Base_Settings-V3\" +\"public-ProfitTrailer_DoubleCross-V8\" +\"public-ProfitTrailer_ElToro-V7\" +\"public-ProfitTrailer_ElDorado-V8\"]" +"myPublicConfigs":"[]" +"myProducts":"[]" +"isAllowedToPublish":false +"maxConfigsAllowed":13 +"licenseType":"PRO" +"upTime":"2020-07-17T15:30:44.140" +"port":8095 +"sslEnabled":false +"displayAdvancedStats":true +"displayFullVersion":true +"displayButtons":true +"isMarketOrderSupported":true +"isLeverageExchange":true +"hasTestNet":false +"isPTFeederEnabled":false +"baseUrl":"http://x.x.x.x:xxxx"} \ No newline at end of file From af0fbabe1ce4589681994449e5542f17b64b0a91 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Mon, 20 Jul 2020 12:02:51 +0900 Subject: [PATCH 2/3] rearrange PBL columns --- Monitor/Pages/_get/DashboardTop.cshtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Monitor/Pages/_get/DashboardTop.cshtml b/Monitor/Pages/_get/DashboardTop.cshtml index 0c0dec8..93520df 100644 --- a/Monitor/Pages/_get/DashboardTop.cshtml +++ b/Monitor/Pages/_get/DashboardTop.cshtml @@ -18,9 +18,9 @@ Market - Ask - Volume - 24H + 24H + Volume + Ask Buy Strategies @@ -59,9 +59,9 @@ } else { @buyLogEntry.Market } - @buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) - @string.Format("{0}", (buyLogEntry.Volume).ToString()) @string.Format("{0}%", (buyLogEntry.PercChange * 100).ToString("#,#0.00")) + @string.Format("{0}", (buyLogEntry.Volume).ToString()) + @buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @if (buyDisabled) { @Html.Raw(buyStrategyText) } else { From c573720420fe11d6299ad4e759d018e6a79b366e Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Mon, 20 Jul 2020 13:53:36 +0900 Subject: [PATCH 3/3] Baglist Layout & Futures Link --- Core/Helper/SystemHelper.cs | 13 +++++++++++++ Monitor/Pages/SettingsGeneral.cshtml | 3 ++- Monitor/Pages/_get/BagDetails.cshtml | 4 ++-- Monitor/Pages/_get/BagList.cshtml | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Core/Helper/SystemHelper.cs b/Core/Helper/SystemHelper.cs index 398b403..73cd7d6 100644 --- a/Core/Helper/SystemHelper.cs +++ b/Core/Helper/SystemHelper.cs @@ -547,6 +547,19 @@ namespace Core.Helper result += pairName; } + else if (platform.Equals("TradingViewFutures")) + { + result = "https://www.tradingview.com/chart/?symbol="; + + string pairName = SystemHelper.StripBadCode(market, Constants.WhiteListMinimal); + + if (pairName.StartsWith(mainMarket)) + { + pairName = pairName.Replace(mainMarket, "") + mainMarket; + } + + result += pairName + "PERP"; + } else { switch (exchange) diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml index 1fdfa3e..5447e0b 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml +++ b/Monitor/Pages/SettingsGeneral.cshtml @@ -241,8 +241,9 @@
diff --git a/Monitor/Pages/_get/BagDetails.cshtml b/Monitor/Pages/_get/BagDetails.cshtml index 273794f..88f2a35 100644 --- a/Monitor/Pages/_get/BagDetails.cshtml +++ b/Monitor/Pages/_get/BagDetails.cshtml @@ -125,9 +125,9 @@ DCA Buy Strategies @if (buyDisabled) { - @Html.Raw(buyStrategyText) + @Html.Raw(buyStrategyText) } else { - @Html.Raw(buyStrategyText) + @Html.Raw(buyStrategyText) } diff --git a/Monitor/Pages/_get/BagList.cshtml b/Monitor/Pages/_get/BagList.cshtml index b1f7eb4..2323bc1 100644 --- a/Monitor/Pages/_get/BagList.cshtml +++ b/Monitor/Pages/_get/BagList.cshtml @@ -110,9 +110,9 @@ // Buy strats @if (buyDisabled) { - @Html.Raw(buyStrategyText) + @Html.Raw(buyStrategyText) } else { - @Html.Raw(buyStrategyText) + @Html.Raw(buyStrategyText) } // BS Value @@ -144,7 +144,7 @@ } // Sell Strats - @Html.Raw(sellStrategyText) + @Html.Raw(sellStrategyText) // SSV @Html.Raw(currentSellValueText)