populateHome
This commit is contained in:
parent
7fb26c6a99
commit
3caa546223
|
|
@ -434,7 +434,7 @@ public class HomeFragment extends Fragment {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceInterface.ProfitStatsData profitsData = null;
|
InstanceInterface.ProfitStatsData profitsData;
|
||||||
try {
|
try {
|
||||||
profitsData = future4.get();
|
profitsData = future4.get();
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
|
@ -454,25 +454,9 @@ public class HomeFragment extends Fragment {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<InstanceInterface.DealData> deals;
|
||||||
try {
|
try {
|
||||||
List<InstanceInterface.DealData> deals = future9.get();
|
deals = future9.get();
|
||||||
if (deals != null) {
|
|
||||||
StringBuilder dealsList = new StringBuilder();
|
|
||||||
for (InstanceInterface.DealData deal : deals) {
|
|
||||||
String timestamp = timeStampConverter(deal.getTimestamp());
|
|
||||||
String pair = deal.getPair();
|
|
||||||
String amount = String.format(Locale.ROOT,"%.2f", deal.getAmount());
|
|
||||||
String exchange = Character.toUpperCase(deal.getExchangeName().charAt(0)) + deal.getExchangeName().substring(1);
|
|
||||||
dealsList.append(timestamp)
|
|
||||||
.append(" | ")
|
|
||||||
.append(pair)
|
|
||||||
.append(" | ")
|
|
||||||
.append(amount)
|
|
||||||
.append(" USDT | ")
|
|
||||||
.append(exchange).append("\n");
|
|
||||||
}
|
|
||||||
lastTrades.setText(dealsList);
|
|
||||||
}
|
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
@ -490,165 +474,7 @@ public class HomeFragment extends Fragment {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateHome(priceData, priceData2, priceData3, profitsData, binanceStats, gateioStats, kucoinStats, okexStats, deals, logs1, logs2, logs3, logs4);
|
||||||
if (priceData!= null) {
|
|
||||||
pricePair1.setText(String.format(Locale.ROOT, "%.2f", priceData.getCurrentPrice()));
|
|
||||||
pricePair124hPercentage.setText(formatPercentage(priceData.getPriceChangePercent24h()));
|
|
||||||
pricePair17dPercentage.setText(formatPercentage(priceData.getPriceChangePercent7d()));
|
|
||||||
pricePair130dPercentage.setText(formatPercentage(priceData.getPriceChangePercent30d()));
|
|
||||||
setPercentageColor(pricePair124hPercentage, priceData.getPriceChangePercent24h());
|
|
||||||
setPercentageColor(pricePair17dPercentage, priceData.getPriceChangePercent7d());
|
|
||||||
setPercentageColor(pricePair130dPercentage, priceData.getPriceChangePercent30d());
|
|
||||||
|
|
||||||
pricePair2.setText(String.format(Locale.ROOT, "%.2f", priceData2.getCurrentPrice()));
|
|
||||||
pricePair224hPercentage.setText(formatPercentage(priceData2.getPriceChangePercent24h()));
|
|
||||||
pricePair27dPercentage.setText(formatPercentage(priceData2.getPriceChangePercent7d()));
|
|
||||||
pricePair230dPercentage.setText(formatPercentage(priceData2.getPriceChangePercent30d()));
|
|
||||||
setPercentageColor(pricePair224hPercentage, priceData2.getPriceChangePercent24h());
|
|
||||||
setPercentageColor(pricePair27dPercentage, priceData2.getPriceChangePercent7d());
|
|
||||||
setPercentageColor(pricePair230dPercentage, priceData2.getPriceChangePercent30d());
|
|
||||||
|
|
||||||
pricePair3.setText(String.format(Locale.ROOT, "%.2f", priceData3.getCurrentPrice()));
|
|
||||||
pricePair324hPercentage.setText(formatPercentage(priceData3.getPriceChangePercent24h()));
|
|
||||||
pricePair37dPercentage.setText(formatPercentage(priceData3.getPriceChangePercent7d()));
|
|
||||||
pricePair330dPercentage.setText(formatPercentage(priceData3.getPriceChangePercent30d()));
|
|
||||||
setPercentageColor(pricePair324hPercentage, priceData3.getPriceChangePercent24h());
|
|
||||||
setPercentageColor(pricePair37dPercentage, priceData3.getPriceChangePercent7d());
|
|
||||||
setPercentageColor(pricePair330dPercentage, priceData3.getPriceChangePercent30d());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profitsData != null) {
|
|
||||||
profitsToday.setText(String.format(Locale.ROOT, "%.2f", profitsData.getProfitsToday()));
|
|
||||||
profitsThisMonth.setText(String.format(Locale.ROOT, "%.2f", profitsData.getProfitsThisMonth()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Exchange stats
|
|
||||||
int timeoutForYellow = 30*1000; //30 seconds - Should be in the config file
|
|
||||||
int timeoutForRed = 120*1000; //2 minutes - Should be in the config file
|
|
||||||
//Icons
|
|
||||||
if (binanceStats!=null){
|
|
||||||
if (binanceStats.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
|
||||||
exchange1Status.setImageResource(R.drawable.ic_red_circle_48);
|
|
||||||
System.err.println(binanceStats.getLastSeen());}
|
|
||||||
else if (binanceStats.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
|
||||||
exchange1Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
|
||||||
else {
|
|
||||||
exchange1Status.setImageResource(R.drawable.ic_green_circle_48);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gateioStats != null){
|
|
||||||
if (gateioStats.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
|
||||||
exchange2Status.setImageResource(R.drawable.ic_red_circle_48);
|
|
||||||
System.err.println(gateioStats.getLastSeen());}
|
|
||||||
else if (gateioStats.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
|
||||||
exchange2Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
|
||||||
else {
|
|
||||||
exchange2Status.setImageResource(R.drawable.ic_green_circle_48);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (kucoinStats != null) {
|
|
||||||
if (kucoinStats.getLastSeen() * 1000 + timeoutForRed < System.currentTimeMillis()) {
|
|
||||||
exchange3Status.setImageResource(R.drawable.ic_red_circle_48);
|
|
||||||
System.err.println(kucoinStats.getLastSeen());
|
|
||||||
} else if (kucoinStats.getLastSeen() * 1000 + timeoutForYellow < System.currentTimeMillis()) {
|
|
||||||
exchange3Status.setImageResource(R.drawable.ic_yellow_circle_48);
|
|
||||||
} else {
|
|
||||||
exchange3Status.setImageResource(R.drawable.ic_green_circle_48);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (okexStats != null) {
|
|
||||||
if (okexStats.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
|
||||||
exchange4Status.setImageResource(R.drawable.ic_red_circle_48);
|
|
||||||
System.err.println(okexStats.getLastSeen());
|
|
||||||
}
|
|
||||||
else if (okexStats.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
|
||||||
exchange4Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
|
||||||
else {
|
|
||||||
exchange4Status.setImageResource(R.drawable.ic_green_circle_48);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Funds available
|
|
||||||
if (binanceStats != null) {
|
|
||||||
String binanceFundsAvailable = String.format(Locale.ROOT, "%.2f", binanceStats.getFundsAvailable());
|
|
||||||
String binanceFundsNeeded = String.format(Locale.ROOT, "%.2f", binanceStats.getFundsNeeded());
|
|
||||||
String binanceFunds = binanceFundsAvailable + "/" + binanceFundsNeeded;
|
|
||||||
double binanceFundsPercentage = 69.4231337;
|
|
||||||
if (binanceStats.getFundsNeeded() != 0) {
|
|
||||||
binanceFundsPercentage = 100 - (binanceStats.getFundsNeeded() - binanceStats.getFundsAvailable()) / binanceStats.getFundsNeeded() * 100;
|
|
||||||
}
|
|
||||||
String binanceFundsPercentageString = String.format(Locale.ROOT, "%.2f", binanceFundsPercentage) + "%";
|
|
||||||
exchange1Funds.setText(binanceFunds);
|
|
||||||
exchange1FundsPercentage.setText(binanceFundsPercentageString);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gateioStats != null) {
|
|
||||||
String gateioFundsAvailable = String.format(Locale.ROOT, "%.2f", gateioStats.getFundsAvailable());
|
|
||||||
String gateioFundsNeeded = String.format(Locale.ROOT, "%.2f", gateioStats.getFundsNeeded());
|
|
||||||
String gateioFunds = gateioFundsAvailable + "/" + gateioFundsNeeded;
|
|
||||||
double gateioFundsPercentage = 69.4231337;
|
|
||||||
if (gateioStats.getFundsNeeded() != 0) {
|
|
||||||
gateioFundsPercentage = 100 - (gateioStats.getFundsNeeded() - gateioStats.getFundsAvailable()) / gateioStats.getFundsNeeded() * 100;
|
|
||||||
}
|
|
||||||
String gateioFundsPercentageString = String.format(Locale.ROOT, "%.2f", gateioFundsPercentage) + "%";
|
|
||||||
exchange2Funds.setText(gateioFunds);
|
|
||||||
exchange2FundsPercentage.setText(gateioFundsPercentageString);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kucoinStats != null) {
|
|
||||||
String kucoinFundsAvailable = String.format(Locale.ROOT, "%.2f", kucoinStats.getFundsAvailable());
|
|
||||||
String kucoinFundsNeeded = String.format(Locale.ROOT, "%.2f", kucoinStats.getFundsNeeded());
|
|
||||||
String kucoinFunds = kucoinFundsAvailable + "/" + kucoinFundsNeeded;
|
|
||||||
double kucoinFundsPercentage = 69.4231337;
|
|
||||||
if (kucoinStats.getFundsNeeded() != 0) {
|
|
||||||
kucoinFundsPercentage = 100 - (kucoinStats.getFundsNeeded() - kucoinStats.getFundsAvailable()) / kucoinStats.getFundsNeeded() * 100;
|
|
||||||
}
|
|
||||||
String kucoinFundsPercentageString = String.format(Locale.ROOT, "%.2f", kucoinFundsPercentage) + "%";
|
|
||||||
exchange3Funds.setText(kucoinFunds);
|
|
||||||
exchange3FundsPercentage.setText(kucoinFundsPercentageString);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (okexStats != null) {
|
|
||||||
String okexFundsAvailable = String.format(Locale.ROOT, "%.2f", okexStats.getFundsAvailable());
|
|
||||||
String okexFundsNeeded = String.format(Locale.ROOT, "%.2f", okexStats.getFundsNeeded());
|
|
||||||
String okexFunds = okexFundsAvailable + "/" + okexFundsNeeded;
|
|
||||||
double okexFundsPercentage = 69.4231337;
|
|
||||||
if (okexStats.getFundsNeeded() != 0) {
|
|
||||||
okexFundsPercentage = 100 - (okexStats.getFundsNeeded() - okexStats.getFundsAvailable()) / okexStats.getFundsNeeded() * 100;
|
|
||||||
}
|
|
||||||
String okexFundsPercentageString = String.format(Locale.ROOT, "%.2f", okexFundsPercentage) + "%";
|
|
||||||
exchange4Funds.setText(okexFunds);
|
|
||||||
exchange4FundsPercentage.setText(okexFundsPercentageString);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Populate logs
|
|
||||||
log1Content.setText(logs1);
|
|
||||||
log2Content.setText(logs2);
|
|
||||||
log3Content.setText(logs3);
|
|
||||||
log4Content.setText(logs4);
|
|
||||||
|
|
||||||
// Exchange stats
|
|
||||||
|
|
||||||
|
|
||||||
if (binanceStats != null) {
|
|
||||||
exchange1WorkersOnline.setText(String.valueOf(binanceStats.getOnlineWorkers()));
|
|
||||||
String longShortWorkers = String.valueOf(binanceStats.getLongWorkers()) + "/" + String.valueOf(binanceStats.getShortWorkers());
|
|
||||||
exchange1WorkersLongShort.setText(longShortWorkers);
|
|
||||||
}
|
|
||||||
if (gateioStats != null) {
|
|
||||||
exchange2WorkersOnline.setText(String.valueOf(gateioStats.getOnlineWorkers()));
|
|
||||||
String longShortWorkers = String.valueOf(gateioStats.getLongWorkers()) + "/" + String.valueOf(gateioStats.getShortWorkers());
|
|
||||||
exchange2WorkersLongShort.setText(longShortWorkers);
|
|
||||||
}
|
|
||||||
if (kucoinStats != null) {
|
|
||||||
exchange3WorkersOnline.setText(String.valueOf(kucoinStats.getOnlineWorkers()));
|
|
||||||
String longShortWorkers = String.valueOf(kucoinStats.getLongWorkers()) + "/" + String.valueOf(kucoinStats.getShortWorkers());
|
|
||||||
exchange3WorkersLongShort.setText(longShortWorkers);
|
|
||||||
}
|
|
||||||
if (okexStats != null) {
|
|
||||||
exchange4WorkersOnline.setText(String.valueOf(okexStats.getOnlineWorkers()));
|
|
||||||
String longShortWorkers = String.valueOf(okexStats.getLongWorkers()) + "/" + String.valueOf(okexStats.getShortWorkers());
|
|
||||||
exchange4WorkersLongShort.setText(longShortWorkers);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -664,6 +490,209 @@ public class HomeFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void populateHome(TickerTracker.PriceChangeData firstTickerChangeData,
|
||||||
|
TickerTracker.PriceChangeData secondTickerChangeData,
|
||||||
|
TickerTracker.PriceChangeData thirdTickerChangeData,
|
||||||
|
InstanceInterface.ProfitStatsData profitsData,
|
||||||
|
InstanceInterface.ExchangeStatsData binanceData,
|
||||||
|
InstanceInterface.ExchangeStatsData gateioData,
|
||||||
|
InstanceInterface.ExchangeStatsData kucoinData,
|
||||||
|
InstanceInterface.ExchangeStatsData okexData,
|
||||||
|
List<InstanceInterface.DealData> dealData,
|
||||||
|
String binanceLogs,
|
||||||
|
String gateioLogs,
|
||||||
|
String kucoinLogs,
|
||||||
|
String okexLogs) {
|
||||||
|
|
||||||
|
if (firstTickerChangeData!= null) {
|
||||||
|
pricePair1.setText(String.format(Locale.ROOT, "%.2f", firstTickerChangeData.getCurrentPrice()));
|
||||||
|
pricePair124hPercentage.setText(formatPercentage(firstTickerChangeData.getPriceChangePercent24h()));
|
||||||
|
pricePair17dPercentage.setText(formatPercentage(firstTickerChangeData.getPriceChangePercent7d()));
|
||||||
|
pricePair130dPercentage.setText(formatPercentage(firstTickerChangeData.getPriceChangePercent30d()));
|
||||||
|
setPercentageColor(pricePair124hPercentage, firstTickerChangeData.getPriceChangePercent24h());
|
||||||
|
setPercentageColor(pricePair17dPercentage, firstTickerChangeData.getPriceChangePercent7d());
|
||||||
|
setPercentageColor(pricePair130dPercentage, firstTickerChangeData.getPriceChangePercent30d());
|
||||||
|
}
|
||||||
|
if (secondTickerChangeData != null) {
|
||||||
|
pricePair2.setText(String.format(Locale.ROOT, "%.2f", secondTickerChangeData.getCurrentPrice()));
|
||||||
|
pricePair224hPercentage.setText(formatPercentage(secondTickerChangeData.getPriceChangePercent24h()));
|
||||||
|
pricePair27dPercentage.setText(formatPercentage(secondTickerChangeData.getPriceChangePercent7d()));
|
||||||
|
pricePair230dPercentage.setText(formatPercentage(secondTickerChangeData.getPriceChangePercent30d()));
|
||||||
|
setPercentageColor(pricePair224hPercentage, secondTickerChangeData.getPriceChangePercent24h());
|
||||||
|
setPercentageColor(pricePair27dPercentage, secondTickerChangeData.getPriceChangePercent7d());
|
||||||
|
setPercentageColor(pricePair230dPercentage, secondTickerChangeData.getPriceChangePercent30d());
|
||||||
|
}
|
||||||
|
if (thirdTickerChangeData != null) {
|
||||||
|
pricePair3.setText(String.format(Locale.ROOT, "%.2f", thirdTickerChangeData.getCurrentPrice()));
|
||||||
|
pricePair324hPercentage.setText(formatPercentage(thirdTickerChangeData.getPriceChangePercent24h()));
|
||||||
|
pricePair37dPercentage.setText(formatPercentage(thirdTickerChangeData.getPriceChangePercent7d()));
|
||||||
|
pricePair330dPercentage.setText(formatPercentage(thirdTickerChangeData.getPriceChangePercent30d()));
|
||||||
|
setPercentageColor(pricePair324hPercentage, thirdTickerChangeData.getPriceChangePercent24h());
|
||||||
|
setPercentageColor(pricePair37dPercentage, thirdTickerChangeData.getPriceChangePercent7d());
|
||||||
|
setPercentageColor(pricePair330dPercentage, thirdTickerChangeData.getPriceChangePercent30d());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profitsData != null) {
|
||||||
|
profitsToday.setText(String.format(Locale.ROOT, "%.2f", profitsData.getProfitsToday()));
|
||||||
|
profitsThisMonth.setText(String.format(Locale.ROOT, "%.2f", profitsData.getProfitsThisMonth()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int timeoutForYellow = 30*1000; //30 seconds - Should be in the config file
|
||||||
|
int timeoutForRed = 120*1000; //2 minutes - Should be in the config file
|
||||||
|
|
||||||
|
//Icons
|
||||||
|
if (binanceData!=null){
|
||||||
|
if (binanceData.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
||||||
|
exchange1Status.setImageResource(R.drawable.ic_red_circle_48);
|
||||||
|
System.err.println(binanceData.getLastSeen());}
|
||||||
|
else if (binanceData.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
||||||
|
exchange1Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
||||||
|
else {
|
||||||
|
exchange1Status.setImageResource(R.drawable.ic_green_circle_48);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gateioData != null){
|
||||||
|
if (gateioData.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
||||||
|
exchange2Status.setImageResource(R.drawable.ic_red_circle_48);
|
||||||
|
System.err.println(gateioData.getLastSeen());}
|
||||||
|
else if (gateioData.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
||||||
|
exchange2Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
||||||
|
else {
|
||||||
|
exchange2Status.setImageResource(R.drawable.ic_green_circle_48);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (kucoinData != null) {
|
||||||
|
if (kucoinData.getLastSeen() * 1000 + timeoutForRed < System.currentTimeMillis()) {
|
||||||
|
exchange3Status.setImageResource(R.drawable.ic_red_circle_48);
|
||||||
|
System.err.println(kucoinData.getLastSeen());
|
||||||
|
} else if (kucoinData.getLastSeen() * 1000 + timeoutForYellow < System.currentTimeMillis()) {
|
||||||
|
exchange3Status.setImageResource(R.drawable.ic_yellow_circle_48);
|
||||||
|
} else {
|
||||||
|
exchange3Status.setImageResource(R.drawable.ic_green_circle_48);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (okexData != null) {
|
||||||
|
if (okexData.getLastSeen()*1000+timeoutForRed < System.currentTimeMillis()) {
|
||||||
|
exchange4Status.setImageResource(R.drawable.ic_red_circle_48);
|
||||||
|
System.err.println(okexData.getLastSeen());
|
||||||
|
}
|
||||||
|
else if (okexData.getLastSeen()*1000+timeoutForYellow < System.currentTimeMillis()) {
|
||||||
|
exchange4Status.setImageResource(R.drawable.ic_yellow_circle_48);}
|
||||||
|
else {
|
||||||
|
exchange4Status.setImageResource(R.drawable.ic_green_circle_48);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Funds available
|
||||||
|
if (binanceData != null) {
|
||||||
|
String binanceFundsAvailable = String.format(Locale.ROOT, "%.2f", binanceData.getFundsAvailable());
|
||||||
|
String binanceFundsNeeded = String.format(Locale.ROOT, "%.2f", binanceData.getFundsNeeded());
|
||||||
|
String binanceFunds = binanceFundsAvailable + "/" + binanceFundsNeeded;
|
||||||
|
double binanceFundsPercentage = 69.4231337;
|
||||||
|
if (binanceData.getFundsNeeded() != 0) {
|
||||||
|
binanceFundsPercentage = 100 - (binanceData.getFundsNeeded() - binanceData.getFundsAvailable()) / binanceData.getFundsNeeded() * 100;
|
||||||
|
}
|
||||||
|
String binanceFundsPercentageString = String.format(Locale.ROOT, "%.2f", binanceFundsPercentage) + "%";
|
||||||
|
exchange1Funds.setText(binanceFunds);
|
||||||
|
exchange1FundsPercentage.setText(binanceFundsPercentageString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gateioData != null) {
|
||||||
|
String gateioFundsAvailable = String.format(Locale.ROOT, "%.2f", gateioData.getFundsAvailable());
|
||||||
|
String gateioFundsNeeded = String.format(Locale.ROOT, "%.2f", gateioData.getFundsNeeded());
|
||||||
|
String gateioFunds = gateioFundsAvailable + "/" + gateioFundsNeeded;
|
||||||
|
double gateioFundsPercentage = 69.4231337;
|
||||||
|
if (gateioData.getFundsNeeded() != 0) {
|
||||||
|
gateioFundsPercentage = 100 - (gateioData.getFundsNeeded() - gateioData.getFundsAvailable()) / gateioData.getFundsNeeded() * 100;
|
||||||
|
}
|
||||||
|
String gateioFundsPercentageString = String.format(Locale.ROOT, "%.2f", gateioFundsPercentage) + "%";
|
||||||
|
exchange2Funds.setText(gateioFunds);
|
||||||
|
exchange2FundsPercentage.setText(gateioFundsPercentageString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kucoinData != null) {
|
||||||
|
String kucoinFundsAvailable = String.format(Locale.ROOT, "%.2f", kucoinData.getFundsAvailable());
|
||||||
|
String kucoinFundsNeeded = String.format(Locale.ROOT, "%.2f", kucoinData.getFundsNeeded());
|
||||||
|
String kucoinFunds = kucoinFundsAvailable + "/" + kucoinFundsNeeded;
|
||||||
|
double kucoinFundsPercentage = 69.4231337;
|
||||||
|
if (kucoinData.getFundsNeeded() != 0) {
|
||||||
|
kucoinFundsPercentage = 100 - (kucoinData.getFundsNeeded() - kucoinData.getFundsAvailable()) / kucoinData.getFundsNeeded() * 100;
|
||||||
|
}
|
||||||
|
String kucoinFundsPercentageString = String.format(Locale.ROOT, "%.2f", kucoinFundsPercentage) + "%";
|
||||||
|
exchange3Funds.setText(kucoinFunds);
|
||||||
|
exchange3FundsPercentage.setText(kucoinFundsPercentageString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (okexData != null) {
|
||||||
|
String okexFundsAvailable = String.format(Locale.ROOT, "%.2f", okexData.getFundsAvailable());
|
||||||
|
String okexFundsNeeded = String.format(Locale.ROOT, "%.2f", okexData.getFundsNeeded());
|
||||||
|
String okexFunds = okexFundsAvailable + "/" + okexFundsNeeded;
|
||||||
|
double okexFundsPercentage = 69.4231337;
|
||||||
|
if (okexData.getFundsNeeded() != 0) {
|
||||||
|
okexFundsPercentage = 100 - (okexData.getFundsNeeded() - okexData.getFundsAvailable()) / okexData.getFundsNeeded() * 100;
|
||||||
|
}
|
||||||
|
String okexFundsPercentageString = String.format(Locale.ROOT, "%.2f", okexFundsPercentage) + "%";
|
||||||
|
exchange4Funds.setText(okexFunds);
|
||||||
|
exchange4FundsPercentage.setText(okexFundsPercentageString);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exchange stats
|
||||||
|
if (binanceData != null) {
|
||||||
|
exchange1WorkersOnline.setText(String.valueOf(binanceData.getOnlineWorkers()));
|
||||||
|
String longShortWorkers = String.valueOf(binanceData.getLongWorkers()) + "/" + String.valueOf(binanceData.getShortWorkers());
|
||||||
|
exchange1WorkersLongShort.setText(longShortWorkers);
|
||||||
|
}
|
||||||
|
if (gateioData != null) {
|
||||||
|
exchange2WorkersOnline.setText(String.valueOf(gateioData.getOnlineWorkers()));
|
||||||
|
String longShortWorkers = String.valueOf(gateioData.getLongWorkers()) + "/" + String.valueOf(gateioData.getShortWorkers());
|
||||||
|
exchange2WorkersLongShort.setText(longShortWorkers);
|
||||||
|
}
|
||||||
|
if (kucoinData != null) {
|
||||||
|
exchange3WorkersOnline.setText(String.valueOf(kucoinData.getOnlineWorkers()));
|
||||||
|
String longShortWorkers = String.valueOf(kucoinData.getLongWorkers()) + "/" + String.valueOf(kucoinData.getShortWorkers());
|
||||||
|
exchange3WorkersLongShort.setText(longShortWorkers);
|
||||||
|
}
|
||||||
|
if (okexData != null) {
|
||||||
|
exchange4WorkersOnline.setText(String.valueOf(okexData.getOnlineWorkers()));
|
||||||
|
String longShortWorkers = String.valueOf(okexData.getLongWorkers()) + "/" + String.valueOf(okexData.getShortWorkers());
|
||||||
|
exchange4WorkersLongShort.setText(longShortWorkers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dealData != null) {
|
||||||
|
StringBuilder dealsList = new StringBuilder();
|
||||||
|
for (InstanceInterface.DealData deal : dealData) {
|
||||||
|
String timestamp = timeStampConverter(deal.getTimestamp());
|
||||||
|
String pair = deal.getPair();
|
||||||
|
String amount = String.format(Locale.ROOT,"%.2f", deal.getAmount());
|
||||||
|
String exchange = Character.toUpperCase(deal.getExchangeName().charAt(0)) + deal.getExchangeName().substring(1);
|
||||||
|
dealsList.append(timestamp)
|
||||||
|
.append(" | ")
|
||||||
|
.append(pair)
|
||||||
|
.append(" | ")
|
||||||
|
.append(amount)
|
||||||
|
.append(" USDT | ")
|
||||||
|
.append(exchange).append("\n");
|
||||||
|
}
|
||||||
|
lastTrades.setText(dealsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Populate logs
|
||||||
|
if (binanceLogs != null) {
|
||||||
|
log1Content.setText(binanceLogs);
|
||||||
|
}
|
||||||
|
if (gateioLogs != null) {
|
||||||
|
log2Content.setText(gateioLogs);
|
||||||
|
}
|
||||||
|
if (kucoinLogs != null) {
|
||||||
|
log3Content.setText(kucoinLogs);
|
||||||
|
}
|
||||||
|
if (okexLogs != null) {
|
||||||
|
log4Content.setText(okexLogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String timeStampConverter(double timestamp) {
|
public static String timeStampConverter(double timestamp) {
|
||||||
long linuxTimestamp = (long) timestamp; // Replace with your timestamp
|
long linuxTimestamp = (long) timestamp; // Replace with your timestamp
|
||||||
Date date = new Date(linuxTimestamp * 1000); // Multiply by 1000 to convert to milliseconds
|
Date date = new Date(linuxTimestamp * 1000); // Multiply by 1000 to convert to milliseconds
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue