Colored switch price on worker card
This commit is contained in:
parent
7931bbed12
commit
6bd530672c
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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_price<switch_price, set color to green
|
||||
nextSoPrice.setText(String.format(Locale.ROOT, "%.8f", worker.getNextSoPrice()));
|
||||
if (worker.isShort() &&
|
||||
worker.getOldLongDictionary()!=null &&
|
||||
worker.getOldLongDictionary().getTpAmount() * worker.getOldLongDictionary().getTpPrice() - worker.getTotalAmountOfQuote()>0 &&
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue