Merge pull request #207 from HojouFotytu/develop

get API properties
This commit is contained in:
HojouFotytu 2020-07-22 07:55:14 +09:00 committed by GitHub
commit cf0834a61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 145 additions and 14 deletions

View File

@ -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
{
@ -500,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
}

View File

@ -15,14 +15,15 @@ namespace Core.Main.DataObjects
public class ProfitTrailerData
{
private SummaryData _summary = null;
private PropertiesData _properties = null;
private List<SellLogData> _sellLog = new List<SellLogData>();
private List<DCALogData> _dcaLog = new List<DCALogData>();
private List<BuyLogData> _buyLog = new List<BuyLogData>();
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<SellLogData> 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)

View File

@ -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)

View File

@ -241,8 +241,9 @@
<label class="col-md-4 col-form-label">Link Platform <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The platform to which the pair name will link if you click on it."></i></label>
<div class="col-md-8">
<select name="Monitor_LinkPlatform" class="form-control">
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingView", StringComparison.InvariantCultureIgnoreCase))">TradingView</option>
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))">Exchange</option>
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingView", StringComparison.InvariantCultureIgnoreCase))">TradingView</option>
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingViewFutures", StringComparison.InvariantCultureIgnoreCase))">TradingViewFutures</option>
</select>
</div>
</div>

View File

@ -125,9 +125,9 @@
<tr>
<td>DCA Buy Strategies</td>
@if (buyDisabled) {
<td class="text-right text-nowrap">@Html.Raw(buyStrategyText)</td>
<td class="text-right text">@Html.Raw(buyStrategyText)</td>
} else {
<td class="text-right text-nowrap">@Html.Raw(buyStrategyText)</td>
<td class="text-right text">@Html.Raw(buyStrategyText)</td>
}
</tr>
<tr>

View File

@ -110,9 +110,9 @@
// Buy strats
@if (buyDisabled) {
<td class="text-nowrap">@Html.Raw(buyStrategyText)</td>
<td class="text">@Html.Raw(buyStrategyText)</td>
} else {
<td class="text-nowrap">@Html.Raw(buyStrategyText)</td>
<td class="text">@Html.Raw(buyStrategyText)</td>
}
// BS Value
@ -144,7 +144,7 @@
}
// Sell Strats
<td class="text-nowrap">@Html.Raw(sellStrategyText)</td>
<td class="text">@Html.Raw(sellStrategyText)</td>
// SSV
<td class="text-right text-nowrap">@Html.Raw(currentSellValueText)</td>

View File

@ -18,9 +18,9 @@
<thead>
<tr>
<th>Market</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="Current ask price for this market">Ask</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="Current Volume">Volume</th>
<th class="text-left" data-toggle="tooltip" data-placement="top" title="24 Hour Trend">24H</th>
<th class="text-center" data-toggle="tooltip" data-placement="top" title="24 Hour Trend">24H</th>
<th class="text-center" data-toggle="tooltip" data-placement="top" title="Current Volume">Volume</th>
<th class="text-center" data-toggle="tooltip" data-placement="top" title="Current ask price for this market">Ask</th>
<th>Buy Strategies</th>
</tr>
</thead>
@ -59,9 +59,9 @@
} else {
<th class="align-top"><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform,Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, buyLogEntry.Market, Model.Summary.MainMarket)" target="_blank">@buyLogEntry.Market</a> <i class="fa fa-exclamation-triangle text-highlight" data-toggle="tooltip" data-placement="top" data-html="true" title="@await Component.InvokeAsync("PairIcon", mps)" data-template="<div class='tooltip' role='tooltip'><div class='tooltip-arrow'></div><div class='tooltip-inner pair-tooltip'></div></div>"></i></th>
}
<td class="text-left">@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text">@string.Format("{0}", (buyLogEntry.Volume24h).ToString())</td>
<td class="text-autocolor">@string.Format("{0}%", (buyLogEntry.PercChange * 100).ToString("#,#0.00"))</td>
<td class="text">@string.Format("{0}", (buyLogEntry.Volume24).ToString())</td>
<td class="text-right">@buyLogEntry.CurrentPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
@if (buyDisabled) {
<td>@Html.Raw(buyStrategyText)</td>
} else {

View File

@ -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"}