DealsData class
This commit is contained in:
parent
b695ed1121
commit
a8f58d59ac
|
|
@ -46,7 +46,6 @@ public class InstanceInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getTraderTime(String exchange) throws IOException {
|
public static double getTraderTime(String exchange) throws IOException {
|
||||||
//Uptime request
|
|
||||||
Request uptimeRequest = new Request.Builder()
|
Request uptimeRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/trader_time")
|
.url(API_BASE_URL + "/" + exchange + "/trader_time")
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
|
|
@ -63,19 +62,44 @@ public class InstanceInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<String> getLastTradesFromExchange(String exchange) throws IOException {
|
||||||
|
Request dealsRequest = new Request.Builder()
|
||||||
|
.url(API_BASE_URL + "/" + exchange + "/get_deals_cache")
|
||||||
|
.header("X-API-KEY", API_KEY)
|
||||||
|
.build();
|
||||||
|
try (Response statsResponse = httpClient.newCall(dealsRequest).execute()) {
|
||||||
|
if (!statsResponse.isSuccessful()) {
|
||||||
|
throw new IOException("Unexpected code " + statsResponse);
|
||||||
|
}
|
||||||
|
String dealsResponseBody = statsResponse.body().string();
|
||||||
|
JsonElement jsonElement = JsonParser.parseString(dealsResponseBody);
|
||||||
|
if (!jsonElement.isJsonObject()) {
|
||||||
|
System.err.println("The parsed JSON response is not a JsonObject.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
if (!jsonObject.has("Deals")) {
|
||||||
|
System.err.println("The parsed JSON response does not contain the deals key.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return a list of items of the format:
|
||||||
|
//(timestamp,pair,amount,exchange_name,order_id,order_history)
|
||||||
|
//order history always is an empty string when querying the deals cache
|
||||||
|
//It can be safely ignored
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getLastLogs(int amount) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ExchangeStatsData getExchangeStatsData(String exchange) throws IOException {
|
public static ExchangeStatsData getExchangeStatsData(String exchange) throws IOException {
|
||||||
//This needs to do A LOT of work
|
//This needs to do A LOT of work
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//All workers stats request
|
//All workers stats request
|
||||||
Request allWorkersStatsRequest = new Request.Builder()
|
Request allWorkersStatsRequest = new Request.Builder()
|
||||||
.url(API_BASE_URL + "/" + exchange + "/get_all_worker_status")
|
.url(API_BASE_URL + "/" + exchange + "/get_all_worker_status")
|
||||||
|
|
@ -88,10 +112,10 @@ public class InstanceInterface {
|
||||||
.header("X-API-KEY", API_KEY)
|
.header("X-API-KEY", API_KEY)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static double getTodaysProfit(String jsonResponse) {
|
private static double getTodaysProfit(String jsonResponse) {
|
||||||
try {
|
try {
|
||||||
JsonElement jsonElement = JsonParser.parseString(jsonResponse);
|
JsonElement jsonElement = JsonParser.parseString(jsonResponse);
|
||||||
|
|
@ -220,6 +244,30 @@ public class InstanceInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class DealData {
|
||||||
|
private final double timestamp;
|
||||||
|
private final String pair;
|
||||||
|
private final String exchangeName;
|
||||||
|
private final String orderId;
|
||||||
|
private final String orderHistory;
|
||||||
|
|
||||||
|
public DealData(double timestamp, String pair, String exchangeName, String orderId, String orderHistory) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
this.pair = pair;
|
||||||
|
this.exchangeName = exchangeName;
|
||||||
|
this.orderId = orderId;
|
||||||
|
this.orderHistory = orderHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTimestamp() { return timestamp; }
|
||||||
|
public String getPair() { return pair; }
|
||||||
|
public String getExchangeName() { return exchangeName; }
|
||||||
|
public String getOrderId() { return orderId; }
|
||||||
|
public String getOrderHistory() { return orderHistory; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class InstanceGlobalStatsData {
|
public static class InstanceGlobalStatsData {
|
||||||
private final String instanceName;
|
private final String instanceName;
|
||||||
private final double instanceUptime;
|
private final double instanceUptime;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue