Package com.xeiam.xchange.currency

Examples of com.xeiam.xchange.currency.CurrencyPair


    // get all services
    PollingMarketDataService marketDataService = bitfinex.getPollingMarketDataService();
    PollingAccountService accout = bitfinex.getPollingAccountService();
    PollingTradeService trades = bitfinex.getPollingTradeService();

    OrderBook orderBook = marketDataService.getOrderBook(new CurrencyPair("XBT", "USD"));
    System.out.println("BIDS: " + orderBook.getBids());
    System.out.println("ASKS: " + orderBook.getAsks());

    Trades trades2 = marketDataService.getTrades(new CurrencyPair("XBT", "USD"), 22233);
    System.out.println("Current trades:" + trades2);

    AccountInfo accountInfo = accout.getAccountInfo();

    System.out.println(accountInfo);
    OpenOrders openOrders = trades.getOpenOrders();
    System.out.println("open orders: " + openOrders);

    for (LimitOrder o : openOrders.getOpenOrders()) {
      System.out.println("Order " + o.getId() + " .. cancelling!");
      System.out.println(trades.cancelOrder(o.getId()));

    }

    String placeLimitOrder1 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(300)));
    String placeLimitOrder2 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(350)));
    String placeLimitOrder3 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(360)));
    String placeLimitOrder4 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(370)));

    System.out.println("limit order id " + placeLimitOrder1);
    System.out.println("limit order id " + placeLimitOrder2);
    System.out.println("limit order id " + placeLimitOrder3);
    System.out.println("limit order id " + placeLimitOrder4);

    trades.placeLimitOrder(new LimitOrder(OrderType.ASK, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(770)));

    System.out.println("Cancelling " + placeLimitOrder1);
    trades.cancelOrder(placeLimitOrder1);

    Trades tradeHistory = trades.getTradeHistory();
View Full Code Here


            TimeUnit.MILLISECONDS.sleep((startTime + 500) - System.currentTimeMillis());
          } catch (InterruptedException e) {
          }

          // send two orders, that will (partially) fulfill each other, to generate a trade.
          LimitOrder buyLimitOrder = new LimitOrder(OrderType.BID, new BigDecimal(1), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(3.20));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(buyLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nBuy Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
            TimeUnit.MILLISECONDS.sleep(1000);
          } catch (InterruptedException e) {
          }

          // check for new balance before submitting second order
          System.out.println("\n\n\n\n\nCached Account Info: ");
          System.out.println(((CoinfloorStreamingExchangeService) streamingExchangeService).getCachedAccountInfo());

          LimitOrder sellLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.52321512784), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(3.19));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(sellLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nSell Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
            TimeUnit.MILLISECONDS.sleep(1000);
          } catch (InterruptedException e) {
          }

          // check for new balance again
          System.out.println("\n\n\n\n\nCached Account Info: ");
          System.out.println(((CoinfloorStreamingExchangeService) streamingExchangeService).getCachedAccountInfo());

          // then send another order, that will never be fulfilled
          LimitOrder bigLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.152), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(500));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(bigLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nBig Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
            TimeUnit.MILLISECONDS.sleep(1000);
          } catch (InterruptedException e) {
          }

          // check for new balance before submitting second order
          System.out.println("\n\n\n\n\nCached Account Info: ");
          System.out.println(((CoinfloorStreamingExchangeService) streamingExchangeService).getCachedAccountInfo());

          // request outcome of theoretical marketOrder
          MarketOrder estMarketOrder = new MarketOrder(OrderType.ASK, new BigDecimal(1), new CurrencyPair("BTC", "GBP"));
          ((CoinfloorStreamingExchangeService) streamingExchangeService).estimateMarketOrder(estMarketOrder).getPayload();
          System.out.println("\n\n\n\n\nEstimated Market Order: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
View Full Code Here

    // Interested in the public polling market data feed (no authentication)
    PollingMarketDataService marketDataService = bitcoinChartsExchange.getPollingMarketDataService();

    // Get the latest ticker data showing BTC/bitstampUSD
    CurrencyPair currencyPair = new CurrencyPair(Currencies.BTC, "bitstampUSD");
    Ticker ticker = marketDataService.getTicker(currencyPair);

    double value = ticker.getLast().doubleValue();

    String currency = ticker.getCurrencyPair().counterSymbol.toString();
View Full Code Here

    System.out.println("----------GENERIC---------");

    ArrayList<CurrencyPair> pairs = new ArrayList<CurrencyPair>(marketDataService.getExchangeSymbols());
    System.out.println(pairs);

    CurrencyPair pair = pairs.get(new Random().nextInt(pairs.size()));
    System.out.println("Market data for " + pair + ":");

    Ticker ticker = marketDataService.getTicker(pair);
    System.out.println(ticker);
View Full Code Here

    System.out.println(symbols);

    ArrayList<CurrencyPair> pairs = new ArrayList<CurrencyPair>(marketDataService.getExchangeSymbols());
    System.out.println(pairs);

    CurrencyPair pair = pairs.get(new Random().nextInt(pairs.size()));
    System.out.println("Market data for " + pair + ":");
    String pairString = BittrexUtils.toPairString(pair);

    BittrexTicker ticker = marketDataService.getBittrexTicker(pairString);
    System.out.println(ticker);
View Full Code Here

  }

  private static void generic(PollingTradeService tradeService) throws IOException {

    CurrencyPair pair = new CurrencyPair("ZET", "BTC");
    LimitOrder limitOrder = new LimitOrder.Builder(OrderType.BID, pair).limitPrice(new BigDecimal("0.00001000")).tradableAmount(new BigDecimal("100")).build();

    try {
      String uuid = tradeService.placeLimitOrder(limitOrder);
      System.out.println("Order successfully placed. ID=" + uuid);
View Full Code Here

    }
  }

  private static void raw(BittrexTradeServiceRaw tradeService) throws IOException {

    CurrencyPair pair = new CurrencyPair("ZET", "BTC");
    LimitOrder limitOrder = new LimitOrder.Builder(OrderType.BID, pair).limitPrice(new BigDecimal("0.00001000")).tradableAmount(new BigDecimal("100")).build();

    try {
      String uuid = tradeService.placeBittrexLimitOrder(limitOrder);
      System.out.println("Order successfully placed. ID=" + uuid);
View Full Code Here

        timeStamp = vircurexDateFormat.parse(vircurexOpenOrder.getReleaseDate());
      } catch (ParseException e) {
        timeStamp = null;
      }

      adaptedOrders.add(new LimitOrder(orderType, BigDecimal.ONE, new CurrencyPair(vircurexOpenOrder.getBaseCurrency(), vircurexOpenOrder.getCounterCurrency()), vircurexOpenOrder.getOrderId(),
          timeStamp, vircurexOpenOrder.getUnitPrice()));
    }

    return adaptedOrders;
  }
View Full Code Here

    return currencyPairs;
  }

  public static CurrencyPair adaptCurrencyPair(final MintPalTicker mintPalTicker) {

    return new CurrencyPair(mintPalTicker.getCode(), mintPalTicker.getExchange());
  }
View Full Code Here

  public ItBitOrder[] getItBitTradeHistory(Object... arguments) throws IOException {

    String currency = null;

    if (arguments.length == 1) {
      CurrencyPair currencyPair = ((CurrencyPair) arguments[0]);
      currency = currencyPair.baseSymbol + currencyPair.counterSymbol;
    }
    else {
      currency = "XBTUSD";
    }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.currency.CurrencyPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.