private static CurrencyPair adaptCurrencyPair(String pair) { // Currency pair is in the format: "BCH:USD" return new CurrencyPair(pair.replace(":", "/")); } }
public static CurrencyPair adaptSymbol(String symbol) { int pairLength = symbol.length(); if (symbol.endsWith("USDT")) { return new CurrencyPair(symbol.substring(0, pairLength - 4), "USDT"); } else { return new CurrencyPair( symbol.substring(0, pairLength - 3), symbol.substring(pairLength - 3)); } }
private static CurrencyPair adaptCurrencyPair(String currencyPairRaw) { if ("DOGEBTC".equalsIgnoreCase(currencyPairRaw)) { return CurrencyPair.DOGE_BTC; } else if ("STARTBTC".equalsIgnoreCase(currencyPairRaw)) { return new CurrencyPair(Currency.START, Currency.BTC); } else if (currencyPairRaw.length() != 6) { throw new IllegalArgumentException("Unrecognized currency pair " + currencyPairRaw); } else { return new CurrencyPair(currencyPairRaw.substring(0, 3), currencyPairRaw.substring(3)); } }
public static CurrencyPair getCurrencyPair(String market) { CurrencyPair currencyPair; Iterator<String> syms = asList(market.split("_")).iterator(); String currencyCounter = syms.next(); String currencyBase = syms.next(); currencyPair = new CurrencyPair(currencyBase, currencyCounter); return currencyPair; }
public static Map<CurrencyPair, LivecoinOrderBook> adaptToCurrencyPairKeysMap( LivecoinAllOrderBooks orderBooksRaw) { Set<Map.Entry<String, LivecoinOrderBook>> entries = orderBooksRaw.getOrderBooksByPair().entrySet(); Map<CurrencyPair, LivecoinOrderBook> converted = new HashMap<>(entries.size()); for (Map.Entry<String, LivecoinOrderBook> entry : entries) { String[] currencyPairSplit = entry.getKey().split("/"); CurrencyPair currencyPair = new CurrencyPair(currencyPairSplit[0], currencyPairSplit[1]); converted.put(currencyPair, entry.getValue()); } return converted; }
public static CurrencyPair bitMarketCurrencyPairToCurrencyPair(String currencyPair) { if (currencyPair.equals("LiteMineXBTC")) { return new CurrencyPair("LiteMineX", "BTC"); } else if (currencyPair.length() == 6) { String ccyA = currencyPair.substring(0, 3); String ccyB = currencyPair.substring(3); return new CurrencyPair(Currency.getInstance(ccyA), Currency.getInstance(ccyB)); } else { throw new IllegalStateException("Cannot convert '" + currencyPair + "' into a CurrencyPair"); } }
public static CurrencyPair adaptCurrencyPair(String bitfinexSymbol) { String tradableIdentifier = adaptBitfinexCurrency(bitfinexSymbol.substring(0, 3)); String transactionCurrency = adaptBitfinexCurrency(bitfinexSymbol.substring(3)); return new CurrencyPair(tradableIdentifier, transactionCurrency); }
public static CurrencyPair adaptMarket(String market) { String[] parts = market.split("_"); return new CurrencyPair(Currency.getInstance(parts[0]), Currency.getInstance(parts[1])); } }
private static void raw(MercadoBitcoinMarketDataServiceRaw marketDataService) throws IOException { // Get the latest order book data for LTC/BRL MercadoBitcoinOrderBook orderBook = marketDataService.getMercadoBitcoinOrderBook(new CurrencyPair(Currency.LTC, Currency.BRL)); System.out.println( "Current Order Book size for LTC / BRL: " + (orderBook.getAsks().size() + orderBook.getBids().size())); System.out.println("First Ask: " + orderBook.getAsks().get(0).toString()); System.out.println("First Bid: " + orderBook.getBids().get(0).toString()); System.out.println(orderBook.toString()); } }
public static void main(String[] args) throws IOException { // Create Default Upbit Instance Exchange upbit = ExchangeFactory.INSTANCE.createExchange(UpbitExchange.class.getName()); // Get The Public Market Data Service MarketDataService marketDataService = upbit.getMarketDataService(); // Currency Pair To Get Ticker Of CurrencyPair pair = new CurrencyPair(Currency.ETH, Currency.KRW); // Print The Generic and Raw Ticker System.out.println(marketDataService.getTicker(pair)); } }
public static CurrencyPair adaptCurrencyPair(BittrexSymbol bittrexSymbol) { String baseSymbol = bittrexSymbol.getMarketCurrency(); String counterSymbol = bittrexSymbol.getBaseCurrency(); return new CurrencyPair(baseSymbol, counterSymbol); }
public static void main(String[] args) throws IOException { // Use the factory to get Cex.IO exchange API using default settings Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CexIOExchange.class.getName()); // Interested in the public market data feed (no authentication) MarketDataService marketDataService = exchange.getMarketDataService(); // Get the latest trade data for GHs/BTC since tid=5635556 Trades trades = marketDataService.getTrades(new CurrencyPair(Currency.GHs, Currency.BTC), 5909107); System.out.println("Trades Size= " + trades.getTrades().size()); System.out.println(trades.toString()); } }
public static void main(String[] args) throws Exception { // CertHelper.trustAllCerts(); poloniex = ExchangeFactory.INSTANCE.createExchange(PoloniexExchange.class.getName()); MarketDataService dataService = poloniex.getMarketDataService(); currencyPair = new CurrencyPair("BTC", "USDT"); // currencyPair = new CurrencyPair("ETH", "BTC"); generic(dataService); // raw((PoloniexMarketDataServiceRaw) dataService); }
private static void generic(MarketDataService marketDataService) throws IOException { OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD); System.out.println(orderBook.toString()); OrderBook orderBookAsXBT = marketDataService.getOrderBook(new CurrencyPair(Currency.XBT, Currency.USD)); System.out.println(orderBookAsXBT.toString()); }
public static ExchangeMetaData adaptMetadata(List<BiboxMarket> markets) { Map<CurrencyPair, CurrencyPairMetaData> pairMeta = new HashMap<>(); for (BiboxMarket biboxMarket : markets) { pairMeta.put( new CurrencyPair(biboxMarket.getCoinSymbol(), biboxMarket.getCurrencySymbol()), new CurrencyPairMetaData(null, null, null, null, null)); } return new ExchangeMetaData(pairMeta, null, null, null, null); }
private static void generic(MarketDataService marketDataService) throws IOException { Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD, 22233); System.out.println(trades.toString()); Trades tradesAsXBT = marketDataService.getTrades(new CurrencyPair(Currency.XBT, Currency.USD), 22233); System.out.println(tradesAsXBT.toString()); } }
/** 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; }
public static LimitOrder adaptOrder( GateioOpenOrder order, Collection<CurrencyPair> currencyPairs) { String[] currencyPairSplit = order.getCurrencyPair().split("_"); CurrencyPair currencyPair = new CurrencyPair(currencyPairSplit[0], currencyPairSplit[1]); return new LimitOrder( order.getType().equals("sell") ? OrderType.ASK : OrderType.BID, order.getAmount(), currencyPair, order.getOrderNumber(), null, order.getRate()); }
public static void setHuobiAssetPairs(HuobiAssetPair[] huobiAssetPairs) { for (HuobiAssetPair entry : huobiAssetPairs) { CurrencyPair pair = new CurrencyPair( translateHuobiCurrencyCode(entry.getBaseCurrency()), translateHuobiCurrencyCode(entry.getQuoteCurrency())); if (pair.base != null && pair.counter != null) { assetPairMap.put(entry.getKey(), pair); assetPairMapReverse.put(pair, entry.getKey()); } } }
public static UserTrade adaptFill(CryptoFacilitiesFill fill) { return new UserTrade( adaptOrderType(fill.getSide()), fill.getSize(), new CurrencyPair(fill.getSymbol(), fill.getSymbol().substring(6, 9)), fill.getPrice(), fill.getFillTime(), fill.getFillId(), fill.getOrderId(), null, (Currency) null); }