use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class BookSanityCheckerTest method testWithAsksLimitOrderError.
@Test
public void testWithAsksLimitOrderError() {
ArrayList<LimitOrder> asks = new ArrayList<>();
ArrayList<LimitOrder> bids = new ArrayList<>();
LimitOrder a1 = new LimitOrder(Order.OrderType.ASK, new BigDecimal(-0.01), CurrencyPair.ADA_BNB, "1", new Date(), new BigDecimal(0.01));
asks.add(a1);
OrderBook book = new OrderBook(new Date(), asks, bids);
Assert.assertEquals(format("LimitOrder amount is <= 0 for %s", a1), BookSanityChecker.hasErrors(book));
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class BookSanityCheckerTest method testWithBidsWrongPriceOrder.
@Test
public void testWithBidsWrongPriceOrder() {
ArrayList<LimitOrder> asks = new ArrayList<>();
ArrayList<LimitOrder> bids = new ArrayList<>();
LimitOrder b1 = new LimitOrder(Order.OrderType.BID, new BigDecimal(0.01), CurrencyPair.ADA_BNB, "1", new Date(), new BigDecimal(0.01));
LimitOrder b2 = new LimitOrder(Order.OrderType.BID, new BigDecimal(0.02), CurrencyPair.ADA_BNB, "2", new Date(), new BigDecimal(0.02));
bids.add(b1);
bids.add(b2);
OrderBook book = new OrderBook(new Date(), asks, bids);
Assert.assertEquals(format("Wrong price order for LimitOrders %s, %s", b2, b1), BookSanityChecker.hasErrors(book));
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class BookSanityCheckerTest method testNoBidsNoErrors.
@Test
public void testNoBidsNoErrors() {
ArrayList<LimitOrder> asks = new ArrayList<>();
ArrayList<LimitOrder> bids = new ArrayList<>();
asks.add(new LimitOrder(Order.OrderType.ASK, new BigDecimal(0.01), CurrencyPair.ADA_BNB, "1", new Date(), new BigDecimal(0.01)));
asks.add(new LimitOrder(Order.OrderType.ASK, new BigDecimal(0.02), CurrencyPair.ADA_BNB, "2", new Date(), new BigDecimal(0.02)));
OrderBook book = new OrderBook(new Date(), asks, bids);
Assert.assertNull(BookSanityChecker.hasErrors(book));
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class CryptopiaAdapters method adaptOrderBook.
/**
* Adapts a CryptopiaOrderBook to an OrderBook Object
*
* @param cryptopiaOrderBook The exchange specific order book
* @param currencyPair (e.g. BTC/USD)
* @return The XChange OrderBook
*/
public static OrderBook adaptOrderBook(CryptopiaOrderBook cryptopiaOrderBook, CurrencyPair currencyPair) {
List<LimitOrder> asks = createOrders(currencyPair, Order.OrderType.ASK, cryptopiaOrderBook.getAsks());
List<LimitOrder> bids = createOrders(currencyPair, Order.OrderType.BID, cryptopiaOrderBook.getBids());
return new OrderBook(new Date(), asks, bids);
}
use of org.knowm.xchange.dto.marketdata.OrderBook in project XChange by knowm.
the class OrderBookTest method testSerializeDeserialize.
@Test
public void testSerializeDeserialize() throws IOException {
OrderBook jsonCopy = ObjectMapperHelper.viaJSON(orderBook);
assertThat(jsonCopy.getTimeStamp()).isEqualTo(orderBook.getTimeStamp());
}
Aggregations