use of org.knowm.xchange.gemini.v1.dto.trade.GeminiLimitOrder in project XChange by knowm.
the class GeminiTradeService method placeLimitOrder.
@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
GeminiOrderStatusResponse newOrder = placeGeminiLimitOrder(limitOrder, GeminiOrderType.LIMIT);
// of this order. Make these available to the application if it has provided a GeminiLimitOrder.
if (limitOrder instanceof GeminiLimitOrder) {
GeminiLimitOrder raw = (GeminiLimitOrder) limitOrder;
raw.setResponse(newOrder);
}
return String.valueOf(newOrder.getId());
}
use of org.knowm.xchange.gemini.v1.dto.trade.GeminiLimitOrder in project XChange by knowm.
the class GeminiStreamingMarketDataService method getOrderBook.
@Override
public Observable<OrderBook> getOrderBook(CurrencyPair currencyPair, Object... args) {
int maxDepth = (int) MoreObjects.firstNonNull(args.length > 0 ? args[0] : null, 1);
Observable<GeminiOrderbook> subscribedOrderbookSnapshot = service.subscribeChannel(currencyPair, maxDepth, maxDepth).filter(s -> filterEventsByReason(s, "change", "initial") || filterEventsByReason(s, "change", "place") || filterEventsByReason(s, "change", "cancel") || filterEventsByReason(s, "change", "trade")).filter(// filter out updates that arrive before initial book
s -> orderbooks.get(currencyPair) != null || filterEventsByReason(s, "change", "initial")).map((JsonNode s) -> {
if (filterEventsByReason(s, "change", "initial")) {
GeminiWebSocketTransaction transaction = mapper.treeToValue(s, GeminiWebSocketTransaction.class);
GeminiOrderbook orderbook = transaction.toGeminiOrderbook(currencyPair);
orderbooks.put(currencyPair, orderbook);
return orderbook;
}
if (filterEventsByReason(s, "change", "place") || filterEventsByReason(s, "change", "cancel") || filterEventsByReason(s, "change", "trade")) {
GeminiWebSocketTransaction transaction = mapper.treeToValue(s, GeminiWebSocketTransaction.class);
GeminiLimitOrder[] levels = transaction.toGeminiLimitOrdersUpdate();
GeminiOrderbook orderbook = orderbooks.get(currencyPair);
orderbook.updateLevels(levels);
return orderbook;
}
throw new NotYetImplementedForExchangeException(" Unknown message type, even after filtering: " + s.toString());
});
return subscribedOrderbookSnapshot.map(geminiOrderbook -> GeminiAdaptersX.toOrderbook(geminiOrderbook, maxDepth, new Date()));
}
Aggregations