Merge pull request #215 from HojouFotytu/develop

Binance USD market error
This commit is contained in:
HojouFotytu 2020-08-07 01:45:13 +09:00 committed by GitHub
commit 235dcd59e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 49 additions and 39 deletions

View File

@ -20,7 +20,8 @@ namespace Core.MarketAnalyzer
public static double GetMainCurrencyPrice(string mainMarket, PTMagicConfiguration systemConfiguration, LogHelper log) public static double GetMainCurrencyPrice(string mainMarket, PTMagicConfiguration systemConfiguration, LogHelper log)
{ {
double result = 0; double result = 0;
if (mainMarket != "USD")
{
try try
{ {
string baseUrl = "https://api.binance.us/api/v1/ticker/24hr?symbol=" + mainMarket + "USDT"; string baseUrl = "https://api.binance.us/api/v1/ticker/24hr?symbol=" + mainMarket + "USDT";
@ -39,9 +40,13 @@ namespace Core.MarketAnalyzer
{ {
log.DoLogCritical(ex.Message, ex); log.DoLogCritical(ex.Message, ex);
} }
return result; return result;
} }
else
{
return 1.0;
}
}
public static List<string> GetMarketData(string mainMarket, Dictionary<string, MarketInfo> marketInfos, PTMagicConfiguration systemConfiguration, LogHelper log) public static List<string> GetMarketData(string mainMarket, Dictionary<string, MarketInfo> marketInfos, PTMagicConfiguration systemConfiguration, LogHelper log)
{ {
@ -58,7 +63,7 @@ namespace Core.MarketAnalyzer
if (jsonArray.Count > 0) if (jsonArray.Count > 0)
{ {
double mainCurrencyPrice = 1; double mainCurrencyPrice = 1;
if (!mainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase)) if (!mainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase) && !mainMarket.Equals("USD", StringComparison.InvariantCultureIgnoreCase))
{ {
mainCurrencyPrice = BinanceUS.GetMainCurrencyPrice(mainMarket, systemConfiguration, log); mainCurrencyPrice = BinanceUS.GetMainCurrencyPrice(mainMarket, systemConfiguration, log);
} }
@ -238,8 +243,11 @@ namespace Core.MarketAnalyzer
} }
bool go = true; bool go = true;
if (!(marketName == "USDUSDT"))
{
while (ticksFetched < ticksNeeded && go) while (ticksFetched < ticksNeeded && go)
{ {
baseUrl = "https://api.binance.us/api/v1/klines?interval=1m&symbol=" + marketName + "&endTime=" + endTime.ToString() + "&limit=" + ticksLimit.ToString(); baseUrl = "https://api.binance.us/api/v1/klines?interval=1m&symbol=" + marketName + "&endTime=" + endTime.ToString() + "&limit=" + ticksLimit.ToString();
log.DoLogDebug("BinanceUS - Getting " + ticksLimit.ToString() + " ticks for '" + marketName + "'..."); log.DoLogDebug("BinanceUS - Getting " + ticksLimit.ToString() + " ticks for '" + marketName + "'...");
@ -273,6 +281,8 @@ namespace Core.MarketAnalyzer
} }
} }
} }
}
catch (WebException ex) catch (WebException ex)
{ {
if (ex.Response != null) if (ex.Response != null)