bugfix with empty old_long

This commit is contained in:
Nicolás Sánchez 2025-03-27 11:56:35 -03:00
parent b5ba20af81
commit ddc3e272bc
2 changed files with 23 additions and 17 deletions

View File

@ -650,9 +650,11 @@ public class InstanceInterface {
double price = value.has("price") && value.get("price").isJsonPrimitive() ? value.get("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;
String tpOrderId = value.has("tp_order_id") && value.get("tp_order_id").isJsonPrimitive() ? value.get("tp_order_id").getAsString() : null;
String tpOrderId = "";
//String tpOrderId = value.has("tp_order_id") && value.get("tp_order_id").isJsonPrimitive() ? value.get("tp_order_id").getAsString() : null;
JsonObject takeProfitOrder = value.get("take_profit_order").getAsJsonObject();
String safetyOrderId = value.has("so_order_id") && value.get("so_order_id").isJsonPrimitive() ? value.get("so_order_id").getAsString() : null;
String safetyOrderId = "";
//String safetyOrderId = value.has("so_order_id") && value.get("so_order_id").isJsonPrimitive() ? value.get("so_order_id").getAsString() : null;
JsonObject safetyOrder = value.get("safety_order").getAsJsonObject();
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;
@ -665,13 +667,15 @@ public class InstanceInterface {
OldLongDictionary oldLongDictionary = null;
if (value.has("old_long")) {
oldLong = value.get("old_long").getAsJsonObject();
oldLongDictionary = new OldLongDictionary(
oldLong.get("datetime").getAsString(),
oldLong.get("fees_paid_in_quote").getAsDouble(),
oldLong.get("quote_spent").getAsDouble(),
oldLong.get("tp_amount").getAsDouble(),
oldLong.get("tp_price").getAsDouble()
);
if (!oldLong.entrySet().isEmpty()) {
oldLongDictionary = new OldLongDictionary(
oldLong.get("datetime").getAsString(),
oldLong.get("fees_paid_in_quote").getAsDouble(),
oldLong.get("quote_spent").getAsDouble(),
oldLong.get("tp_amount").getAsDouble(),
oldLong.get("tp_price").getAsDouble()
);
}
}
valueToReturn.add(new WorkerStatsData(
@ -710,7 +714,7 @@ public class InstanceInterface {
statusString
));
} catch (Exception e) {
System.err.println("Error processing JSON for key '" + key + "': " + e.getMessage());
System.err.println("In getAllWorkerStats: Error processing JSON for key '" + key + "': " + e.getMessage());
}
}
}

View File

@ -108,13 +108,15 @@ public class WorkerInterface {
InstanceInterface.OldLongDictionary oldLongDictionary = null;
if (value.has("old_long")) {
oldLong = value.get("old_long").getAsJsonObject();
oldLongDictionary = new InstanceInterface.OldLongDictionary(
oldLong.get("datetime").getAsString(),
oldLong.get("fees_paid_in_quote").getAsDouble(),
oldLong.get("quote_spent").getAsDouble(),
oldLong.get("tp_amount").getAsDouble(),
oldLong.get("tp_price").getAsDouble()
);
if (!oldLong.entrySet().isEmpty()) {
oldLongDictionary = new InstanceInterface.OldLongDictionary(
oldLong.get("datetime").getAsString(),
oldLong.get("fees_paid_in_quote").getAsDouble(),
oldLong.get("quote_spent").getAsDouble(),
oldLong.get("tp_amount").getAsDouble(),
oldLong.get("tp_price").getAsDouble()
);
}
}
valueToReturn = new InstanceInterface.WorkerStatsData(