use of org.knowm.xchange.gemini.v1.dto.marketdata.GeminiTrade in project XChange by knowm.
the class GeminiAdapters method adaptTrades.
public static Trades adaptTrades(GeminiTrade[] trades, CurrencyPair currencyPair) {
List<Trade> tradesList = new ArrayList<>(trades.length);
long lastTradeId = 0;
for (GeminiTrade trade : trades) {
long tradeId = trade.getTradeId();
if (tradeId > lastTradeId) {
lastTradeId = tradeId;
}
tradesList.add(adaptTrade(trade, currencyPair));
}
return new Trades(tradesList, lastTradeId, TradeSortType.SortByID);
}
use of org.knowm.xchange.gemini.v1.dto.marketdata.GeminiTrade in project XChange by knowm.
the class GeminiWebSocketTransaction method toGeminiTrades.
public GeminiTrade[] toGeminiTrades() {
long timestamp = Long.valueOf(this.timestamp);
List<GeminiTrade> trades = new ArrayList<>(1000);
for (JsonNode jsonEvent : events) {
if (jsonEvent.get("type").asText().equals("trade")) {
GeminiTrade trade = toGeminiTrade(jsonEvent, timestamp);
trades.add(trade);
}
}
return trades.toArray(new GeminiTrade[trades.size()]);
}
use of org.knowm.xchange.gemini.v1.dto.marketdata.GeminiTrade in project XChange by knowm.
the class GeminiWebSocketTransaction method toGeminiTrade.
private static GeminiTrade toGeminiTrade(JsonNode jsonEvent, long timestamp) {
long tid = Long.valueOf(jsonEvent.get("tid").asText());
BigDecimal price = new BigDecimal(jsonEvent.get("price").asText());
BigDecimal amount = new BigDecimal(jsonEvent.get("amount").asText());
String takerSide = jsonEvent.get("makerSide").asText().equals("ask") ? "buy" : "sell";
return new GeminiTrade(price, amount, timestamp, "gemini", tid, takerSide);
}
use of org.knowm.xchange.gemini.v1.dto.marketdata.GeminiTrade in project XChange by knowm.
the class GeminiAdapters method adaptTrade.
public static Trade adaptTrade(GeminiTrade trade, CurrencyPair currencyPair) {
OrderType orderType = trade.getType().equals("buy") ? OrderType.BID : OrderType.ASK;
BigDecimal amount = trade.getAmount();
BigDecimal price = trade.getPrice();
Date date = // Gemini uses Unix timestamps
DateUtils.fromMillisUtc(trade.getTimestamp() * 1000L);
final String tradeId = String.valueOf(trade.getTradeId());
return new Trade.Builder().type(orderType).originalAmount(amount).currencyPair(currencyPair).price(price).timestamp(date).id(tradeId).build();
}
Aggregations