wip
This commit is contained in:
parent
a4767708dd
commit
54c2247b6f
|
|
@ -2,6 +2,7 @@ package com.example.dcav2gui;
|
||||||
|
|
||||||
import static com.example.dcav2gui.MainActivity.globalSettings;
|
import static com.example.dcav2gui.MainActivity.globalSettings;
|
||||||
|
|
||||||
|
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
@ -449,6 +450,7 @@ public class InstanceInterface {
|
||||||
JsonObject oldLong = null;
|
JsonObject oldLong = null;
|
||||||
if (value.has("old_long")) {
|
if (value.has("old_long")) {
|
||||||
oldLong = value.get("old_long").getAsJsonObject();
|
oldLong = value.get("old_long").getAsJsonObject();
|
||||||
|
//translate from json to OldLongDictionary
|
||||||
}
|
}
|
||||||
|
|
||||||
valueToReturn.add(new WorkerStatsData(
|
valueToReturn.add(new WorkerStatsData(
|
||||||
|
|
@ -601,6 +603,34 @@ public class InstanceInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<WorkerData> fetchWorkersDataForCards(String exchange) throws IOException {
|
||||||
|
// Implement this method to fetch actual data
|
||||||
|
// call List<WorkerStatsData> getAllWorkersStats from InstanceInterface and
|
||||||
|
// translate all the WorkerStatsData objects to WorkerData objects!
|
||||||
|
// Example implementation:
|
||||||
|
List<InstanceInterface.WorkerStatsData> workerStatsDataList = InstanceInterface.getAllWorkersStats(exchange, true);
|
||||||
|
List<WorkerData> workerDataList = new ArrayList<>();
|
||||||
|
if (workerStatsDataList != null) {
|
||||||
|
for (InstanceInterface.WorkerStatsData workerStatsData : workerStatsDataList) {
|
||||||
|
WorkerData workerData = new WorkerData(
|
||||||
|
workerStatsData.getPair(),
|
||||||
|
workerStatsData.getSoAmount(),
|
||||||
|
workerStatsData.getNumberOfSafetyOrders(),
|
||||||
|
workerStatsData.getDealUptime(),
|
||||||
|
workerStatsData.getNextSoPrice(),
|
||||||
|
workerStatsData.getPrice(),
|
||||||
|
workerStatsData.getTakeProfitPrice(),
|
||||||
|
workerStatsData.getIsShort(),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
workerStatsData.getOldLongDictionary());
|
||||||
|
workerDataList.add(workerData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return workerDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class DealData {
|
public static class DealData {
|
||||||
private final double timestamp;
|
private final double timestamp;
|
||||||
|
|
@ -774,10 +804,10 @@ public class InstanceInterface {
|
||||||
private final String safetyPriceTable;
|
private final String safetyPriceTable;
|
||||||
private final String dealOrderHistory;
|
private final String dealOrderHistory;
|
||||||
private final String pauseReason;
|
private final String pauseReason;
|
||||||
private final JsonObject oldLongDictionary; //Change type
|
private final OldLongDictionary oldLongDictionary; //Change type
|
||||||
private final String statusString;
|
private final String statusString;
|
||||||
|
|
||||||
public WorkerStatsData(String pair, boolean isShort, boolean stopWhenProfit, double orderSize, double quoteSpent, double baseBought, int soAmount, int numberOfSafetyOrders, int tpMode, String profitTable, double startTime, double startPrice, double dealStartTime, double dealUptime, double totalUptime, double price, double takeProfitPrice, double nextSoPrice, String tpOrderId, JsonObject takeProfitOrder, String soOrderId, JsonObject safetyOrder, double feesPaidInBase, double feesPaidInQuote, double partialProfit, String safetyPriceTable, String dealOrderHistory, String pauseReason, JsonObject oldLong, String statusString) {
|
public WorkerStatsData(String pair, boolean isShort, boolean stopWhenProfit, double orderSize, double quoteSpent, double baseBought, int soAmount, int numberOfSafetyOrders, int tpMode, String profitTable, double startTime, double startPrice, double dealStartTime, double dealUptime, double totalUptime, double price, double takeProfitPrice, double nextSoPrice, String tpOrderId, JsonObject takeProfitOrder, String soOrderId, JsonObject safetyOrder, double feesPaidInBase, double feesPaidInQuote, double partialProfit, String safetyPriceTable, String dealOrderHistory, String pauseReason, OldLongDictionary oldLong, String statusString) {
|
||||||
this.pair = pair;
|
this.pair = pair;
|
||||||
this.isShort = isShort;
|
this.isShort = isShort;
|
||||||
this.stopWhenProfit = stopWhenProfit;
|
this.stopWhenProfit = stopWhenProfit;
|
||||||
|
|
@ -838,7 +868,7 @@ public class InstanceInterface {
|
||||||
public String getSafetyPriceTable() { return safetyPriceTable; }
|
public String getSafetyPriceTable() { return safetyPriceTable; }
|
||||||
public String getDealOrderHistory() { return dealOrderHistory; }
|
public String getDealOrderHistory() { return dealOrderHistory; }
|
||||||
public String getPauseReason() { return pauseReason; }
|
public String getPauseReason() { return pauseReason; }
|
||||||
public JsonObject getOldLongDictionary() { return oldLongDictionary; }
|
public OldLongDictionary getOldLongDictionary() { return oldLongDictionary; }
|
||||||
public String getStatusString() { return statusString; }
|
public String getStatusString() { return statusString; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.AndroidViewModel;
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
|
||||||
|
import com.example.dcav2gui.InstanceInterface;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -33,13 +39,17 @@ public class BinanceViewModel extends AndroidViewModel {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
// Fetch and update the data
|
// Fetch and update the data
|
||||||
List<WorkerData> newData = null; // Implement this method to fetch actual data
|
List<WorkerData> newData = InstanceInterface.fetchWorkersDataForCards("binance");
|
||||||
workerDataList.setValue(newData);
|
workerDataList.postValue(newData);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue