Package com.xeiam.xchange.dto.trade

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


    return new UserTrades(openOrders, TradeSortType.SortByID);
  }

  public static UserTrade adaptTrade(final JustcoinTrade justcoinTrade) {

    return new UserTrade(OrderType.valueOf(justcoinTrade.getType().toUpperCase()), justcoinTrade.getAmount(), adaptCurrencyPair(justcoinTrade.getMarket()), justcoinTrade.getAveragePrice(), justcoinTrade
        .getCreatedAt(), justcoinTrade.getId(), null, null, null);
  }
View Full Code Here


          .getOrder_id());
      final Date timestamp = DateUtils.fromMillisUtc(order.getDate_completed() / 1000L);
      final BigDecimal price = order.getPrice().getValue();
      final BigDecimal amount = order.getUnits().getValue();
      final BigDecimal feeAmount = order.getFee().getValue();
      trades.add(new UserTrade(orderType, amount, currPair, price, timestamp, orderId, orderId, feeAmount, currPair.counterSymbol));
    }

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

    String transactionCurrency = adaptCurrency(krakenAssetPair.substring(4));
    Date timestamp = new Date((long) (krakenTrade.getUnixTimestamp() * 1000L));
    BigDecimal averagePrice = krakenTrade.getAverageClosePrice();
    BigDecimal price = (averagePrice == null) ? krakenTrade.getPrice() : averagePrice;

    return new UserTrade(orderType, tradableAmount, new CurrencyPair(tradableIdentifier, transactionCurrency), price, timestamp, tradeId, krakenTrade.getOrderTxId(), krakenTrade.getFee(), transactionCurrency);
  }
View Full Code Here

      OrderType type = t.getSide().equals("buy") ? OrderType.BID : OrderType.ASK;

      String base = t.getSymbol().substring(0, 3);
      String counter = t.getSymbol().substring(3, 6);

      UserTrade trade = new UserTrade(type, t.getExecQuantity().divide(LOT_MULTIPLIER), new CurrencyPair(base, counter), t.getExecPrice(), new Date(t.getTimestamp()), t.getClientOrderId(),
          Long.toString(t.getOriginalOrderId()), t.getFee(), counter);

      trades.add(trade);
    }
View Full Code Here

    UserTrades trades = KrakenAdapters.adaptTradesHistory(krakenTradeHistoryMap);
    List<UserTrade> tradeList = trades.getUserTrades();

    assertThat(tradeList.size()).isEqualTo(1);
    UserTrade trade = tradeList.get(0);
    assertThat(trade.getId()).isEqualTo("TY5BYV-WJUQF-XPYEYD");
    assertThat(trade.getPrice()).isEqualTo(new BigDecimal("32.07562"));
    assertThat(trade.getTradableAmount()).isEqualTo("0.50000000");
    assertThat(trade.getCurrencyPair().baseSymbol).isEqualTo(Currencies.BTC);
    assertThat(trade.getCurrencyPair().counterSymbol).isEqualTo(Currencies.LTC);
    assertThat(trade.getType()).isEqualTo(OrderType.ASK);
    assertThat(trade.getFeeAmount()).isEqualTo(new BigDecimal("0.03208"));
    assertThat(trade.getFeeCurrency()).isEqualTo(Currencies.LTC);
  }
View Full Code Here

    UserTrades trades = CryptoTradeAdapters.adaptTrades(tradeHistory);

    assertThat(trades.getlastID()).isEqualTo(17);
    assertThat(trades.getTrades()).hasSize(2);

    UserTrade trade = trades.getUserTrades().get(1);
    assertThat(trade.getPrice()).isEqualTo("128");
    assertThat(trade.getType()).isEqualTo(OrderType.ASK);
    assertThat(trade.getTimestamp()).isEqualTo(new Date(1370965122));
    assertThat(trade.getTradableAmount()).isEqualTo("0.1");
    assertThat(trade.getId()).isEqualTo("17");
    assertThat(trade.getOrderId()).isEqualTo("1");
    assertThat(trade.getFeeAmount()).isNull();
  }
View Full Code Here

    CurrencyPair currencyPair = adaptCurrencyPair(symbol);

    for (BitfinexTradeResponse trade : trades) {
      OrderType orderType = trade.getType().equalsIgnoreCase("buy") ? OrderType.BID : OrderType.ASK;
      Date timestamp = convertBigDecimalTimestampToDate(trade.getTimestamp());
      pastTrades.add(new UserTrade(orderType, trade.getAmount(), currencyPair, trade.getPrice(), timestamp, trade.getTradeId(), trade.getOrderId(), trade.getFeeAmount(), trade.getFeeCurrency()));
    }

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

  public static UserTrade adaptTrade(CryptoTradeTrade trade) {

    OrderType orderType = adaptOrderType(trade.getType());
    Date timestamp = new Date(trade.getTimestamp());

    return new UserTrade(orderType, trade.getAmount(), trade.getCurrencyPair(), trade.getRate(), timestamp, String.valueOf(trade.getId()), String.valueOf(trade.getMyOrder()), null, null);
  }
View Full Code Here

    long lastTradeId = 0;
    for (CryptoTradeTrade cryptoTradeTrade : cryptoTradeTrades.getTrades()) {
      long tradeId = cryptoTradeTrade.getId();
      if (tradeId > lastTradeId)
        lastTradeId = tradeId;
      UserTrade trade = adaptTrade(cryptoTradeTrade);
      tradeList.add(trade);
    }

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

    BigDecimal tradedCurrencyFillAmount = t.getTradedCurrencyFillAmount();
    CurrencyPair currencyPair = adaptCurrencyPair(t.getCurrencyPair());
    BigDecimal price = t.getSettlementCurrencyFillAmount().divide(tradedCurrencyFillAmount, PRICE_SCALE, BigDecimal.ROUND_HALF_EVEN);
    OrderType type = adaptSide(t.getSide());
    // for fees, getWalletHistory should be used.
    return new UserTrade(type, tradedCurrencyFillAmount, currencyPair, price, t.getTimestamp(), t.getTradeId(), t.getOrderId(), null, null);
  }
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.