/**
   * Adapts a CexIOTrade to a Trade Object
   *
   * @param trade CexIO trade object
   * @param currencyPair trade currencies
   * @return The XChange Trade
   */
  public static Trade adaptTrade(CexIOTrade trade, CurrencyPair currencyPair) {

    BigDecimal amount = trade.getAmount();
    BigDecimal price = trade.getPrice();
    Date date = DateUtils.fromMillisUtc(trade.getDate() * 1000L);
    // Cex.IO API does not return trade type
    return new Trade(null, amount, currencyPair, price, date, String.valueOf(trade.getTid()));
  }
Beispiel #2
0
  /**
   * Adapts a Transaction[] to a Trades Object
   *
   * @param transactions The Bitstamp transactions
   * @param tradableIdentifier The tradeable identifier (e.g. BTC in BTC/USD)
   * @param currency The currency (e.g. USD in BTC/USD)
   * @return The XChange Trades
   */
  public static Trades adaptTrades(
      BitstampTransaction[] transactions, String tradableIdentifier, String currency) {

    List<Trade> trades = new ArrayList<Trade>();
    for (BitstampTransaction tx : transactions) {
      trades.add(
          new Trade(
              null,
              tx.getAmount(),
              tradableIdentifier,
              currency,
              BigMoney.of(CurrencyUnit.of(currency), tx.getPrice()),
              DateUtils.fromMillisUtc(tx.getDate() * 1000L),
              tx.getTid()));
    }

    return new Trades(trades);
  }
  public static OpenOrders adaptOpenOrders(List<CexIOOrder> cexIOOrderList) {

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>();

    for (CexIOOrder cexIOOrder : cexIOOrderList) {
      Order.OrderType orderType =
          cexIOOrder.getType() == CexIOOrder.Type.buy ? Order.OrderType.BID : Order.OrderType.ASK;
      String id = Long.toString(cexIOOrder.getId());
      limitOrders.add(
          new LimitOrder(
              orderType,
              cexIOOrder.getPending(),
              new CurrencyPair(
                  cexIOOrder.getTradableIdentifier(), cexIOOrder.getTransactionCurrency()),
              id,
              DateUtils.fromMillisUtc(cexIOOrder.getTime()),
              cexIOOrder.getPrice()));
    }

    return new OpenOrders(limitOrders);
  }