From 6bd530672c2ca9686e869749904b5bc7605552f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Wed, 25 Dec 2024 20:59:56 -0300 Subject: [PATCH] Colored switch price on worker card --- .../example/dcav2gui/ui/exchanges/WorkerData.java | 12 +++++++++++- .../ui/exchanges/adapters/WorkerCardAdapter.java | 15 +++++++++++++-- .../example/dcav2gui/ui/home/HomeFragment.java | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/dcav2gui/ui/exchanges/WorkerData.java b/app/src/main/java/com/example/dcav2gui/ui/exchanges/WorkerData.java index e4d0581..9e7a697 100644 --- a/app/src/main/java/com/example/dcav2gui/ui/exchanges/WorkerData.java +++ b/app/src/main/java/com/example/dcav2gui/ui/exchanges/WorkerData.java @@ -24,7 +24,6 @@ public class WorkerData { boolean isBoosted, boolean isAuto, boolean isPaused, boolean stopWhenProfit, InstanceInterface.OldLongDictionary oldLongDictionary) { - // TODO: Add total_amount_of_quote and total_amount_of_base this.pair = pair; this.amountOfSafetyOrders = amountOfSafetyOrders; this.maxSafetyOrders = maxSafetyOrders; @@ -57,4 +56,15 @@ public class WorkerData { public boolean isPaused() { return isPaused; } public boolean getStopWhenProfit() { return stopWhenProfit; } public InstanceInterface.OldLongDictionary getOldLongDictionary() { return oldLongDictionary; } + + public double getMinSwitchPrice() { + if (oldLongDictionary==null) return 0; + + double oldTarget = oldLongDictionary.getTpAmount() * oldLongDictionary.getTpPrice(); + double baseLeft = oldLongDictionary.getTpAmount() - totalAmountOfBase; + + if (baseLeft <= 0) return 0; + return (oldTarget - totalAmountOfQuote) / baseLeft; + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/dcav2gui/ui/exchanges/adapters/WorkerCardAdapter.java b/app/src/main/java/com/example/dcav2gui/ui/exchanges/adapters/WorkerCardAdapter.java index ca1ed41..e709607 100644 --- a/app/src/main/java/com/example/dcav2gui/ui/exchanges/adapters/WorkerCardAdapter.java +++ b/app/src/main/java/com/example/dcav2gui/ui/exchanges/adapters/WorkerCardAdapter.java @@ -79,8 +79,19 @@ public class WorkerCardAdapter{ //Cyan pair.setTextColor(Color.parseColor("#008B8B")); } + price.setText(String.format(Locale.ROOT, "%.8f", worker.getPrice())); + + //TODO: If short and old_long and next_so_price0 && + worker.getOldLongDictionary().getTpAmount() - worker.getTotalAmountOfBase() > 0 && + worker.getNextSoPrice()>worker.getMinSwitchPrice()) { + //Green + nextSoPrice.setTextColor(Color.parseColor("#00FF00")); + } takeProfitPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getTakeProfitPrice())); double percentageToProfit = abs(worker.getTakeProfitPrice()- worker.getPrice())/worker.getPrice()*100; @@ -88,7 +99,7 @@ public class WorkerCardAdapter{ percentage.setText(percentageToDisplay); if (percentageToProfit<1) { //Green - percentage.setTextColor(Color.parseColor("#006A00")); + percentage.setTextColor(Color.parseColor("#00FF00")); } else if (percentageToProfit>20) { //Red percentage.setTextColor(Color.parseColor("#FFFF0000")); @@ -96,7 +107,7 @@ public class WorkerCardAdapter{ //Yellow percentage.setTextColor(Color.parseColor("#FFA500")); } else { - percentage.setTextColor(Color.parseColor("#FF424242")); + percentage.setTextColor(Color.parseColor("#CACACA")); } String safetyOrdersToDisplay = worker.getAmountOfSafetyOrders()-1 + "/" + worker.getMaxSafetyOrders(); diff --git a/app/src/main/java/com/example/dcav2gui/ui/home/HomeFragment.java b/app/src/main/java/com/example/dcav2gui/ui/home/HomeFragment.java index 010b70e..4ff10c5 100644 --- a/app/src/main/java/com/example/dcav2gui/ui/home/HomeFragment.java +++ b/app/src/main/java/com/example/dcav2gui/ui/home/HomeFragment.java @@ -423,7 +423,7 @@ public class HomeFragment extends Fragment { } private void setPercentageColor(TextView textView, double percentage) { - int upColor = ContextCompat.getColor(requireContext(), R.color.dark_green); + int upColor = ContextCompat.getColor(requireContext(), R.color.bright_green); String formattedPercentage = formatPercentage(percentage); textView.setText(formattedPercentage);