diff --git a/configuration.properties b/configuration.properties deleted file mode 100644 index 02fe70a..0000000 --- a/configuration.properties +++ /dev/null @@ -1 +0,0 @@ -sellOnlyMode=true \ No newline at end of file diff --git a/src/main/java/nl/komtek/gpi/application/Application.java b/src/main/java/nl/komtek/gpi/application/Application.java index cee3db8..fce8eb8 100644 --- a/src/main/java/nl/komtek/gpi/application/Application.java +++ b/src/main/java/nl/komtek/gpi/application/Application.java @@ -84,7 +84,7 @@ public class Application { @Bean public TaskScheduler taskScheduler() { - return new ConcurrentTaskScheduler(Executors.newScheduledThreadPool(2)); + return new ConcurrentTaskScheduler(Executors.newScheduledThreadPool(4)); } @Bean diff --git a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java index 954be59..e3c2469 100644 --- a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java +++ b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java @@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -101,7 +103,7 @@ public class GunbotProxyController { JsonElement jElement = new JsonParser().parse(result); JsonObject jObject = jElement.getAsJsonObject(); - JsonArray jArray = jObject.getAsJsonArray(currencyPair); + JsonArray jArray = hideOpenOrders(jObject.getAsJsonArray(currencyPair)); return jArray != null ? jArray.toString() : "[]"; } @@ -216,6 +218,10 @@ public class GunbotProxyController { return result; } + if (result.contains("error")) { + return result; + } + List chartData = mapper.mapChartData(result); JsonParser jsonParser = new JsonParser(); @@ -227,4 +233,18 @@ public class GunbotProxyController { return filteredjArray.toString(); } + + private JsonArray hideOpenOrders(JsonArray jsonArray){ + + for (Iterator it = jsonArray.iterator(); it.hasNext(); ) { + JsonElement element = it.next(); + JsonObject jsonObject = element.getAsJsonObject(); + String orderNumber = jsonObject.get("orderNumber").getAsString(); + String[] orderNumbersToHide = util.getConfigurationProperty("hideOrders","").split(","); + if (Arrays.asList(orderNumbersToHide).contains(orderNumber)){ + it.remove(); + } + } + return jsonArray; + } } diff --git a/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java b/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java index 6fac559..a4684bb 100644 --- a/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java +++ b/src/main/java/nl/komtek/gpi/services/GunbotProxyService.java @@ -343,7 +343,7 @@ public class GunbotProxyService { } else if (result.contains("Nonce")) { throw new ProxyHandledException("nonce error: " + result); } else if (result.contains("Connection timed out")) { - throw new RuntimeException(result); + throw new ProxyHandledException(result); } return result; } diff --git a/src/main/java/nl/komtek/gpi/utils/Util.java b/src/main/java/nl/komtek/gpi/utils/Util.java index 597d7fb..df2138a 100644 --- a/src/main/java/nl/komtek/gpi/utils/Util.java +++ b/src/main/java/nl/komtek/gpi/utils/Util.java @@ -25,6 +25,16 @@ public class Util { return StringUtils.replace(value, "\"", ""); } + public String getEnvProperty(String key, String defaultValue) { + String value = getEnvProperty(key); + return (value == null) ? defaultValue : value; + } + + public String getConfigurationProperty(String key, String defaultValue) { + String value = getConfigurationProperty(key); + return (value == null) ? defaultValue : value; + } + public String getConfigurationProperty(String key) { CaseLessProperties prop = new CaseLessProperties(); String value = null;