From 19b418a9e61648a86f261e879472ccb5f269e6cb Mon Sep 17 00:00:00 2001 From: elroy Date: Sat, 29 Jul 2017 16:51:08 +0200 Subject: [PATCH] Simplify application.properties and small bug fix --- .../komtek/gpi/application/Application.java | 15 +++- .../controllers/GunbotProxyController.java | 2 +- .../gpi/controllers/MonitoringController.java | 4 +- src/main/resources/templates/index.ftl | 89 ++++++++++--------- 4 files changed, 63 insertions(+), 47 deletions(-) diff --git a/src/main/java/nl/komtek/gpi/application/Application.java b/src/main/java/nl/komtek/gpi/application/Application.java index 320acc7..ddb73a6 100644 --- a/src/main/java/nl/komtek/gpi/application/Application.java +++ b/src/main/java/nl/komtek/gpi/application/Application.java @@ -3,8 +3,8 @@ package nl.komtek.gpi.application; import net.sf.ehcache.Cache; import org.apache.catalina.connector.Connector; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.cache.CacheManager; @@ -19,6 +19,8 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Executors; /** @@ -42,7 +44,15 @@ public class Application { private boolean doubleBuyProtection; public static void main(String[] args) { - SpringApplication.run(Application.class, args); + Map props = new HashMap<>(); + props.put("server.port", 443); + props.put("server.ssl.key-store", "classpath:poloniex.keystore"); + props.put("server.ssl.key-store-password", "poloniex"); + props.put("server.ssl.key-password", "poloniex"); + new SpringApplicationBuilder() + .sources(Application.class) + .properties(props) + .run(args); } @Bean @@ -57,7 +67,6 @@ public class Application { Cache orderBookCache = new Cache("orderBook", 5, false, true, 0, 0); Cache publicTradeHistoryCache = new Cache("publicTradeHistory", 5, false, true, 0, 0); - cacheManager.addCache(tickerCache); cacheManager.addCache(tradeHistoryCache); cacheManager.addCache(openOrdersCache); diff --git a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java index 53f6cc9..cc3077b 100644 --- a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java +++ b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java @@ -305,7 +305,7 @@ public class GunbotProxyController { BigDecimal btcValue = BigDecimal.valueOf(element.getAsJsonObject().get("btcValue").getAsDouble()); if (available.doubleValue() == 0) { - continue; + filteredObject.add(entry.getKey().toString(), element); } double approximatePrice = btcValue.doubleValue() / available.add(onOrders).doubleValue(); diff --git a/src/main/java/nl/komtek/gpi/controllers/MonitoringController.java b/src/main/java/nl/komtek/gpi/controllers/MonitoringController.java index c7f5bfa..66ab5d9 100644 --- a/src/main/java/nl/komtek/gpi/controllers/MonitoringController.java +++ b/src/main/java/nl/komtek/gpi/controllers/MonitoringController.java @@ -10,6 +10,7 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @@ -29,7 +30,7 @@ public class MonitoringController { private ResourceLoader resourceLoader; @Autowired private ResourcePatternResolver resourcePatternResolver; - @Value("${gunbot.location}") + @Value("${gunbot.location:}") private String gunbotLocation; private Gson gson = new Gson(); @Autowired @@ -62,6 +63,7 @@ public class MonitoringController { market = "BTC"; } modelMap.put("balance", gunbotProxyService.getBTCBalance(market)); + modelMap.put("gunbotLocation", !StringUtils.isEmpty(gunbotLocation)); return new ModelAndView("index", modelMap); } } diff --git a/src/main/resources/templates/index.ftl b/src/main/resources/templates/index.ftl index 5b13de5..61a17e6 100644 --- a/src/main/resources/templates/index.ftl +++ b/src/main/resources/templates/index.ftl @@ -7,51 +7,56 @@ Your BTC Balance = ${balance}
-
- - - - - - - - - - <#list monitoringDatas as monitoringData> - - - + <#if !gunbotLocation> + You have not setup your gunbot location! + <#else> +
+
+
MarketIn BTCBuy/BoughtSell/SoldLast priceHow's the price?
${monitoringData.market._pair}
+ + + + + + + + + <#list monitoringDatas as monitoringData> + + + + <#assign altBalance = monitoringData.altcoinBalance!0.0 > + <#if altBalance gt 0> + <#assign btc=altBalance * monitoringData.lastPrice> + <#assign total = total + btc> + + <#else> + + - <#if monitoringData.altcoinBalance gt 0> - <#assign btc=monitoringData.altcoinBalance * monitoringData.lastPrice> - <#assign total = total + btc> - - <#else> - - + <#if altBalance gt 0> + + <#else> + + - <#if monitoringData.altcoinBalance gt 0> - - <#else> - - + <#if altBalance gt 0> + + <#else> + + - <#if monitoringData.altcoinBalance gt 0> - - <#else> - - - - - - - - - - - - -
MarketIn BTCBuy/BoughtSell/SoldLast priceHow's the price?
${monitoringData.market._pair}${btc}0.00000000${btc}0.00000000${monitoringData.boughtPrice!0.0}${monitoringData.priceToBuy!0.0}${monitoringData.boughtPrice!0.0}${monitoringData.priceToBuy!0.0}${monitoringData.priceToSell!0.0}${monitoringData.soldPrice!0.0}${monitoringData.priceToSell!0.0}${monitoringData.soldPrice!0.0}${monitoringData.lastPrice!0.0}${monitoringData.reason!""}
Total${total}
+ ${monitoringData.lastPrice!0.0} + ${monitoringData.reason!""} + + + + + Total + ${total} + + + \ No newline at end of file