Compare commits
6 Commits
2025.05.16
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
8d3478820e | |
|
|
d621c5bf4a | |
|
|
5983fa244e | |
|
|
ab82f95a03 | |
|
|
94137f57e6 | |
|
|
614ca2f525 |
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-01-09T00:51:44.224576189Z">
|
<DropdownSelection timestamp="2025-09-05T19:18:31.537268933Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=ZY22FN7MHQ" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/home/nicolas/.android/avd/Pixel_6_Pro_API_34.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@ package com.example.dcav2gui;
|
||||||
|
|
||||||
import static com.example.dcav2gui.MainActivity.globalSettings;
|
import static com.example.dcav2gui.MainActivity.globalSettings;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
import com.example.dcav2gui.ui.exchanges.WorkerData;
|
||||||
|
import com.google.gson.Gson;
|
||||||
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;
|
||||||
|
|
@ -19,8 +22,10 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -377,6 +382,45 @@ public class InstanceInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static JsonObject modDefaultOrderSize(String exchange, double newOrderSize, boolean retry) throws IOException {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject jsonPayload = new JsonObject();
|
||||||
|
jsonPayload.addProperty("amount", String.valueOf(newOrderSize));
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
|
Request modDefaultOrderSizeRequest = new Request.Builder()
|
||||||
|
.url(API_BASE_URL + "/" + exchange + "/mod_default_order_size")
|
||||||
|
.header("X-API-KEY", API_KEY)
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response modDefaultOrderSizeResponse = httpClient.newCall(modDefaultOrderSizeRequest).execute()) {
|
||||||
|
if (!modDefaultOrderSizeResponse.isSuccessful()) {
|
||||||
|
if (modDefaultOrderSizeResponse.code() == 503 && retry) {
|
||||||
|
return modDefaultOrderSize(exchange, newOrderSize,false);
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected code " + modDefaultOrderSizeResponse);
|
||||||
|
}
|
||||||
|
String modDefaultOrderSizeResponseBody = modDefaultOrderSizeResponse.body().string();
|
||||||
|
JsonElement jsonElement = JsonParser.parseString(modDefaultOrderSizeResponseBody);
|
||||||
|
if (!jsonElement.isJsonObject()) {
|
||||||
|
System.err.println("The parsed JSON response is not a JsonObject.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
if (jsonObject.has("Error")) {
|
||||||
|
System.err.println("The parsed JSON response contains Error");
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If no error, the response is {"Success": f"Success. Default order size modified to $amount}"}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getAllLogs(String exchange, boolean retry) throws IOException {
|
public static String getAllLogs(String exchange, boolean retry) throws IOException {
|
||||||
//200 lines hard limit
|
//200 lines hard limit
|
||||||
Request logRequest = new Request.Builder()
|
Request logRequest = new Request.Builder()
|
||||||
|
|
@ -652,18 +696,22 @@ public class InstanceInterface {
|
||||||
double nextSoPrice = value.has("next_so_price") && value.get("next_so_price").isJsonPrimitive() ? value.get("next_so_price").getAsDouble() : 0.0;
|
double nextSoPrice = value.has("next_so_price") && value.get("next_so_price").isJsonPrimitive() ? value.get("next_so_price").getAsDouble() : 0.0;
|
||||||
JsonObject takeProfitOrder = null;
|
JsonObject takeProfitOrder = null;
|
||||||
String tpOrderId = "";
|
String tpOrderId = "";
|
||||||
JsonObject safetyOrder = null;
|
JsonArray safetyOrders = null;
|
||||||
String safetyOrderId = "";
|
String safetyOrderId = "";
|
||||||
JsonElement takeProfitOrderElement = value.get("take_profit_order");
|
JsonElement takeProfitOrderElement = value.get("take_profit_order");
|
||||||
if (takeProfitOrderElement!=null && !takeProfitOrderElement.isJsonNull() && takeProfitOrderElement.isJsonObject()) {
|
if (takeProfitOrderElement!=null && !takeProfitOrderElement.isJsonNull() && takeProfitOrderElement.isJsonObject()) {
|
||||||
takeProfitOrder = takeProfitOrderElement.getAsJsonObject();
|
takeProfitOrder = takeProfitOrderElement.getAsJsonObject();
|
||||||
tpOrderId = takeProfitOrder.has("id") && takeProfitOrder.get("id").isJsonPrimitive() ? takeProfitOrder.get("id").getAsString() : "";
|
tpOrderId = takeProfitOrder.has("id") && takeProfitOrder.get("id").isJsonPrimitive() ? takeProfitOrder.get("id").getAsString() : "";
|
||||||
}
|
}
|
||||||
JsonElement safetyOrderElement = value.get("safety_order");
|
JsonElement safetyOrderElements = value.get("safety_orders");
|
||||||
if (safetyOrderElement!=null && !safetyOrderElement.isJsonNull() && safetyOrderElement.isJsonObject()) {
|
if (safetyOrderElements!=null && !safetyOrderElements.isJsonNull() && safetyOrderElements.isJsonArray()) {
|
||||||
safetyOrder = safetyOrderElement.getAsJsonObject();
|
safetyOrders = safetyOrderElements.getAsJsonArray();
|
||||||
safetyOrderId = safetyOrder.has("id") && safetyOrder.get("id").isJsonPrimitive() ? safetyOrder.get("id").getAsString() : "";
|
if (!safetyOrders.isEmpty()) {
|
||||||
|
JsonObject firstSafetyOrder = safetyOrders.get(0).getAsJsonObject();
|
||||||
|
safetyOrderId = firstSafetyOrder.has("id") && firstSafetyOrder.get("id").isJsonPrimitive() ? firstSafetyOrder.get("id").getAsString() : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
int safetyOrdersFilled = value.has("safety_orders_filled") && value.get("safety_orders_filled").isJsonPrimitive() ? value.get("safety_orders_filled").getAsInt() : 0;
|
||||||
double feesPaidInBase = value.has("fees_paid_in_base") && value.get("fees_paid_in_base").isJsonPrimitive() ? value.get("fees_paid_in_base").getAsDouble() : 0.0;
|
double feesPaidInBase = value.has("fees_paid_in_base") && value.get("fees_paid_in_base").isJsonPrimitive() ? value.get("fees_paid_in_base").getAsDouble() : 0.0;
|
||||||
double feesPaidInQuote = value.has("fees_paid_in_quote") && value.get("fees_paid_in_quote").isJsonPrimitive() ? value.get("fees_paid_in_quote").getAsDouble() : 0.0;
|
double feesPaidInQuote = value.has("fees_paid_in_quote") && value.get("fees_paid_in_quote").isJsonPrimitive() ? value.get("fees_paid_in_quote").getAsDouble() : 0.0;
|
||||||
double partialProfit = value.has("partial_profit") && value.get("partial_profit").isJsonPrimitive() ? value.get("partial_profit").getAsDouble() : 0.0;
|
double partialProfit = value.has("partial_profit") && value.get("partial_profit").isJsonPrimitive() ? value.get("partial_profit").getAsDouble() : 0.0;
|
||||||
|
|
@ -711,7 +759,8 @@ public class InstanceInterface {
|
||||||
tpOrderId,
|
tpOrderId,
|
||||||
takeProfitOrder,
|
takeProfitOrder,
|
||||||
safetyOrderId,
|
safetyOrderId,
|
||||||
safetyOrder,
|
safetyOrders,
|
||||||
|
safetyOrdersFilled,
|
||||||
feesPaidInBase,
|
feesPaidInBase,
|
||||||
feesPaidInQuote,
|
feesPaidInQuote,
|
||||||
partialProfit,
|
partialProfit,
|
||||||
|
|
@ -843,6 +892,7 @@ public class InstanceInterface {
|
||||||
WorkerData workerData = new WorkerData(
|
WorkerData workerData = new WorkerData(
|
||||||
workerStatsData.getPair(),
|
workerStatsData.getPair(),
|
||||||
workerStatsData.getSoAmount(),
|
workerStatsData.getSoAmount(),
|
||||||
|
workerStatsData.getSafetyOrdersFilled(),
|
||||||
workerStatsData.getNumberOfSafetyOrders(),
|
workerStatsData.getNumberOfSafetyOrders(),
|
||||||
workerStatsData.getDealUptime(),
|
workerStatsData.getDealUptime(),
|
||||||
workerStatsData.getNextSoPrice(),
|
workerStatsData.getNextSoPrice(),
|
||||||
|
|
@ -1053,14 +1103,14 @@ public class InstanceInterface {
|
||||||
private final double dealStartTime;
|
private final double dealStartTime;
|
||||||
private final double dealUptime;
|
private final double dealUptime;
|
||||||
private final double totalUptime;
|
private final double totalUptime;
|
||||||
|
|
||||||
private final double price;
|
private final double price;
|
||||||
private final double takeProfitPrice;
|
private final double takeProfitPrice;
|
||||||
private final double nextSoPrice;
|
private final double nextSoPrice;
|
||||||
private final String tpOrderId;
|
private final String tpOrderId;
|
||||||
private final JsonObject takeProfitOrder;
|
private final JsonObject takeProfitOrder;
|
||||||
private final String soOrderId;
|
private final String soOrderId;
|
||||||
private final JsonObject safetyOrder;
|
private final JsonArray safetyOrders;
|
||||||
|
private final int safetyOrdersFilled;
|
||||||
private final double feesPaidInBase;
|
private final double feesPaidInBase;
|
||||||
private final double feesPaidInQuote;
|
private final double feesPaidInQuote;
|
||||||
private final double partialProfit;
|
private final double partialProfit;
|
||||||
|
|
@ -1070,7 +1120,7 @@ public class InstanceInterface {
|
||||||
private final OldLongDictionary oldLongDictionary; //Change type
|
private final OldLongDictionary oldLongDictionary; //Change type
|
||||||
private final String statusString;
|
private final String statusString;
|
||||||
|
|
||||||
public WorkerStatsData(String pair, boolean isShort, boolean isBoosted, boolean isPaused, boolean autoSwitchEnabled, 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) {
|
public WorkerStatsData(String pair, boolean isShort, boolean isBoosted, boolean isPaused, boolean autoSwitchEnabled, 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, JsonArray safetyOrders, int safetyOrdersFilled, 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.isBoosted = isBoosted;
|
this.isBoosted = isBoosted;
|
||||||
|
|
@ -1095,7 +1145,8 @@ public class InstanceInterface {
|
||||||
this.tpOrderId = tpOrderId;
|
this.tpOrderId = tpOrderId;
|
||||||
this.takeProfitOrder = takeProfitOrder;
|
this.takeProfitOrder = takeProfitOrder;
|
||||||
this.soOrderId = soOrderId;
|
this.soOrderId = soOrderId;
|
||||||
this.safetyOrder = safetyOrder;
|
this.safetyOrders = safetyOrders;
|
||||||
|
this.safetyOrdersFilled = safetyOrdersFilled;
|
||||||
this.feesPaidInBase = feesPaidInBase;
|
this.feesPaidInBase = feesPaidInBase;
|
||||||
this.feesPaidInQuote = feesPaidInQuote;
|
this.feesPaidInQuote = feesPaidInQuote;
|
||||||
this.partialProfit = partialProfit;
|
this.partialProfit = partialProfit;
|
||||||
|
|
@ -1129,7 +1180,8 @@ public class InstanceInterface {
|
||||||
public String getTpOrderId() { return tpOrderId; }
|
public String getTpOrderId() { return tpOrderId; }
|
||||||
public JsonObject getTakeProfitOrder() { return takeProfitOrder; }
|
public JsonObject getTakeProfitOrder() { return takeProfitOrder; }
|
||||||
public String getSoOrderId() { return soOrderId; }
|
public String getSoOrderId() { return soOrderId; }
|
||||||
public JsonObject getSafetyOrder() { return safetyOrder; }
|
public JsonArray getSafetyOrders() { return safetyOrders; }
|
||||||
|
public int getSafetyOrdersFilled() { return safetyOrdersFilled; }
|
||||||
public double getFeesPaidInBase() { return feesPaidInBase; }
|
public double getFeesPaidInBase() { return feesPaidInBase; }
|
||||||
public double getFeesPaidInQuote() { return feesPaidInQuote; }
|
public double getFeesPaidInQuote() { return feesPaidInQuote; }
|
||||||
public double getPartialProfit() { return partialProfit; }
|
public double getPartialProfit() { return partialProfit; }
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||||
import com.example.dcav2gui.ui.home.HomeFragment;
|
import com.example.dcav2gui.ui.home.HomeFragment;
|
||||||
import com.google.android.material.materialswitch.MaterialSwitch;
|
import com.google.android.material.materialswitch.MaterialSwitch;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
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;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
@ -94,9 +95,18 @@ public class WorkerInterface {
|
||||||
double takeProfitPrice = value.has("take_profit_price") && value.get("take_profit_price").isJsonPrimitive() ? value.get("take_profit_price").getAsDouble() : 0.0;
|
double takeProfitPrice = value.has("take_profit_price") && value.get("take_profit_price").isJsonPrimitive() ? value.get("take_profit_price").getAsDouble() : 0.0;
|
||||||
double nextSoPrice = value.has("next_so_price") && value.get("next_so_price").isJsonPrimitive() ? value.get("next_so_price").getAsDouble() : 0.0;
|
double nextSoPrice = value.has("next_so_price") && value.get("next_so_price").isJsonPrimitive() ? value.get("next_so_price").getAsDouble() : 0.0;
|
||||||
JsonObject takeProfitOrder = value.get("take_profit_order").getAsJsonObject();
|
JsonObject takeProfitOrder = value.get("take_profit_order").getAsJsonObject();
|
||||||
JsonObject safetyOrder = value.get("safety_order").getAsJsonObject();
|
JsonArray safetyOrders = null;
|
||||||
|
String safetyOrderId = "";
|
||||||
|
JsonElement safetyOrderElements = value.get("safety_orders");
|
||||||
|
if (safetyOrderElements!=null && !safetyOrderElements.isJsonNull() && safetyOrderElements.isJsonArray()) {
|
||||||
|
safetyOrders = safetyOrderElements.getAsJsonArray();
|
||||||
|
if (!safetyOrders.isEmpty()) {
|
||||||
|
JsonObject firstSafetyOrder = safetyOrders.get(0).getAsJsonObject();
|
||||||
|
safetyOrderId = firstSafetyOrder.has("id") && firstSafetyOrder.get("id").isJsonPrimitive() ? firstSafetyOrder.get("id").getAsString() : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int safetyOrdersFilled = value.has("safety_orders_filled") && value.get("safety_orders_filled").isJsonPrimitive() ? value.get("safety_orders_filled").getAsInt() : 0;
|
||||||
String tpOrderId = takeProfitOrder.has("id") && takeProfitOrder.get("id").isJsonPrimitive() ? takeProfitOrder.get("id").getAsString() : null;
|
String tpOrderId = takeProfitOrder.has("id") && takeProfitOrder.get("id").isJsonPrimitive() ? takeProfitOrder.get("id").getAsString() : null;
|
||||||
String safetyOrderId = safetyOrder.has("id") && safetyOrder.get("id").isJsonPrimitive() ? safetyOrder.get("id").getAsString() : null;
|
|
||||||
double feesPaidInBase = value.has("fees_paid_in_base") && value.get("fees_paid_in_base").isJsonPrimitive() ? value.get("fees_paid_in_base").getAsDouble() : 0.0;
|
double feesPaidInBase = value.has("fees_paid_in_base") && value.get("fees_paid_in_base").isJsonPrimitive() ? value.get("fees_paid_in_base").getAsDouble() : 0.0;
|
||||||
double feesPaidInQuote = value.has("fees_paid_in_quote") && value.get("fees_paid_in_quote").isJsonPrimitive() ? value.get("fees_paid_in_quote").getAsDouble() : 0.0;
|
double feesPaidInQuote = value.has("fees_paid_in_quote") && value.get("fees_paid_in_quote").isJsonPrimitive() ? value.get("fees_paid_in_quote").getAsDouble() : 0.0;
|
||||||
double partialProfit = value.has("partial_profit") && value.get("partial_profit").isJsonPrimitive() ? value.get("partial_profit").getAsDouble() : 0.0;
|
double partialProfit = value.has("partial_profit") && value.get("partial_profit").isJsonPrimitive() ? value.get("partial_profit").getAsDouble() : 0.0;
|
||||||
|
|
@ -144,7 +154,8 @@ public class WorkerInterface {
|
||||||
tpOrderId,
|
tpOrderId,
|
||||||
takeProfitOrder,
|
takeProfitOrder,
|
||||||
safetyOrderId,
|
safetyOrderId,
|
||||||
safetyOrder,
|
safetyOrders,
|
||||||
|
safetyOrdersFilled,
|
||||||
feesPaidInBase,
|
feesPaidInBase,
|
||||||
feesPaidInQuote,
|
feesPaidInQuote,
|
||||||
partialProfit,
|
partialProfit,
|
||||||
|
|
@ -639,6 +650,93 @@ public class WorkerInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JsonObject modConcurrentSafetyOrders(String exchange, String pair, int amount, boolean retry) throws IOException {
|
||||||
|
String[] pairBaseAndQuote = pair.split("/");
|
||||||
|
String base = pairBaseAndQuote[0];
|
||||||
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject jsonPayload = new JsonObject();
|
||||||
|
jsonPayload.addProperty("base", base);
|
||||||
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
jsonPayload.addProperty("amount", String.valueOf(amount));
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
|
Request modConcurrentSafetyOrdersRequest = new Request.Builder()
|
||||||
|
.url(API_BASE_URL + "/" + exchange + "/mod_concurrent_safety_orders")
|
||||||
|
.header("X-API-KEY", API_KEY)
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response modConcurrentSafetyOrdersResponse = httpClient.newCall(modConcurrentSafetyOrdersRequest).execute()) {
|
||||||
|
if (!modConcurrentSafetyOrdersResponse.isSuccessful()) {
|
||||||
|
if (modConcurrentSafetyOrdersResponse.code() == 503 && retry) {
|
||||||
|
return modConcurrentSafetyOrders(exchange, pair, amount,false);
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected code " + modConcurrentSafetyOrdersResponse);
|
||||||
|
}
|
||||||
|
String modConcurrentSafetyOrdersResponseBody = modConcurrentSafetyOrdersResponse.body().string();
|
||||||
|
JsonElement jsonElement = JsonParser.parseString(modConcurrentSafetyOrdersResponseBody);
|
||||||
|
if (!jsonElement.isJsonObject()) {
|
||||||
|
System.err.println("The parsed JSON response is not a JsonObject.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
if (jsonObject.has("Error")) {
|
||||||
|
System.err.println("The parsed JSON response contains Error");
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If no error, the response is {"Success": "Success. The change will take effect as new safety orders are sent or filled"}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static JsonObject modOrderSize(String exchange, String pair, double newOrderSize, boolean retry) throws IOException {
|
||||||
|
String[] pairBaseAndQuote = pair.split("/");
|
||||||
|
String base = pairBaseAndQuote[0];
|
||||||
|
String quote = pairBaseAndQuote[1];
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject jsonPayload = new JsonObject();
|
||||||
|
jsonPayload.addProperty("base", base);
|
||||||
|
jsonPayload.addProperty("quote", quote);
|
||||||
|
jsonPayload.addProperty("amount", String.valueOf(newOrderSize));
|
||||||
|
String jsonPayloadString = gson.toJson(jsonPayload);
|
||||||
|
|
||||||
|
RequestBody requestBody = RequestBody.create(jsonPayloadString, MediaType.get("application/json; charset=utf-8"));
|
||||||
|
Request modOrderSizeRequest = new Request.Builder()
|
||||||
|
.url(API_BASE_URL + "/" + exchange + "/mod_order_size")
|
||||||
|
.header("X-API-KEY", API_KEY)
|
||||||
|
.post(requestBody)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response modOrderSizeResponse = httpClient.newCall(modOrderSizeRequest).execute()) {
|
||||||
|
if (!modOrderSizeResponse.isSuccessful()) {
|
||||||
|
if (modOrderSizeResponse.code() == 503 && retry) {
|
||||||
|
return modOrderSize(exchange, pair, newOrderSize,false);
|
||||||
|
}
|
||||||
|
throw new IOException("Unexpected code " + modOrderSizeResponse);
|
||||||
|
}
|
||||||
|
String modOrderSizeResponseBody = modOrderSizeResponse.body().string();
|
||||||
|
JsonElement jsonElement = JsonParser.parseString(modOrderSizeResponseBody);
|
||||||
|
if (!jsonElement.isJsonObject()) {
|
||||||
|
System.err.println("The parsed JSON response is not a JsonObject.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
if (jsonObject.has("Error")) {
|
||||||
|
System.err.println("The parsed JSON response contains Error");
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If no error, the response is {"Success": "Success. The change will take effect when the next deal is started"}
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static JsonObject addSafetyOrders(String exchange, String pair, int amount, boolean retry) throws IOException {
|
public static JsonObject addSafetyOrders(String exchange, String pair, int amount, boolean retry) throws IOException {
|
||||||
String[] pairBaseAndQuote = pair.split("/");
|
String[] pairBaseAndQuote = pair.split("/");
|
||||||
|
|
@ -1023,6 +1121,77 @@ public class WorkerInterface {
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendModifyConcurrentSafetyOrdersCall(String exchange, String pair, Context context) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle("Modify concurrent safety orders of "+ pair);
|
||||||
|
|
||||||
|
final EditText input = new EditText(context);
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
|
input.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
builder.setView(input);
|
||||||
|
|
||||||
|
builder.setPositiveButton("Modify concurrent safety orders", (dialog, which) -> {
|
||||||
|
final int newAmount = Integer.parseInt(input.getText().toString());
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject response = WorkerInterface.modConcurrentSafetyOrders(exchange, pair, newAmount, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
showToggleDialog(response, context);
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Show an error dialog on the main thread
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
AlertDialog.Builder errorBuilder = new AlertDialog.Builder(context);
|
||||||
|
errorBuilder.setTitle("Error");
|
||||||
|
errorBuilder.setMessage("Failed to modify concurrent safety orders: " + e.getMessage());
|
||||||
|
errorBuilder.setPositiveButton("OK", null);
|
||||||
|
errorBuilder.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendModifyOrderSizeCall(String exchange, String pair, Context context) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle("Modify order size of "+ pair);
|
||||||
|
|
||||||
|
final EditText input = new EditText(context);
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
|
input.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
builder.setView(input);
|
||||||
|
|
||||||
|
builder.setPositiveButton("Modify", (dialog, which) -> {
|
||||||
|
final double newOrderSize = Double.parseDouble(input.getText().toString());
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject response = WorkerInterface.modOrderSize(exchange, pair, newOrderSize, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
showToggleDialog(response, context);
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Show an error dialog on the main thread
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
AlertDialog.Builder errorBuilder = new AlertDialog.Builder(context);
|
||||||
|
errorBuilder.setTitle("Error");
|
||||||
|
errorBuilder.setMessage("Failed to modify order size: " + e.getMessage());
|
||||||
|
errorBuilder.setPositiveButton("OK", null);
|
||||||
|
errorBuilder.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendAddSafetyOrdersCall(String exchange, String pair, Context context) {
|
public static void sendAddSafetyOrdersCall(String exchange, String pair, Context context) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
|
@ -1136,6 +1305,9 @@ public class WorkerInterface {
|
||||||
"Next safety order price: " + String.format(Locale.ROOT, numberFormat,result.getNextSoPrice()) + "\n" +
|
"Next safety order price: " + String.format(Locale.ROOT, numberFormat,result.getNextSoPrice()) + "\n" +
|
||||||
"Take profit order ID: " + result.getTpOrderId() + "\n" +
|
"Take profit order ID: " + result.getTpOrderId() + "\n" +
|
||||||
"Safety order ID: " + result.getSoOrderId() + "\n" +
|
"Safety order ID: " + result.getSoOrderId() + "\n" +
|
||||||
|
"Safety orders online: " + result.getSafetyOrders().size() + "\n" +
|
||||||
|
"Safety orders filled: " + result.getSafetyOrdersFilled() + "\n" +
|
||||||
|
"Max safety orders: " + result.getNumberOfSafetyOrders() + "\n" +
|
||||||
"Short: " + result.getIsShort() + "\n" +
|
"Short: " + result.getIsShort() + "\n" +
|
||||||
"Boosted: " + result.getIsBoosted() + "\n" +
|
"Boosted: " + result.getIsBoosted() + "\n" +
|
||||||
"Paused: " + result.getIsPaused() + "\n" + isPausedExtraString +
|
"Paused: " + result.getIsPaused() + "\n" + isPausedExtraString +
|
||||||
|
|
@ -1144,8 +1316,6 @@ public class WorkerInterface {
|
||||||
"Order size: " + result.getOrderSize() + "\n" +
|
"Order size: " + result.getOrderSize() + "\n" +
|
||||||
"Quote in deal: " + result.getQuoteSpent() + "\n" +
|
"Quote in deal: " + result.getQuoteSpent() + "\n" +
|
||||||
"Base in deal: " + result.getBaseBought() + "\n" +
|
"Base in deal: " + result.getBaseBought() + "\n" +
|
||||||
"Safety orders sent: " + (result.getSoAmount()-1) + "\n" +
|
|
||||||
"Max safety orders: " + result.getNumberOfSafetyOrders() + "\n" +
|
|
||||||
"Start time: " + HomeFragment.timeStampConverter(result.getStartTime(), false) + "\n" +
|
"Start time: " + HomeFragment.timeStampConverter(result.getStartTime(), false) + "\n" +
|
||||||
"Total uptime: " + WorkerCardAdapter.formatSeconds(result.getTotalUptime()) + "\n" +
|
"Total uptime: " + WorkerCardAdapter.formatSeconds(result.getTotalUptime()) + "\n" +
|
||||||
"Start price: " + String.format(Locale.ROOT, numberFormat,result.getStartPrice()) + "\n" +
|
"Start price: " + String.format(Locale.ROOT, numberFormat,result.getStartPrice()) + "\n" +
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,12 @@ public class BinanceFragment extends Fragment implements WorkerCardAdapter.OnCar
|
||||||
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
||||||
WorkerInterface.sendSwitchQuoteCurrencyCall("binance", pair, getContext());
|
WorkerInterface.sendSwitchQuoteCurrencyCall("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modConcurrentSafetyOrders) {
|
||||||
|
WorkerInterface.sendModifyConcurrentSafetyOrdersCall("binance", pair, getContext());
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modOrderSize) {
|
||||||
|
WorkerInterface.sendModifyOrderSizeCall("binance", pair, getContext());
|
||||||
|
return true;
|
||||||
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
||||||
WorkerInterface.sendAddSafetyOrdersCall("binance", pair, getContext());
|
WorkerInterface.sendAddSafetyOrdersCall("binance", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,12 @@ public class GateioFragment extends Fragment implements WorkerCardAdapter.OnCard
|
||||||
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
||||||
WorkerInterface.sendSwitchQuoteCurrencyCall("gateio", pair, getContext());
|
WorkerInterface.sendSwitchQuoteCurrencyCall("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modConcurrentSafetyOrders) {
|
||||||
|
WorkerInterface.sendModifyConcurrentSafetyOrdersCall("gateio", pair, getContext());
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modOrderSize) {
|
||||||
|
WorkerInterface.sendModifyOrderSizeCall("gateio", pair, getContext());
|
||||||
|
return true;
|
||||||
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
||||||
WorkerInterface.sendAddSafetyOrdersCall("gateio", pair, getContext());
|
WorkerInterface.sendAddSafetyOrdersCall("gateio", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,12 @@ public class KucoinFragment extends Fragment implements WorkerCardAdapter.OnCard
|
||||||
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
||||||
WorkerInterface.sendSwitchQuoteCurrencyCall("kucoin", pair, getContext());
|
WorkerInterface.sendSwitchQuoteCurrencyCall("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modConcurrentSafetyOrders) {
|
||||||
|
WorkerInterface.sendModifyConcurrentSafetyOrdersCall("kucoin", pair, getContext());
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modOrderSize) {
|
||||||
|
WorkerInterface.sendModifyOrderSizeCall("kucoin", pair, getContext());
|
||||||
|
return true;
|
||||||
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
||||||
WorkerInterface.sendAddSafetyOrdersCall("kucoin", pair, getContext());
|
WorkerInterface.sendAddSafetyOrdersCall("kucoin", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,12 @@ public class OkxFragment extends Fragment implements WorkerCardAdapter.OnCardLon
|
||||||
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
} else if (item.getItemId() == R.id.switchQuoteCurrency) {
|
||||||
WorkerInterface.sendSwitchQuoteCurrencyCall("okex", pair, getContext());
|
WorkerInterface.sendSwitchQuoteCurrencyCall("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modConcurrentSafetyOrders) {
|
||||||
|
WorkerInterface.sendModifyConcurrentSafetyOrdersCall("okex", pair, getContext());
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.modOrderSize) {
|
||||||
|
WorkerInterface.sendModifyOrderSizeCall("okex", pair, getContext());
|
||||||
|
return true;
|
||||||
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
} else if (item.getItemId() == R.id.addSafetyOrders) {
|
||||||
WorkerInterface.sendAddSafetyOrdersCall("okex", pair, getContext());
|
WorkerInterface.sendAddSafetyOrdersCall("okex", pair, getContext());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.example.dcav2gui.InstanceInterface;
|
||||||
public class WorkerData {
|
public class WorkerData {
|
||||||
private final String pair;
|
private final String pair;
|
||||||
private final int amountOfSafetyOrders;
|
private final int amountOfSafetyOrders;
|
||||||
|
private final int safetyOrdersFilled;
|
||||||
private final int maxSafetyOrders;
|
private final int maxSafetyOrders;
|
||||||
private final double uptime;
|
private final double uptime;
|
||||||
private final double nextSoPrice;
|
private final double nextSoPrice;
|
||||||
|
|
@ -19,13 +20,14 @@ public class WorkerData {
|
||||||
private final boolean stopWhenProfit;
|
private final boolean stopWhenProfit;
|
||||||
private final InstanceInterface.OldLongDictionary oldLongDictionary;
|
private final InstanceInterface.OldLongDictionary oldLongDictionary;
|
||||||
|
|
||||||
public WorkerData(String pair, int amountOfSafetyOrders, int maxSafetyOrders, double uptime,
|
public WorkerData(String pair, int amountOfSafetyOrders, int safetyOrdersFilled, int maxSafetyOrders, double uptime,
|
||||||
double nextSoPrice, double price, double takeProfitPrice, double totalAmountOfQuote, double totalAmountOfBase, boolean isShort,
|
double nextSoPrice, double price, double takeProfitPrice, double totalAmountOfQuote, double totalAmountOfBase, boolean isShort,
|
||||||
boolean isBoosted, boolean isAuto, boolean isPaused, boolean stopWhenProfit,
|
boolean isBoosted, boolean isAuto, boolean isPaused, boolean stopWhenProfit,
|
||||||
InstanceInterface.OldLongDictionary oldLongDictionary) {
|
InstanceInterface.OldLongDictionary oldLongDictionary) {
|
||||||
|
|
||||||
this.pair = pair;
|
this.pair = pair;
|
||||||
this.amountOfSafetyOrders = amountOfSafetyOrders;
|
this.amountOfSafetyOrders = amountOfSafetyOrders;
|
||||||
|
this.safetyOrdersFilled = safetyOrdersFilled;
|
||||||
this.maxSafetyOrders = maxSafetyOrders;
|
this.maxSafetyOrders = maxSafetyOrders;
|
||||||
this.uptime = uptime;
|
this.uptime = uptime;
|
||||||
this.nextSoPrice = nextSoPrice;
|
this.nextSoPrice = nextSoPrice;
|
||||||
|
|
@ -43,6 +45,7 @@ public class WorkerData {
|
||||||
|
|
||||||
public String getPair() { return pair; }
|
public String getPair() { return pair; }
|
||||||
public int getAmountOfSafetyOrders() { return amountOfSafetyOrders; }
|
public int getAmountOfSafetyOrders() { return amountOfSafetyOrders; }
|
||||||
|
public int getSafetyOrdersFilled() { return safetyOrdersFilled; }
|
||||||
public int getMaxSafetyOrders() { return maxSafetyOrders; }
|
public int getMaxSafetyOrders() { return maxSafetyOrders; }
|
||||||
public double getUptime() { return uptime; }
|
public double getUptime() { return uptime; }
|
||||||
public double getNextSoPrice() { return nextSoPrice; }
|
public double getNextSoPrice() { return nextSoPrice; }
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class WorkerCardAdapter{
|
||||||
percentage.setTextColor(Color.parseColor("#CACACA"));
|
percentage.setTextColor(Color.parseColor("#CACACA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String safetyOrdersToDisplay = worker.getAmountOfSafetyOrders()-1 + "/" + worker.getMaxSafetyOrders();
|
String safetyOrdersToDisplay = worker.getSafetyOrdersFilled() + "/" + worker.getMaxSafetyOrders();
|
||||||
safetyOrders.setText(safetyOrdersToDisplay);
|
safetyOrders.setText(safetyOrdersToDisplay);
|
||||||
|
|
||||||
uptime.setText(formatSeconds(worker.getUptime()));
|
uptime.setText(formatSeconds(worker.getUptime()));
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
package com.example.dcav2gui.ui.home;
|
package com.example.dcav2gui.ui.home;
|
||||||
|
|
||||||
import static com.example.dcav2gui.InstanceInterface.getLastNTrades;
|
import static com.example.dcav2gui.InstanceInterface.getLastNTrades;
|
||||||
|
import static com.example.dcav2gui.WorkerInterface.showToggleDialog;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
|
|
@ -16,6 +19,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
|
@ -34,6 +38,7 @@ import com.example.dcav2gui.InstanceInterface;
|
||||||
import com.example.dcav2gui.MainActivity;
|
import com.example.dcav2gui.MainActivity;
|
||||||
import com.example.dcav2gui.R;
|
import com.example.dcav2gui.R;
|
||||||
import com.example.dcav2gui.TickerTracker;
|
import com.example.dcav2gui.TickerTracker;
|
||||||
|
import com.example.dcav2gui.WorkerInterface;
|
||||||
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
import com.example.dcav2gui.ui.exchanges.adapters.WorkerCardAdapter;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
|
@ -348,6 +353,9 @@ public class HomeFragment extends Fragment {
|
||||||
} else if (item.getItemId() == R.id.exchangeMenuConfigFile) {
|
} else if (item.getItemId() == R.id.exchangeMenuConfigFile) {
|
||||||
fetchExchangeConfig(exchange, true);
|
fetchExchangeConfig(exchange, true);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.exchangeModDefaultOrderSize) {
|
||||||
|
sendModifyDefaultOrderSizeCall(exchange, getContext());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -540,6 +548,43 @@ public class HomeFragment extends Fragment {
|
||||||
return shortWorkers;
|
return shortWorkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendModifyDefaultOrderSizeCall(String exchange, Context context) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle("Modify default order size of "+ exchange);
|
||||||
|
|
||||||
|
final EditText input = new EditText(context);
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||||
|
input.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
builder.setView(input);
|
||||||
|
|
||||||
|
builder.setPositiveButton("Modify", (dialog, which) -> {
|
||||||
|
final double newOrderSize = Double.parseDouble(input.getText().toString());
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
JsonObject response = InstanceInterface.modDefaultOrderSize(exchange, newOrderSize, true);
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
showToggleDialog(response, context);
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// Show an error dialog on the main thread
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
|
AlertDialog.Builder errorBuilder = new AlertDialog.Builder(context);
|
||||||
|
errorBuilder.setTitle("Error");
|
||||||
|
errorBuilder.setMessage("Failed to modify default order size: " + e.getMessage());
|
||||||
|
errorBuilder.setPositiveButton("OK", null);
|
||||||
|
errorBuilder.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showLastTradesDetailsDialog(List<InstanceInterface.DealData> result) {
|
private void showLastTradesDetailsDialog(List<InstanceInterface.DealData> result) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
List<String> shortWorkers = new ArrayList<>();
|
List<String> shortWorkers = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,6 @@
|
||||||
android:title="View paused traders" />
|
android:title="View paused traders" />
|
||||||
<item android:id="@+id/exchangeMenuConfigFile"
|
<item android:id="@+id/exchangeMenuConfigFile"
|
||||||
android:title="View config file" />
|
android:title="View config file" />
|
||||||
|
<item android:id="@+id/exchangeModDefaultOrderSize"
|
||||||
|
android:title="Modify default order size" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
@ -42,6 +42,10 @@
|
||||||
<item android:id="@+id/workerMenuAdd"
|
<item android:id="@+id/workerMenuAdd"
|
||||||
android:title="Add...">
|
android:title="Add...">
|
||||||
<menu>
|
<menu>
|
||||||
|
<item android:id="@+id/modOrderSize"
|
||||||
|
android:title="Modify order size"/>
|
||||||
|
<item android:id="@+id/modConcurrentSafetyOrders"
|
||||||
|
android:title="Modify concurrent safety orders"/>
|
||||||
<item android:id="@+id/addSafetyOrders"
|
<item android:id="@+id/addSafetyOrders"
|
||||||
android:title="Add safety orders"/>
|
android:title="Add safety orders"/>
|
||||||
<item android:id="@+id/addQuote"
|
<item android:id="@+id/addQuote"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name" translatable="false">DCAv2GUI</string>
|
<string name="app_name" translatable="false">DCAv2GUI</string>
|
||||||
<string name="nav_header_title" translatable="false">DCAv2</string>
|
<string name="nav_header_title" translatable="false">DCAv2</string>
|
||||||
<string name="nav_header_subtitle">Version 2025.04.07</string>
|
<string name="nav_header_subtitle">Version 2025.09.06</string>
|
||||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
<string name="nav_header_desc">Navigation header</string>
|
<string name="nav_header_desc">Navigation header</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue