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