Package com.xeiam.xchange.dto.marketdata

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


    return new Trades(trades, lastTradeId, TradeSortType.SortByID);
  }

  public static Trade adaptPublicTrade(final CurrencyPair currencyPair, final JustcoinPublicTrade justcoinTrade) {

    return new Trade(null, justcoinTrade.getAmount(), currencyPair, justcoinTrade.getPrice(), new Date(justcoinTrade.getDate() * 1000), justcoinTrade.getTid());
  }
View Full Code Here


    BigDecimal amount = vosTrade.getUnitsTraded().getValue();
    Date date = DateUtils.fromMillisUtc(vosTrade.getTimestamp() / 1000L);
    final String tradeId = String.valueOf(vosTrade.getTransactionId());

    return new Trade(null, amount, currencyPair, vosTrade.getPrice().getValue(), date, tradeId);
  }
View Full Code Here

    OrderType type = adaptOrderType(krakenPublicTrade.getType());
    BigDecimal tradableAmount = krakenPublicTrade.getVolume();
    Date timestamp = new Date((long) (krakenPublicTrade.getTime() * 1000L));

    return new Trade(type, tradableAmount, currencyPair, krakenPublicTrade.getPrice(), timestamp, "0");
  }
View Full Code Here

    }
  }

  private static Trade internalAdaptTrade(JSONObject jsonObject) throws JSONException {

    return new Trade(BTCChinaAdapters.adaptOrderType(jsonObject.getString("type")), new BigDecimal(jsonObject.getString("amount")), BTCChinaAdapters.adaptCurrencyPair(jsonObject.getString("market")),
        new BigDecimal(jsonObject.getString("price")), BTCChinaAdapters.adaptDate(jsonObject.getLong("date")), String.valueOf(jsonObject.getLong("trade_id")));
  }
View Full Code Here

      BigDecimal amount = hitbtcTrade.getAmount();
      String tid = hitbtcTrade.getTid();
      long longTradeId = tid == null ? 0 : Long.parseLong(tid);
      if (longTradeId > lastTradeId)
        lastTradeId = longTradeId;
      Trade trade = new Trade(null, amount, currencyPair, price, timestamp, tid);
      trades.add(trade);
    }

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

  public static Trade adaptTrade(VirtExTrade virtExTrade, CurrencyPair currencyPair) {

    BigDecimal amount = virtExTrade.getAmount();
    Date date = DateUtils.fromMillisUtc((long) virtExTrade.getDate() * 1000L);
    final String tradeId = String.valueOf(virtExTrade.getTid());
    return new Trade(null, amount, currencyPair, virtExTrade.getPrice(), date, tradeId);
  }
View Full Code Here

  public static Trade adaptTrade(String tradeId, CryptonitOrder cryptonitTrade, CurrencyPair currencyPair) {

    BigDecimal amount = cryptonitTrade.getBidAmount();
    BigDecimal price = cryptonitTrade.getBidRate();

    return new Trade(null, amount, currencyPair, price, DateUtils.fromMillisUtc(cryptonitTrade.getFilled() * 1000L), tradeId);
  }
View Full Code Here

  public static Trade adaptTrade(VirtExTrade virtExTrade, CurrencyPair currencyPair) {

    BigDecimal amount = virtExTrade.getAmount();
    Date date = DateUtils.fromMillisUtc((long) virtExTrade.getDate() * 1000L);
    final String tradeId = String.valueOf(virtExTrade.getTid());
    return new Trade(null, amount, currencyPair, virtExTrade.getPrice(), date, tradeId);
  }
View Full Code Here

    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()));
  }
View Full Code Here

  @Test
  public void testAdaptTrade() throws JSONException, IOException {

    JSONObject jsonObject = new JSONObject(IOUtils.toString(getClass().getResource("trade.json"), Charsets.UTF_8));
    Trade trade = BTCChinaJSONObjectAdapters.adaptTrade(jsonObject);
    assertEquals(new BigDecimal("0.79000000"), trade.getTradableAmount());
    assertEquals(CurrencyPair.BTC_CNY, trade.getCurrencyPair());
    assertEquals(new BigDecimal("2350.25"), trade.getPrice());
    assertEquals("8948160", trade.getId());
    assertEquals(1411924375000L, trade.getTimestamp().getTime());
    assertEquals(OrderType.ASK, trade.getType());
  }
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.