@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof BinancePrice)) return false; BinancePrice other = (BinancePrice) obj; return pair.equals(other.pair) && price.equals(other.price); }
/** Return something like <code>btc_brl:83948239</code> */ public static String makeMercadoBitcoinOrderId(CurrencyPair currencyPair, String orderId) { String pair; if (currencyPair.equals(CurrencyPair.BTC_BRL)) { pair = "btc_brl"; } else if (currencyPair.equals(new CurrencyPair(Currency.LTC, Currency.BRL))) { pair = "ltc_brl"; } else { throw new NotAvailableFromExchangeException(); } return pair + ":" + orderId; }
: !this.currencyPair.equals(other.currencyPair)) { return false;
public BinancePrice tickerPrice(CurrencyPair pair) throws IOException { return tickerAllPrices() .stream() .filter(p -> p.getCurrencyPair().equals(pair)) .collect(StreamUtils.singletonCollector()); }
/** * @param pair * @return */ public static String toSymbol(CurrencyPair pair) { if (pair.equals(CurrencyPair.IOTA_BTC)) { return "IOTABTC"; } return pair.base.getCurrencyCode() + pair.counter.getCurrencyCode(); }
public static String toSymbol(CurrencyPair pair) { if (pair.equals(CurrencyPair.IOTA_BTC)) { return "IOTABTC"; } return pair.base.getCurrencyCode() + pair.counter.getCurrencyCode(); }
/** * @param pair * @return */ public static String toSymbol(CurrencyPair pair) { if (pair.equals(CurrencyPair.IOTA_BTC)) { return "IOTABTC"; } return pair.base.getCurrencyCode() + pair.counter.getCurrencyCode(); }
limitOrders.stream().allMatch(order -> order.getCurrencyPair().equals(currencyPair)); if (!valid) { throw new UnsupportedOperationException(
@Override default boolean accept(LimitOrder order) { return order != null && getCurrencyPair() != null && getCurrencyPair().equals(order.getCurrencyPair()); }
/** * Find and match an order with id in orders * * @param orders * @param order * @param id * @return */ public static boolean findLimitOrder(List<LimitOrder> orders, LimitOrder order, String id) { boolean found = false; for (LimitOrder openOrder : orders) { if (openOrder.getId().equalsIgnoreCase(id)) { if (order.getCurrencyPair().equals(openOrder.getCurrencyPair()) && (order.getOriginalAmount().compareTo(openOrder.getOriginalAmount()) == 0) && (order.getLimitPrice().compareTo(openOrder.getLimitPrice()) == 0)) { found = true; } } } return found; }
/** * The result is not the pure order id. It is a composition with the currency pair and the order * id (the same format used as parameter of {@link #cancelOrder}). Please see {@link * org.knowm.xchange.mercadobitcoin.MercadoBitcoinUtils#makeMercadoBitcoinOrderId} . */ @Override public String placeLimitOrder(LimitOrder limitOrder) throws IOException { String pair; if (limitOrder.getCurrencyPair().equals(CurrencyPair.BTC_BRL)) { pair = "btc_brl"; } else if (limitOrder.getCurrencyPair().equals(new CurrencyPair(Currency.LTC, Currency.BRL))) { pair = "ltc_brl"; } else { throw new NotAvailableFromExchangeException(); } String type; if (limitOrder.getType() == Order.OrderType.BID) { type = "buy"; } else { type = "sell"; } MercadoBitcoinBaseTradeApiResult<MercadoBitcoinPlaceLimitOrderResult> newOrderResult = mercadoBitcoinPlaceLimitOrder( pair, type, limitOrder.getOriginalAmount(), limitOrder.getLimitPrice()); return MercadoBitcoinUtils.makeMercadoBitcoinOrderId( limitOrder.getCurrencyPair(), newOrderResult.getTheReturn().keySet().iterator().next()); }
/** * Adapts a KoinimTicker to a Ticker Object * * @param koinimTicker The exchange specific ticker * @param currencyPair * @return The ticker */ public static Ticker adaptTicker(KoinimTicker koinimTicker, CurrencyPair currencyPair) { if (!currencyPair.equals(new CurrencyPair(BTC, TRY))) { throw new NotAvailableFromExchangeException(); } if (koinimTicker != null) { return new Ticker.Builder() .currencyPair(new CurrencyPair(BTC, Currency.TRY)) .last(koinimTicker.getSell()) .bid(koinimTicker.getBid()) .ask(koinimTicker.getAsk()) .high(koinimTicker.getHigh()) .low(koinimTicker.getLow()) .volume(koinimTicker.getVolume()) .vwap(koinimTicker.getAvg()) .build(); } return null; } }
if (!currencyPair.equals(new CurrencyPair(BTC, TRY))) { throw new NotAvailableFromExchangeException();
private String getChannelPostfix(CurrencyPair currencyPair) { if (currencyPair.equals(CurrencyPair.BTC_USD)) { return ""; } return "_" + currencyPair.base.toString().toLowerCase() + currencyPair.counter.toString().toLowerCase(); } }
public BinancePrice tickerPrice(CurrencyPair pair) throws IOException { return tickerAllPrices().stream() .filter(p -> p.getCurrencyPair().equals(pair)) .collect(StreamUtils.singletonCollector()); }
public static String toSymbol(CurrencyPair pair) { if (pair.equals(CurrencyPair.IOTA_BTC)) { return "IOTABTC"; } return pair.base.getCurrencyCode() + pair.counter.getCurrencyCode(); }
@Override default boolean accept(LimitOrder order) { return order != null && getCurrencyPair() != null && getCurrencyPair().equals(order.getCurrencyPair()); }
private Observable<BinanceRawTrade> rawTradeStream(CurrencyPair currencyPair) { return service.subscribeChannel(channelFromCurrency(currencyPair, "trade")) .map((JsonNode s) -> tradeTransaction(s.toString())) .filter(transaction -> transaction.getData().getCurrencyPair().equals(currencyPair) && transaction.getData().getEventType() == TRADE ) .map(transaction -> transaction.getData().getRawTrade()); }
private Observable<BinanceTicker24h> rawTickerStream(CurrencyPair currencyPair) { return service.subscribeChannel(channelFromCurrency(currencyPair, "ticker")) .map((JsonNode s) -> tickerTransaction(s.toString())) .filter(transaction -> transaction.getData().getCurrencyPair().equals(currencyPair) && transaction.getData().getEventType() == TICKER_24_HR) .map(transaction -> transaction.getData().getTicker()); }
private OrderbookSubscription connectOrderBook(CurrencyPair currencyPair) { OrderbookSubscription subscription = new OrderbookSubscription(); // 1. Open a stream to wss://stream.binance.com:9443/ws/bnbbtc@depth // 2. Buffer the events you receive from the stream. subscription.stream = service.subscribeChannel(channelFromCurrency(currencyPair, "depth")) .map((JsonNode s) -> depthTransaction(s.toString())) .filter(transaction -> transaction.getData().getCurrencyPair().equals(currencyPair) && transaction.getData().getEventType() == DEPTH_UPDATE); return subscription; }