Package com.xeiam.xchange.dto.marketdata

Examples of com.xeiam.xchange.dto.marketdata.Trade


    assertThat(trades.getlastID()).isEqualTo(1402189349725L);

    List<Trade> tradeList = trades.getTrades();
    assertThat(tradeList.size()).isEqualTo(2);

    Trade trade = tradeList.get(0);
    assertThat(trade.getTradableAmount()).isEqualTo("0.25");
    assertThat(trade.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_USD);
    assertThat(trade.getPrice()).isEqualTo("655");
    assertThat(trade.getId()).isEqualTo("1402189342525");
    assertThat(trade.getType()).isEqualTo(OrderType.BID);
    assertThat(trade.getTimestamp().getTime()).isEqualTo(1402189342525L);
  }
View Full Code Here


    List<Trade> tradeList = new ArrayList<Trade>();

    for (BitMarketTrade bitMarketTrade : bitMarketTrades) {

      Trade trade = new Trade(OrderType.BID, bitMarketTrade.getAmount(), currencyPair, bitMarketTrade.getPrice(), new Date(bitMarketTrade.getDate()), bitMarketTrade.getTid());

      tradeList.add(trade);
    }

    Trades trades = new Trades(tradeList, Trades.TradeSortType.SortByTimestamp);
View Full Code Here

    return new LimitOrder(type, data[1], currencyPair, id, timestamp, data[0]);
  }

  private static Trade adaptTrade(OkCoinTrade trade, CurrencyPair currencyPair) {

    return new Trade(trade.getType().equals("buy") ? OrderType.BID : OrderType.ASK, trade.getAmount(), currencyPair, trade.getPrice(), trade.getDate(), "" + trade.getTid());
  }
View Full Code Here

    Trades adaptedTrades = BTERAdapters.adaptTrades(tradeHistory, CurrencyPair.BTC_CNY);

    List<Trade> tradeList = adaptedTrades.getTrades();
    assertThat(tradeList).hasSize(2);

    Trade trade = tradeList.get(0);
    assertThat(trade.getType()).isEqualTo(OrderType.ASK);
    assertThat(trade.getTradableAmount()).isEqualTo("0.0129");
    assertThat(trade.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_CNY);
    assertThat(trade.getPrice()).isEqualTo("3942");
    assertThat(trade.getTimestamp()).isEqualTo(new Date(1393908191000L));
    assertThat(trade.getId()).isEqualTo("5600118");
  }
View Full Code Here

    assertThat(adaptedTrades.getlastID()).isEqualTo(92726);

    final List<Trade> adaptedTradeList = adaptedTrades.getTrades();
    assertThat(adaptedTradeList).hasSize(2);

    final Trade adaptedTrade = adaptedTradeList.get(0);
    assertThat(adaptedTrade.getTradableAmount()).isEqualTo("0.16204");
    assertThat(adaptedTrade.getPrice()).isEqualTo("600.632");
    assertThat(adaptedTrade.getId()).isEqualTo("92595");
    assertThat(adaptedTrade.getTimestamp().getTime()).isEqualTo(1403353443000L);
    assertThat(adaptedTrade.getId()).isEqualTo("92595");
    assertThat(adaptedTrade.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_USD);
    assertThat(adaptedTrade.getType()).isNull();
  }
View Full Code Here

      rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
    } catch (IOException e) {
      throw new ExchangeException("JSON parse error", e);
    }

    Trade trade;

    synchronized (cachedDataSynchronizationObject) {
      List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
      List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
      if (rawRetObj.getBidId() != 0) {
        for (int i = 0; i < bidList.size(); i++) {
          if (bidList.get(i).getId().equals(String.valueOf(rawRetObj.getBidId()))) {
            bidList.remove(i);
            break;
          }
        }
      }
      if (rawRetObj.getAskId() != 0) {
        for (int i = 0; i < askList.size(); i++) {
          if (askList.get(i).getId().equals(String.valueOf(rawRetObj.getAskId()))) {
            askList.remove(i);
            break;
          }
        }
      }
      cachedOrderBook = new OrderBook(new Date(), askList, bidList);

      OrderType type = (rawRetObj.getBidId() > rawRetObj.getAskId() ? OrderType.BID : OrderType.ASK);
      BigDecimal limitPrice = rawRetObj.getPrice();

      trade =
          new Trade(type, rawRetObj.getBaseQty(), new CurrencyPair(rawRetObj.getBase().toString(), rawRetObj.getCounter().toString()), limitPrice, new Date(), String.valueOf(rawRetObj.getId()));

      List<Trade> newTradesList = (cachedTrades == null ? new ArrayList<Trade>() : cachedTrades.getTrades());
      newTradesList.add(trade);

      Trades newCachedTrades = new Trades(newTradesList, TradeSortType.SortByID);
View Full Code Here

  public static Trade adaptTrade(BTERPublicTrade trade, CurrencyPair currencyPair) {

    OrderType orderType = adaptOrderType(trade.getType());
    Date timestamp = DateUtils.fromMillisUtc(trade.getDate() * 1000);

    return new Trade(orderType, trade.getAmount(), currencyPair, trade.getPrice(), timestamp, trade.getTradeId());
  }
View Full Code Here

      if (!tradeIdString.isEmpty()) {
        long tradeId = Long.valueOf(tradeIdString);
        if (tradeId > lastTradeId)
          lastTradeId = tradeId;
      }
      Trade adaptedTrade = adaptTrade(trade, currencyPair);
      tradeList.add(adaptedTrade);
    }

    return new Trades(tradeList, lastTradeId, TradeSortType.SortByTimestamp);
  }
View Full Code Here

  public static Trade adaptPoloniexPublicTrade(PoloniexPublicTrade poloniexTrade, CurrencyPair currencyPair) {

    OrderType type = poloniexTrade.getType().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK;
    Date timestamp = PoloniexUtils.stringToDate(poloniexTrade.getDate());

    Trade trade = new Trade(type, poloniexTrade.getAmount(), currencyPair, poloniexTrade.getRate(), timestamp, poloniexTrade.getTradeID());
    return trade;
  }
View Full Code Here

    long lastTradeId = 0;
    for (BitstampTransaction tx : transactions) {
      final long tradeId = tx.getTid();
      if (tradeId > lastTradeId)
        lastTradeId = tradeId;
      trades.add(new Trade(null, tx.getAmount(), currencyPair, tx.getPrice(), DateUtils.fromMillisUtc(tx.getDate() * 1000L), String.valueOf(tradeId)));
    }

    return new Trades(trades, lastTradeId, TradeSortType.SortByID);
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.marketdata.Trade

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.