Package com.xeiam.xchange.dto.trade

Examples of com.xeiam.xchange.dto.trade.UserTrade


    final BigDecimal price = money.divide(amount, scale, RoundingMode.HALF_EVEN);
    final Date date = adaptDate(transaction.getDate());
    final String tradeId = String.valueOf(transaction.getId());

    return new UserTrade(orderType, amount, currencyPair, price, date, tradeId, null, null, null);
  }
View Full Code Here


  public static UserTrades adaptTransactions(List<BTCChinaTransaction> transactions) {

    List<UserTrade> tradeHistory = new ArrayList<UserTrade>(transactions.size());

    for (BTCChinaTransaction transaction : transactions) {
      UserTrade adaptTransaction = adaptTransaction(transaction);
      if (adaptTransaction != null) {
        tradeHistory.add(adaptTransaction);
      }
    }
View Full Code Here

    return type.equals("buy") || type.equals("buy_market") ? OrderType.BID : OrderType.ASK;
  }

  private static UserTrade adaptTrade(OkCoinOrder order) {

    return new UserTrade(adaptOrderType(order.getType()), order.getDealAmount(), adaptSymbol(order.getSymbol()), order.getAvgRate(), order.getCreateDate(), null, String.valueOf(order.getOrderId()), null, null);
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    BTCETradeHistoryReturn btceTradeHistory = mapper.readValue(is, BTCETradeHistoryReturn.class);

    UserTrades trades = BTCEAdapters.adaptTradeHistory(btceTradeHistory.getReturnValue());
    List<UserTrade> tradeList = trades.getUserTrades();
    UserTrade lastTrade = tradeList.get(tradeList.size() - 1);
    assertThat(lastTrade.getId()).isEqualTo("7258275");
    assertThat(lastTrade.getType()).isEqualTo(OrderType.ASK);
    assertThat(lastTrade.getPrice().toString()).isEqualTo("125.75");
    assertThat(lastTrade.getTimestamp().getTime()).isEqualTo(1378194574000L);
    assertThat(DateUtils.toUTCString(lastTrade.getTimestamp())).isEqualTo("2013-09-03 07:49:34 GMT");
    assertThat(lastTrade.getFeeAmount()).isNull();

  }
View Full Code Here

  }

  @Test
  public void testAdapter() {

    final UserTrade trade = JustcoinAdapters.adaptTrade(justcoinTrade);

    assertThat(trade.getId()).isEqualTo(id);
    assertThat(trade.getPrice()).isEqualTo(averagePrice);
    assertThat(trade.getTimestamp()).isEqualTo(orderCreatedAt);
    assertThat(trade.getTradableAmount()).isEqualTo(amount);
    assertThat(trade.getCurrencyPair().baseSymbol).isEqualTo(tradableIdentifier);
    assertThat(trade.getCurrencyPair().counterSymbol).isEqualTo(transactionCurrency);
    assertThat(trade.getType()).isEqualTo(OrderType.BID);
  }
View Full Code Here

    BigDecimal price = userTrade.getRate();
    Date date = PoloniexUtils.stringToDate(userTrade.getDate());
    String tradeId = String.valueOf(userTrade.getTradeID());
    String orderId = String.valueOf(userTrade.getOrderNumber());

    return new UserTrade(orderType, amount, currencyPair, price, date, tradeId, orderId, userTrade.getFee(), currencyPair.counterSymbol);
  }
View Full Code Here

    OrderType orderType = adaptOrderType(bterTrade.getType());
    Date timestamp = DateUtils.fromMillisUtc(bterTrade.getTimeUnix() * 1000);
    CurrencyPair currencyPair = adaptCurrencyPair(bterTrade.getPair());

    return new UserTrade(orderType, bterTrade.getAmount(), currencyPair, bterTrade.getRate(), timestamp, bterTrade.getId(), null, null, null);
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    BTCETradeHistoryReturn btceTradeHistory = mapper.readValue(is, BTCETradeHistoryReturn.class);

    UserTrades trades = BTCEAdapters.adaptTradeHistory(btceTradeHistory.getReturnValue());
    List<UserTrade> tradeList = trades.getUserTrades();
    UserTrade lastTrade = tradeList.get(tradeList.size() - 1);
    assertThat(lastTrade.getId()).isEqualTo("7258275");
    assertThat(lastTrade.getType()).isEqualTo(OrderType.ASK);
    assertThat(lastTrade.getPrice().toString()).isEqualTo("125.75");
    assertThat(lastTrade.getTimestamp().getTime()).isEqualTo(1378194574000L);
    assertThat(DateUtils.toUTCString(lastTrade.getTimestamp())).isEqualTo("2013-09-03 07:49:34 GMT");
    assertThat(lastTrade.getFeeAmount()).isNull();

  }
View Full Code Here

        final String tradeId = String.valueOf(transactionId);
        final String orderId = String.valueOf(bitstampUserTransaction.getOrderId());
        final BigDecimal feeAmount = bitstampUserTransaction.getFee();
        final CurrencyPair currencyPair = CurrencyPair.BTC_USD;

        UserTrade trade = new UserTrade(orderType, tradableAmount, currencyPair, price, timestamp, tradeId, orderId, feeAmount, currencyPair.counterSymbol);
        trades.add(trade);
      }
    }

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

      OrderType orderType = itBitOrder.getSide().equals("buy") ? OrderType.BID : OrderType.ASK;
      CurrencyPair currencyPair = new CurrencyPair(instrument.substring(0, 3), instrument.substring(3, 6));
      Date timestamp = parseDate(itBitOrder.getCreatedTime());

      trades.add(new UserTrade(orderType, itBitOrder.getAmount(), currencyPair, itBitOrder.getPrice(), timestamp, itBitOrder.getId(), itBitOrder.getId(), null, null));
    }

    return new UserTrades(trades, TradeSortType.SortByTimestamp);
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.trade.UserTrade

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.