本文整理了Java中com.xeiam.xchange.dto.marketdata.OrderBook
类的一些代码示例,展示了OrderBook
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OrderBook
类的具体详情如下:
包路径:com.xeiam.xchange.dto.marketdata.OrderBook
类名称:OrderBook
暂无
代码示例来源:origin: com.xeiam.xchange/xchange-mintpal
public static OrderBook adaptOrderBook(final CurrencyPair currencyPair, final List<MintPalPublicOrders> mintPalOrderBook) {
final boolean firstIsBids = mintPalOrderBook.get(0).getType().equalsIgnoreCase("buy");
final List<LimitOrder> bids = firstIsBids ? adaptOrders(currencyPair, OrderType.BID, mintPalOrderBook.get(0)) : adaptOrders(currencyPair, OrderType.BID, mintPalOrderBook.get(1));
final List<LimitOrder> asks = firstIsBids ? adaptOrders(currencyPair, OrderType.ASK, mintPalOrderBook.get(1)) : adaptOrders(currencyPair, OrderType.ASK, mintPalOrderBook.get(0));
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-coinfloor
public Map<String, Object> adaptOrderOpened(String data) {
Map<String, Object> resultMap = new HashMap<String, Object>();
CoinfloorOrder rawRetObj;
try {
rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
} catch (IOException e) {
throw new ExchangeException("JSON parse error", e);
}
synchronized (cachedDataSynchronizationObject) {
List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
if (rawRetObj.getBaseQty().doubleValue() > 0) {
bidList.add(adaptOrder(rawRetObj));
} else {
askList.add(adaptOrder(rawRetObj));
}
cachedOrderBook = new OrderBook(null, askList, bidList);
}
resultMap.put("generic", adaptOrder(rawRetObj));
resultMap.put("raw", rawRetObj);
return resultMap;
}
代码示例来源:origin: sutra/huobi-client
if (depth.getBids().size() >= 2) {
BigDecimal bid0 = depth.getBids().get(0).getLimitPrice();
BigDecimal bid1 = depth.getBids().get(1).getLimitPrice();
if (bid0.compareTo(bid1) <= 0) {
throw new RuntimeException("bids in depth should be ordered from highest to lowest.");
if (depth.getAsks().size() >= 2) {
BigDecimal ask0 = depth.getAsks().get(0).getLimitPrice();
BigDecimal ask1 = depth.getAsks().get(1).getLimitPrice();
if (ask0.compareTo(ask1) >= 0) {
throw new RuntimeException("asks in depth should be ordered from lowest to highest.");
代码示例来源:origin: com.xeiam.xchange/xchange-loyalbit
public static OrderBook adaptOrderBook(LoyalbitOrderBook loyalbitOrderBook, CurrencyPair currencyPair) {
List<LimitOrder> asks = createOrders(currencyPair, Order.OrderType.ASK, loyalbitOrderBook.getAsks());
List<LimitOrder> bids = createOrders(currencyPair, Order.OrderType.BID, loyalbitOrderBook.getBids());
return new OrderBook(new Date(), asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-coinfloor
public Map<String, Object> adaptOrders(String data) throws ExchangeException {
Map<String, Object> resultMap = new HashMap<String, Object>();
CoinfloorOrderbook rawRetObj;
try {
rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrderbook.class);
} catch (IOException e) {
throw new ExchangeException("JSON parse error", e);
}
resultMap.put("raw", rawRetObj);
OrderBook orderbook;
synchronized (cachedDataSynchronizationObject) {
List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
List<CoinfloorOrder> orders = rawRetObj.getOrders();
if (orders != null) {
for (CoinfloorOrder order : orders) {
if (order.getBaseQty().doubleValue() > 0) {
bidList.add(adaptOrder(order));
} else {
askList.add(adaptOrder(order));
}
}
}
orderbook = new OrderBook(null, askList, bidList);
cachedOrderBook = orderbook;
}
resultMap.put("generic", orderbook);
return resultMap;
}
代码示例来源:origin: com.xeiam.xchange/xchange-btccentral
/**
* @param marketDepth
* @param currencyPair
* @return new order book
*/
public static OrderBook adaptMarketDepth(BTCCentralMarketDepth marketDepth, CurrencyPair currencyPair) {
List<LimitOrder> asks = adaptMarketOrderToLimitOrder(marketDepth.getAsks(), OrderType.ASK, currencyPair);
List<LimitOrder> bids = adaptMarketOrderToLimitOrder(marketDepth.getBids(), OrderType.BID, currencyPair);
Collections.reverse(bids);
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-coinfloor
List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
if (rawRetObj.getBaseQty().doubleValue() > 0) {
for (int i = 0; i < bidList.size(); i++) {
cachedOrderBook = new OrderBook(null, askList, bidList);
代码示例来源:origin: com.xeiam.xchange/xchange-cryptsy
public static List<OrderBook> adaptPublicOrderBooks(Map<Integer, CryptsyPublicOrderbook> cryptsyOrderBooks) {
List<OrderBook> orderBooks = new ArrayList<OrderBook>();
for (CryptsyPublicOrderbook cryptsyOrderBook : cryptsyOrderBooks.values()) {
CurrencyPair currencyPair = adaptCurrencyPair(cryptsyOrderBook.getLabel());
List<LimitOrder> asks = adaptPublicOrders(cryptsyOrderBook.getSellOrders(), OrderType.ASK, currencyPair);
List<LimitOrder> bids = adaptPublicOrders(cryptsyOrderBook.getBuyOrders(), OrderType.BID, currencyPair);
orderBooks.add(new OrderBook(null, asks, bids));
}
return orderBooks;
}
代码示例来源:origin: com.xeiam.xchange/xchange-coinfloor
List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
if (rawRetObj.getBidId() != 0) {
for (int i = 0; i < bidList.size(); i++) {
cachedOrderBook = new OrderBook(null, askList, bidList);
代码示例来源:origin: com.xeiam.xchange/xchange-huobi
public static OrderBook adaptOrderBook(BitVcFuturesDepth depth, CurrencyPair currencyPair) {
List<LimitOrder> asks = adaptOrderBook(depth.getAsks(), ASK, currencyPair);
List<LimitOrder> bids = adaptOrderBook(depth.getBids(), BID, currencyPair);
// ask side is flipped
Collections.sort(asks);
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitstamp
private OrderBook parseOrderBook(String rawJson) throws IOException {
BitstampStreamingOrderBook bitstampOrderBook = streamObjectMapper.readValue(rawJson, BitstampStreamingOrderBook.class);
List<LimitOrder> asks = BitstampAdapters.createOrders(CurrencyPair.BTC_USD, Order.OrderType.ASK, bitstampOrderBook.getAsks());
List<LimitOrder> bids = BitstampAdapters.createOrders(CurrencyPair.BTC_USD, Order.OrderType.BID, bitstampOrderBook.getBids());
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-btctrade
public static OrderBook adaptOrderBook(BTCTradeDepth btcTradeDepth, CurrencyPair currencyPair) {
List<LimitOrder> asks = adaptLimitOrders(btcTradeDepth.getAsks(), currencyPair, OrderType.ASK);
Collections.reverse(asks);
List<LimitOrder> bids = adaptLimitOrders(btcTradeDepth.getBids(), currencyPair, OrderType.BID);
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-ripple
return new OrderBook(null, asks, bids);
代码示例来源:origin: com.xeiam.xchange/xchange-cavirtex
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
// Request data
VirtExDepth virtExDepth = getVirtExOrderBook(currencyPair);
// Adapt to XChange DTOs
List<LimitOrder> asks = VirtExAdapters.adaptOrders(virtExDepth.getAsks(), currencyPair, "ask", "");
Collections.reverse(asks);
List<LimitOrder> bids = VirtExAdapters.adaptOrders(virtExDepth.getBids(), currencyPair, "bid", "");
return new OrderBook(null, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitso
public static OrderBook adaptOrderBook(BitsoOrderBook bitsoOrderBook, CurrencyPair currencyPair, int timeScale) {
List<LimitOrder> asks = createOrders(currencyPair, Order.OrderType.ASK, bitsoOrderBook.getAsks());
List<LimitOrder> bids = createOrders(currencyPair, Order.OrderType.BID, bitsoOrderBook.getBids());
Date date = new Date(bitsoOrderBook.getTimestamp() * timeScale); // polled order books provide a timestamp in seconds, stream in ms
return new OrderBook(date, asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-cointrader
public static OrderBook adaptOrderBook(CointraderOrderBook cointraderOrderBook) {
List<LimitOrder> asks = new ArrayList<LimitOrder>();
List<LimitOrder> bids = new ArrayList<LimitOrder>();
for (CointraderOrderBook.Entry obe : cointraderOrderBook.getData()) {
if (CointraderOrder.Type.Buy.equals(obe.getType())) {
bids.add(new LimitOrder(Order.OrderType.BID, obe.getQuantity(), obe.getCurrencyPair(), null, obe.getCreated(), obe.getPrice()));
} else {
asks.add(new LimitOrder(Order.OrderType.ASK, obe.getQuantity(), obe.getCurrencyPair(), null, obe.getCreated(), obe.getPrice()));
}
}
Collections.sort(bids, BID_COMPARATOR);
Collections.sort(asks, ASK_COMPARATOR);
return new OrderBook(new Date(), asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitfinex
public static OrderBook adaptOrderBook(BitfinexDepth btceDepth, CurrencyPair currencyPair) {
OrdersContainer asksOrdersContainer = adaptOrders(btceDepth.getAsks(), currencyPair, OrderType.ASK);
OrdersContainer bidsOrdersContainer = adaptOrders(btceDepth.getBids(), currencyPair, OrderType.BID);
return new OrderBook(new Date(Math.max(asksOrdersContainer.getTimestamp(), bidsOrdersContainer.getTimestamp())),
asksOrdersContainer.getLimitOrders(), bidsOrdersContainer.getLimitOrders());
}
代码示例来源:origin: com.xeiam.xchange/xchange-okcoin
public static OrderBook adaptOrderBook(OkCoinDepth depth, CurrencyPair currencyPair) {
List<LimitOrder> asks = adaptLimitOrders(OrderType.ASK, depth.getAsks(), currencyPair);
Collections.reverse(asks);
List<LimitOrder> bids = adaptLimitOrders(OrderType.BID, depth.getBids(), currencyPair);
return new OrderBook(depth.getTimestamp(), asks, bids);
}
代码示例来源:origin: com.xeiam.xchange/xchange-kraken
public static OrderBook adaptOrderBook(KrakenDepth krakenDepth, CurrencyPair currencyPair) {
OrdersContainer asksOrdersContainer = adaptOrders(krakenDepth.getAsks(), currencyPair, OrderType.ASK);
OrdersContainer bidsOrdersContainer = adaptOrders(krakenDepth.getBids(), currencyPair, OrderType.BID);
return new OrderBook(new Date(Math.max(asksOrdersContainer.getTimestamp(), bidsOrdersContainer.getTimestamp())),
asksOrdersContainer.getLimitOrders(), bidsOrdersContainer.getLimitOrders());
}
代码示例来源:origin: com.xeiam.xchange/xchange-bitstamp
/**
* Adapts a com.xeiam.xchange.bitstamp.api.model.OrderBook to a OrderBook Object
*
* @param currencyPair (e.g. BTC/USD)
* @param currency The currency (e.g. USD in BTC/USD)
* @param timeScale polled order books provide a timestamp in seconds, stream in ms
* @return The XChange OrderBook
*/
public static OrderBook adaptOrderBook(BitstampOrderBook bitstampOrderBook, CurrencyPair currencyPair, int timeScale) {
List<LimitOrder> asks = createOrders(currencyPair, Order.OrderType.ASK, bitstampOrderBook.getAsks());
List<LimitOrder> bids = createOrders(currencyPair, Order.OrderType.BID, bitstampOrderBook.getBids());
Date date = new Date(bitstampOrderBook.getTimestamp() * timeScale); // polled order books provide a timestamp in seconds, stream in ms
return new OrderBook(date, asks, bids);
}
内容来源于网络,如有侵权,请联系作者删除!