Package com.xeiam.xchange.currency

Examples of com.xeiam.xchange.currency.CurrencyPair


    List<UserTrade> trades = new ArrayList<UserTrade>();
    for (int i = 0; i < btcTradeOrders.length; i++) {
      BTCTradeOrder order = btcTradeOrders[i];

      CurrencyPair currencyPair = adaptCurrencyPair(order.getCoin());

      if (currencyPair != null) {
        BTCTradeOrder orderDetail = btcTradeOrderDetails[i];

        for (com.xeiam.xchange.btctrade.dto.trade.BTCTradeTrade trade : orderDetail.getTrades()) {
View Full Code Here


  public static List<OrderBook> adaptPublicOrderBooks(Map<Integer, CryptsyPublicOrderbook> cryptsyOrderBooks) {

    Date timestamp = new Date();
    List<OrderBook> orderBooks = new ArrayList<OrderBook>();
    for (CryptsyPublicOrderbook cryptsyOrderBook : cryptsyOrderBooks.values()) {
      CurrencyPair currencyPair = adaptCurrencyPair(cryptsyOrderBook.getLabel());
      List<LimitOrder> asks = adaptPublicOrders(cryptsyOrderBook.getSellOrders(), OrderType.ASK, currencyPair);
      List<LimitOrder> bids = adaptPublicOrders(cryptsyOrderBook.getBuyOrders(), OrderType.BID, currencyPair);

      orderBooks.add(new OrderBook(timestamp, asks, bids));
    }
View Full Code Here

  public static Map<CurrencyPair, Trades> adaptPublicTrades(Map<Integer, CryptsyPublicMarketData> cryptsyMarketData) {

    Map<CurrencyPair, Trades> trades = new HashMap<CurrencyPair, Trades>();
    for (CryptsyPublicMarketData cryptsyMarketDataEntry : cryptsyMarketData.values()) {
      CurrencyPair currencyPair = adaptCurrencyPair(cryptsyMarketDataEntry.getLabel());
      List<Trade> tradesList = new ArrayList<Trade>();
      long lastTradeId = 0;
      List<CryptsyPublicTrade> recentTrades = cryptsyMarketDataEntry.getRecentTrades();
      if (recentTrades != null) {
        for (CryptsyPublicTrade trade : recentTrades) {
View Full Code Here

    List<UserTrade> trades = new ArrayList<UserTrade>();
    if (cryptsyTradeHistory != null) {
      for (CryptsyTradeHistory trade : cryptsyTradeHistory) {
        OrderType tradeType = trade.getTradeType() == CryptsyOrderType.Buy ? OrderType.BID : OrderType.ASK;
        CurrencyPair currencyPair = CryptsyCurrencyUtils.convertToCurrencyPair(trade.getMarketId());

        trades.add(new UserTrade(tradeType, trade.getQuantity(), currencyPair, trade.getPrice(), trade.getTimestamp(), String.valueOf(trade.getTradeId()), String.valueOf(trade.getOrderId()), trade.getFee(), currencyPair.counterSymbol));
      }
    }
    return new UserTrades(trades, TradeSortType.SortByTimestamp);
View Full Code Here

    final Date timestamp = transfer.getCreatedAt();
    final String id = transfer.getTransactionId();
    final BigDecimal feeAmount = transfer.getCoinbaseFee().getAmount();
    final String feeCurrency = transfer.getCoinbaseFee().getCurrency();

    return new UserTrade(orderType, tradableAmount, new CurrencyPair(tradableIdentifier, transactionCurrency), price, timestamp, id, id, feeAmount, feeCurrency);
  }
View Full Code Here

    return pairs;
  }

  public static CurrencyPair adaptCurrencyPair(CryptsyPublicMarketData cryptsyPublicMarketData) {

    return new CurrencyPair(cryptsyPublicMarketData.getPrimaryCurrencyCode(), cryptsyPublicMarketData.getSecondaryCurrencyCode());
  }
View Full Code Here

  }

  public static CurrencyPair adaptCurrencyPair(String cryptsyLabel) {

    String[] marketCurrencies = cryptsyLabel.split("/");
    return new CurrencyPair(marketCurrencies[0], marketCurrencies[1]);
  }
View Full Code Here

    marketSets[0] = new HashMap<Integer, CurrencyPair>();
    marketSets[1] = new HashMap<CurrencyPair, Integer>();

    for (CryptsyPublicMarketData currMarketData : cryptsyPublicMarketData.values()) {
      CurrencyPair currencyPair = adaptCurrencyPair(currMarketData.getLabel());

      ((HashMap<Integer, CurrencyPair>) marketSets[0]).put(currMarketData.getMarketId(), currencyPair);
      ((HashMap<CurrencyPair, Integer>) marketSets[1]).put(currencyPair, currMarketData.getMarketId());
    }
View Full Code Here

    // subscribe to orderbook
    ((CoinfloorStreamingExchangeService) streamingExchangeService).watchOrders("BTC", "GBP");
    TimeUnit.MILLISECONDS.sleep(1000);

    // 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(320));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(buyLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    LimitOrder sellLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.52321512784), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(319));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(sellLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    // 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));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(bigLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    // request outcome of theoretical marketOrder
    MarketOrder estMarketOrder = new MarketOrder(OrderType.ASK, new BigDecimal(1), new CurrencyPair("BTC", "GBP"));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).estimateMarketOrder(estMarketOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    // get user's current open orders, cancel all of them.
    CoinfloorOpenOrders openOrders = (CoinfloorOpenOrders) ((CoinfloorStreamingExchangeService) streamingExchangeService).getOrders().getPayloadItem("raw");
View Full Code Here

   * @param marketId int representation of marketId
   * @return CurrencyPair used by that of that market
   */
  public static CurrencyPair convertToCurrencyPair(int marketId) {

    CurrencyPair currencyPairs = marketIds_CurrencyPairs.get(marketId);

    return (currencyPairs == null ? new CurrencyPair("UNKNOWN_UNKNOWN") : currencyPairs);
  }
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.