fix monitoring

This commit is contained in:
elroy 2017-07-06 15:59:50 +02:00
parent 87080bdc05
commit aa7ced0042
6 changed files with 47 additions and 26 deletions

View File

@ -5,7 +5,7 @@
<groupId>nl.komtek</groupId>
<artifactId>GunbotProxyCommunity</artifactId>
<version>0.9.4</version>
<version>0.9.5</version>
<packaging>jar</packaging>
<name>GunbotProxyCommunity</name>

View File

@ -43,21 +43,25 @@ public class MonitoringController {
Resource[] logResources = resourcePatternResolver.getResources(logFilePatern);
List<String> logPaths = new ArrayList<>();
for (Resource resource : logResources){
for (Resource resource : logResources) {
logPaths.add(resource.getFilename().replace("-log.txt", ""));
}
List<MonitoringData> monitoringDatas = new ArrayList<>();
for (Resource resource : saveResources) {
String tmpName = resource.getFilename().replace("-save.json","");
if (!logPaths.contains(tmpName)){
String tmpName = resource.getFilename().replace("-save.json", "");
if (!logPaths.contains(tmpName)) {
continue;
}
byte[] data = Files.readAllBytes(resource.getFile().toPath());
monitoringDatas.add(gson.fromJson(new String(data), MonitoringData.class));
}
modelMap.put("monitoringDatas", monitoringDatas);
modelMap.put("balance", gunbotProxyService.getBTCBalance("default"));
return new ModelAndView("index",modelMap);
String market = "default";
if (gunbotProxyService.isUsingMultipleMarkets()) {
market = "BTC";
}
modelMap.put("balance", gunbotProxyService.getBTCBalance(market));
return new ModelAndView("index", modelMap);
}
}

View File

@ -187,7 +187,7 @@ public class GunbotProxyService {
.onFailedAttempt(this::handleException)
.get(() -> analyzeResult(publicClient.returnTicker()));
if (logger.getLevel().isLessSpecificThan(Level.DEBUG)) {
if (logger.getLevel().isMoreSpecificThan(Level.INFO)) {
logger.info("ticker updated");
} else {
logger.info("ticker: " + result);
@ -215,14 +215,6 @@ public class GunbotProxyService {
return getCompleteBalancesScheduled(market);
}
@Cacheable(value = "balances", key = "#market")
public double getBTCBalance(String market) {
String result = getBalancesScheduled(market);
JsonElement jsonElement = new JsonParser().parse(result);
JsonObject jsonObject = jsonElement.getAsJsonObject();
return jsonObject.get("BTC").getAsDouble();
}
@CachePut(value = "completeBalances", key = "#market")
public String getCompleteBalancesScheduled(String market) {
PoloniexTradingAPIClient tradingAPIClient = getMarketDefaultTradingClient(market);
@ -233,14 +225,22 @@ public class GunbotProxyService {
return result;
}
@CachePut(value = "balances", key = "market")
public String getBalancesScheduled(String market) {
@Cacheable(value = "balances", key = "#market")
public double getBTCBalance(String market) {
return getBalancesScheduled(market);
}
@CachePut(value = "balances", key = "#market")
public double getBalancesScheduled(String market) {
PoloniexTradingAPIClient tradingAPIClient = getMarketDefaultTradingClient(market);
String result = Failsafe.with(retryPolicy)
.onFailedAttempt(this::handleException)
.get(() -> analyzeResult(tradingAPIClient.returnBalances()));
logger.debug("balances" + result);
return result;
JsonElement jsonElement = new JsonParser().parse(result);
JsonObject jsonObject = jsonElement.getAsJsonObject();
return jsonObject.get("BTC").getAsDouble();
}
@Cacheable(value = "openOrders", key = "#market", sync = true)

View File

@ -121,4 +121,12 @@ public class ScheduledTasks {
}
}
@Scheduled(fixedDelay = 10000)
public void updateBalances() {
String market = "default";
if (gunbotProxyService.isUsingMultipleMarkets()) {
market = "BTC";
}
gunbotProxyService.getBalancesScheduled(market);
}
}

View File

@ -2,7 +2,7 @@
<diskStore path="cache" />
<cache
name="tradeHistory"
maxElementsInMemory="10000"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
@ -11,7 +11,7 @@
<cache
name="openOrders"
maxElementsInMemory="10000"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
@ -20,7 +20,7 @@
<cache
name="completeBalances"
maxElementsInMemory="10000"
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
@ -29,7 +29,7 @@
<cache
name="chartData"
maxElementsInMemory="10000"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="10"
@ -38,7 +38,7 @@
<cache
name="ticker"
maxElementsInMemory="10000"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
@ -47,11 +47,20 @@
<cache
name="buyOrderProtection"
maxElementsInMemory="10000"
maxElementsInMemory="500"
eternal="false"
timeToIdleSeconds="30"
timeToLiveSeconds="30"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" />
<cache
name="balances"
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" />
</ehcache>

View File

@ -2,7 +2,7 @@ set sp=--server.port=443
set sks=--server.ssl.key-store=classpath:poloniex.keystore
set sksp=--server.ssl.key-store-password=poloniex
set skp=--server.ssl.key-password=poloniex
set gbl=--gunbot.location=file://C:/Users/Elroy/OneDrive/Documents/GUNBOT_v3.3.2
set gbl=--gunbot.location=file://C:/Users/Elroy/Documents/GUNBOT_v3.3.2
set lnl=--logging.level.nl.komtek=DEBUG
@ -14,5 +14,5 @@ REM This apiKey will do the buying and selling and orders canceling stuff. You c
set a=--apiKey1=another apiKey
set as=--apiSecret1=your secret
java -jar GunbotProxyCommunity-0.9.2.jar %sp% %sks% %sksp% %skp% %da% %ds% %a% %as% %lnl%
java -jar GunbotProxyCommunity-0.9.5.jar %sp% %sks% %sksp% %skp% %da% %ds% %a% %as% %lnl%
pause