(String[] args)
| 16 | public class WatchTrades { |
| 17 | |
| 18 | public static void main(String[] args) throws Exception { |
| 19 | String symbol = args.length > 0 ? args[0] : "BTC/USDT"; |
| 20 | |
| 21 | Binance exchange = new Binance(); |
| 22 | exchange.verbose = false; |
| 23 | |
| 24 | System.out.println("Loading markets..."); |
| 25 | exchange.loadMarkets(false); |
| 26 | System.out.println("Watching " + symbol + " trades (10 batches)...\n"); |
| 27 | |
| 28 | System.out.printf("%-26s %-5s %12s %12s %14s%n", |
| 29 | "Datetime", "Side", "Price", "Amount", "Cost"); |
| 30 | System.out.println("-".repeat(72)); |
| 31 | |
| 32 | int totalTrades = 0; |
| 33 | for (int i = 0; i < 10; i++) { |
| 34 | List<Trade> trades = exchange.watchTrades(symbol); |
| 35 | |
| 36 | // Print only the latest trades from this batch |
| 37 | int start = Math.max(0, trades.size() - 5); |
| 38 | for (int j = start; j < trades.size(); j++) { |
| 39 | Trade t = trades.get(j); |
| 40 | System.out.printf("%-26s %-5s %12s %12s %14s%n", |
| 41 | t.datetime, |
| 42 | t.side, |
| 43 | t.price, |
| 44 | t.amount, |
| 45 | t.cost); |
| 46 | } |
| 47 | totalTrades += trades.size(); |
| 48 | } |
| 49 | |
| 50 | System.out.println("\nTotal trades received: " + totalTrades); |
| 51 | System.out.println("Done!"); |
| 52 | System.exit(0); |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected