use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class LgoTradeServiceTest method cannotPlaceAskMarketOrderWithAmountToLow.
@Test
public void cannotPlaceAskMarketOrderWithAmountToLow() {
ThrowingCallable check = () -> tradeService.verifyOrder(new MarketOrder(OrderType.ASK, new BigDecimal("0.00001"), CurrencyPair.BTC_USD, new Date()));
assertThatThrownBy(check).isInstanceOf(IllegalArgumentException.class).hasMessage("Quantity to low");
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class LgoTradeServiceTest method cannotPlaceAskMarketOrderWithAmountToHigh.
@Test
public void cannotPlaceAskMarketOrderWithAmountToHigh() {
ThrowingCallable check = () -> tradeService.verifyOrder(new MarketOrder(OrderType.ASK, new BigDecimal("1001"), CurrencyPair.BTC_USD, new Date()));
assertThatThrownBy(check).isInstanceOf(IllegalArgumentException.class).hasMessage("Quantity to high");
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class LgoAdaptersTest method adaptsAskMarketOrder.
@Test
public void adaptsAskMarketOrder() {
Date timestamp = new Date();
MarketOrder marketOrder = new MarketOrder(OrderType.ASK, new BigDecimal("1"), CurrencyPair.BTC_USD, null, timestamp);
LgoPlaceOrder bidOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder);
assertThat(bidOrder).isEqualToComparingFieldByField(new LgoPlaceMarketOrder(0, "S", "BTC-USD", new BigDecimal("1"), timestamp.toInstant()));
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class LgoAdaptersTest method adaptsBidMarketOrder.
@Test
public void adaptsBidMarketOrder() {
Date now = new Date();
MarketOrder marketOrder = new MarketOrder(OrderType.BID, new BigDecimal("1"), CurrencyPair.BTC_USD, null, now);
LgoPlaceOrder bidOrder = LgoAdapters.adaptEncryptedMarketOrder(marketOrder);
assertThat(bidOrder).isEqualToComparingFieldByField(new LgoPlaceMarketOrder(0, "B", "BTC-USD", new BigDecimal("1"), now.toInstant()));
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class BitfinexTradeServiceRaw method placeBitfinexOrderMulti.
public BitfinexNewOrderMultiResponse placeBitfinexOrderMulti(List<? extends Order> orders, BitfinexOrderType bitfinexOrderType) throws IOException {
BitfinexNewOrder[] bitfinexOrders = new BitfinexNewOrder[orders.size()];
for (int i = 0; i < bitfinexOrders.length; i++) {
Order o = orders.get(i);
if (o instanceof LimitOrder) {
LimitOrder limitOrder = (LimitOrder) o;
String pair = BitfinexUtils.toPairStringV1(limitOrder.getCurrencyPair());
String type = (limitOrder.getType().equals(OrderType.BID) || limitOrder.getType().equals(OrderType.EXIT_ASK)) ? "buy" : "sell";
String orderType = bitfinexOrderType.toString();
bitfinexOrders[i] = new BitfinexNewOrder(pair, "bitfinex", type, orderType, limitOrder.getOriginalAmount(), limitOrder.getLimitPrice());
} else if (o instanceof MarketOrder) {
MarketOrder marketOrder = (MarketOrder) o;
String pair = BitfinexUtils.toPairStringV1(marketOrder.getCurrencyPair());
String type = (marketOrder.getType().equals(OrderType.BID) || marketOrder.getType().equals(OrderType.EXIT_ASK)) ? "buy" : "sell";
String orderType = bitfinexOrderType.toString();
bitfinexOrders[i] = new BitfinexNewOrder(pair, "bitfinex", type, orderType, marketOrder.getOriginalAmount(), BigDecimal.ONE);
}
}
BitfinexNewOrderMultiRequest request = new BitfinexNewOrderMultiRequest(String.valueOf(exchange.getNonceFactory().createValue()), bitfinexOrders);
return decorateApiCall(() -> bitfinex.newOrderMulti(apiKey, payloadCreator, signatureCreator, request)).withRateLimiter(rateLimiter(BITFINEX_RATE_LIMITER)).call();
}
Aggregations