MCPcopy Index your code
hub / github.com/ccxt/ccxt / main

Method main

java/lib/src/test/java/io/github/ccxt/types/LiveTest.java:23–101  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

21 }
22
23 public static void main(String[] args) throws Exception {
24 System.out.println("=== CCXT Java Typed Wrapper - Live Test (binance) ===\n");
25
26 // 1. Create exchange instance
27 var exchange = new Binance();
28 exchange.verbose = false;
29
30 // 2. Load markets
31 System.out.println("[1] Loading markets...");
32 Map<String, MarketInterface> markets = exchange.loadMarkets(false);
33 check(markets.size() > 0, "markets should not be empty");
34 System.out.println(" Loaded " + markets.size() + " markets");
35 MarketInterface btcUsdt = markets.get("BTC/USDT");
36 if (btcUsdt != null) {
37 check(btcUsdt.symbol != null, "symbol should not be null");
38 System.out.println(" BTC/USDT: id=" + btcUsdt.id + " type=" + btcUsdt.type
39 + " spot=" + btcUsdt.spot + " active=" + btcUsdt.active);
40 if (btcUsdt.precision != null) {
41 System.out.println(" precision: amount=" + btcUsdt.precision.amount + " price=" + btcUsdt.precision.price);
42 }
43 if (btcUsdt.limits != null && btcUsdt.limits.amount != null) {
44 System.out.println(" limits.amount: min=" + btcUsdt.limits.amount.min + " max=" + btcUsdt.limits.amount.max);
45 }
46 }
47 System.out.println(" PASS\n");
48
49 // 3. Fetch ticker
50 System.out.println("[2] Fetching BTC/USDT ticker...");
51 Ticker ticker = exchange.fetchTicker("BTC/USDT");
52 check(ticker.symbol != null, "ticker.symbol should not be null");
53 check(ticker.last != null && ticker.last > 0, "ticker.last should be > 0");
54 System.out.println(" symbol=" + ticker.symbol + " last=" + ticker.last + " bid=" + ticker.bid + " ask=" + ticker.ask);
55 System.out.println(" high=" + ticker.high + " low=" + ticker.low + " volume=" + ticker.baseVolume);
56 System.out.println(" PASS\n");
57
58 // 4. Fetch order book
59 System.out.println("[3] Fetching BTC/USDT order book...");
60 OrderBook ob = exchange.fetchOrderBook("BTC/USDT");
61 check(ob.bids != null && !ob.bids.isEmpty(), "orderbook bids should not be empty");
62 check(ob.asks != null && !ob.asks.isEmpty(), "orderbook asks should not be empty");
63 System.out.println(" bids=" + ob.bids.size() + " asks=" + ob.asks.size());
64 System.out.println(" best bid: " + ob.bids.get(0).get(0) + " x " + ob.bids.get(0).get(1));
65 System.out.println(" best ask: " + ob.asks.get(0).get(0) + " x " + ob.asks.get(0).get(1));
66 check(ob.bids.get(0).get(0) > 0, "bid price should be > 0");
67 System.out.println(" PASS\n");
68
69 // 5. Fetch recent trades
70 System.out.println("[4] Fetching BTC/USDT trades...");
71 List<Trade> trades = exchange.fetchTrades("BTC/USDT");
72 check(trades != null && !trades.isEmpty(), "trades should not be empty");
73 System.out.println(" got " + trades.size() + " trades");
74 Trade first = trades.get(0);
75 check(first.price != null && first.price > 0, "trade.price should be > 0");
76 check(first.amount != null && first.amount > 0, "trade.amount should be > 0");
77 System.out.println(" first: " + first.datetime + " " + first.side + " " + first.amount + " @ " + first.price);
78 System.out.println(" PASS\n");
79
80 // 6. Fetch OHLCV (using typed wrapper with optional params)

Callers

nothing calls this directly

Calls 9

loadMarketsMethod · 0.95
checkMethod · 0.95
fetchTickerMethod · 0.95
fetchOrderBookMethod · 0.95
fetchTradesMethod · 0.95
fetchOHLCVMethod · 0.95
fetchTickerAsyncMethod · 0.95
isEmptyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected