Do not retry if the answer is a error result
This commit is contained in:
parent
b7e4e41e74
commit
3a4b59de07
|
@ -83,6 +83,7 @@ public class GunbotProxyService {
|
||||||
|
|
||||||
retryPolicy = new RetryPolicy()
|
retryPolicy = new RetryPolicy()
|
||||||
.retryOn(failure -> failure instanceof Exception)
|
.retryOn(failure -> failure instanceof Exception)
|
||||||
|
.abortOn(failure -> failure.getMessage().startsWith("error:"))
|
||||||
.withDelay(500, TimeUnit.MILLISECONDS)
|
.withDelay(500, TimeUnit.MILLISECONDS)
|
||||||
.withMaxRetries(maxRetries);
|
.withMaxRetries(maxRetries);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +275,7 @@ public class GunbotProxyService {
|
||||||
String result = Failsafe.with(retryPolicy)
|
String result = Failsafe.with(retryPolicy)
|
||||||
.onFailedAttempt(this::handleException)
|
.onFailedAttempt(this::handleException)
|
||||||
.get(() -> analyzeResult(tradingAPIClient.buy(currencyPair, buyPrice, amount, false, false, false)));
|
.get(() -> analyzeResult(tradingAPIClient.buy(currencyPair, buyPrice, amount, false, false, false)));
|
||||||
logger.info("Buy order" + result);
|
logger.info(String.format("Buy order for %s -- %s", currencyPair, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +293,7 @@ public class GunbotProxyService {
|
||||||
String result = Failsafe.with(retryPolicy)
|
String result = Failsafe.with(retryPolicy)
|
||||||
.onFailedAttempt(this::handleException)
|
.onFailedAttempt(this::handleException)
|
||||||
.get(() -> analyzeResult(tradingAPIClient.buy(currencyPair, buyPrice, amount, false, false, false)));
|
.get(() -> analyzeResult(tradingAPIClient.buy(currencyPair, buyPrice, amount, false, false, false)));
|
||||||
logger.info("Buy order" + result);
|
logger.info(String.format("Buy order for %s -- %s", currencyPair, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +310,7 @@ public class GunbotProxyService {
|
||||||
String result = Failsafe.with(retryPolicy)
|
String result = Failsafe.with(retryPolicy)
|
||||||
.onFailedAttempt(this::handleException)
|
.onFailedAttempt(this::handleException)
|
||||||
.get(() -> analyzeResult(tradingAPIClient.sell(currencyPair, buyPrice, amount, false, true, false)));
|
.get(() -> analyzeResult(tradingAPIClient.sell(currencyPair, buyPrice, amount, false, true, false)));
|
||||||
logger.info("Sell order" + result);
|
logger.info(String.format("Sell order for %s -- %s", currencyPair, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +343,7 @@ public class GunbotProxyService {
|
||||||
throw new ProxyHandledException("No value was returned");
|
throw new ProxyHandledException("No value was returned");
|
||||||
} else if (result.contains("Nonce")) {
|
} else if (result.contains("Nonce")) {
|
||||||
throw new ProxyHandledException("nonce error: " + result);
|
throw new ProxyHandledException("nonce error: " + result);
|
||||||
} else if (result.contains("error")) {
|
} else if (result.contains("error:")) {
|
||||||
throw new RuntimeException(result);
|
throw new RuntimeException(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -393,9 +394,8 @@ public class GunbotProxyService {
|
||||||
|
|
||||||
public String checkTradingKey(String apiKey) {
|
public String checkTradingKey(String apiKey) {
|
||||||
PoloniexTradingAPIClient tradingAPIClient = poloniexTradingAPIClients.get(apiKey);
|
PoloniexTradingAPIClient tradingAPIClient = poloniexTradingAPIClients.get(apiKey);
|
||||||
String result = Failsafe.with(retryPolicy)
|
return Failsafe.with(retryPolicy)
|
||||||
.onFailedAttempt(this::handleException)
|
.onFailedAttempt(this::handleException)
|
||||||
.get(() -> analyzeResult(tradingAPIClient.returnOpenOrders("ALL")));
|
.get(() -> analyzeResult(tradingAPIClient.returnOpenOrders("ALL")));
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,7 @@ REM This apiKey will do the buying and selling and orders canceling stuff. You c
|
||||||
set a=--apiKey1=another apiKey
|
set a=--apiKey1=another apiKey
|
||||||
set as=--apiSecret1=your secret
|
set as=--apiSecret1=your secret
|
||||||
|
|
||||||
java -jar GunbotProxyCommunity-0.9.7.jar %sp% %sks% %sksp% %skp% %da% %ds% %a% %as% %lnl%
|
set dbp=--doubleBuyProtectionSeconds=60
|
||||||
|
|
||||||
|
java -jar GunbotProxyCommunity-0.9.7.jar %sp% %sks% %sksp% %skp% %da% %ds% %a% %as% %lnl% %dbp%
|
||||||
pause
|
pause
|
||||||
|
|
Loading…
Reference in New Issue