Package com.xeiam.xchange.dto.trade

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


    BigDecimal amount = trade.getQuantity().subtract(trade.getQuantityRemaining());
    BigDecimal price = trade.getLimit();
    Date date = BittrexUtils.toDate(trade.getTimeStamp());
    String orderId = String.valueOf(trade.getOrderUuid());

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


    return new UserTrades(trades, TradeSortType.SortByTimestamp);
  }

  private static UserTrade adaptTrade(BTCTradeOrder order, com.xeiam.xchange.btctrade.dto.trade.BTCTradeTrade trade, CurrencyPair currencyPair) {

    return new UserTrade(adaptOrderType(order.getType()), trade.getAmount(), currencyPair, trade.getPrice(), adaptDatetime(trade.getDatetime()), trade.getTradeId(), order.getId(), null, null);
  }
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

    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

      Date timeStamp = DateUtils.fromMillisUtc(result.getTimestamp() * 1000L);
      String tradeId = String.valueOf(entry.getKey());
      String orderId = String.valueOf(result.getOrderId());
      CurrencyPair currencyPair = new CurrencyPair(pair[0].toUpperCase(), pair[1].toUpperCase());

      trades.add(new UserTrade(type, tradableAmount, currencyPair, price, timeStamp, tradeId, orderId, null, null));
    }
    return new UserTrades(trades, TradeSortType.SortByTimestamp);
  }
View Full Code Here

      BigDecimal tradableAmount = result.getAmount();
      Date timeStamp = DateUtils.fromMillisUtc(result.getTimestamp() * 1000L);
      String orderId = String.valueOf(result.getOrderId());
      String tradeId = String.valueOf(entry.getKey());
      CurrencyPair currencyPair = new CurrencyPair(pair[0].toUpperCase(), pair[1].toUpperCase());
      trades.add(new UserTrade(type, tradableAmount, currencyPair, price, timeStamp, tradeId, orderId, null, null));
    }
    return new UserTrades(trades, TradeSortType.SortByTimestamp);
  }
View Full Code Here

  public void testAdaptTrades() throws IOException {

    BigDecimal tradableAmount = new BigDecimal("1.20000000");
    BigDecimal price = new BigDecimal("905.10").divide(tradableAmount, RoundingMode.HALF_EVEN);

    UserTrade expectedTrade =
            new UserTrade(OrderType.BID, tradableAmount, CurrencyPair.BTC_USD, price, DateUtils.fromISO8601DateString("2014-02-06T18:12:38-08:00"), "52f4411767c71baf9000003f", "52f4411767c71baf9000003f", new BigDecimal("9.05"), "USD");

    // Read in the JSON from the example resources
    InputStream is = CoinbaseAdapterTest.class.getResourceAsStream("/trade/example-transfers-data.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CoinbaseTransfers transfers = mapper.readValue(is, CoinbaseTransfers.class);

    UserTrades trades = CoinbaseAdapters.adaptTrades(transfers);
    List<UserTrade> tradeList = trades.getUserTrades();
    assertThat(tradeList.size()).isEqualTo(1);

    UserTrade trade = tradeList.get(0);
    assertThat(trade).isEqualsToByComparingFields(expectedTrade);
  }
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    CryptsyTradeHistoryReturn cryptsyTradeHistory = mapper.readValue(is, CryptsyTradeHistoryReturn.class);

    UserTrades adaptedTrades = CryptsyAdapters.adaptTradeHistory(cryptsyTradeHistory);

    UserTrade trade = adaptedTrades.getUserTrades().get(0);
    assertEquals(trade.getCurrencyPair(), CurrencyPair.LTC_BTC);
    assertEquals(trade.getId(), "9982231");
    assertEquals(trade.getOrderId(), "23569349");
    assertEquals(trade.getType(), OrderType.BID);
    assertEquals(trade.getTradableAmount(), new BigDecimal("0.15949550"));
    assertEquals(trade.getPrice(), new BigDecimal("0.03128615"));
    assertEquals(trade.getFeeAmount(), new BigDecimal("0.000009980"));
    assertEquals(trade.getFeeCurrency(), Currencies.BTC);
  }
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.