Search in sources :

Example 11 with MarketOrder

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");
}
Also used : ThrowingCallable(org.assertj.core.api.ThrowableAssert.ThrowingCallable) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) BigDecimal(java.math.BigDecimal) Date(java.util.Date) LgoProductsTest(org.knowm.xchange.lgo.dto.product.LgoProductsTest) Test(org.junit.Test)

Example 12 with MarketOrder

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");
}
Also used : ThrowingCallable(org.assertj.core.api.ThrowableAssert.ThrowingCallable) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) BigDecimal(java.math.BigDecimal) Date(java.util.Date) LgoProductsTest(org.knowm.xchange.lgo.dto.product.LgoProductsTest) Test(org.junit.Test)

Example 13 with MarketOrder

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()));
}
Also used : LgoPlaceOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceOrder) LgoPlaceMarketOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder) LgoPlaceMarketOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) Date(java.util.Date) BigDecimal(java.math.BigDecimal) LgoProductsTest(org.knowm.xchange.lgo.dto.product.LgoProductsTest) Test(org.junit.Test)

Example 14 with MarketOrder

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()));
}
Also used : LgoPlaceOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceOrder) LgoPlaceMarketOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder) LgoPlaceMarketOrder(org.knowm.xchange.lgo.dto.order.LgoPlaceMarketOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) Date(java.util.Date) BigDecimal(java.math.BigDecimal) LgoProductsTest(org.knowm.xchange.lgo.dto.product.LgoProductsTest) Test(org.junit.Test)

Example 15 with MarketOrder

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();
}
Also used : BitfinexLimitOrder(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexLimitOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) FixedRateLoanOrder(org.knowm.xchange.dto.trade.FixedRateLoanOrder) Order(org.knowm.xchange.dto.Order) BitfinexNewOrder(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexNewOrder) ActiveOrder(org.knowm.xchange.bitfinex.v2.dto.trade.ActiveOrder) FloatingRateLoanOrder(org.knowm.xchange.dto.trade.FloatingRateLoanOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) BitfinexNewOrder(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexNewOrder) BitfinexNewOrderMultiRequest(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexNewOrderMultiRequest) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) BitfinexLimitOrder(org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexLimitOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder)

Aggregations

MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)45 BigDecimal (java.math.BigDecimal)37 Test (org.junit.Test)20 Date (java.util.Date)17 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)15 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)10 TradeService (org.knowm.xchange.service.trade.TradeService)9 UserTrades (org.knowm.xchange.dto.trade.UserTrades)8 Order (org.knowm.xchange.dto.Order)7 OrderType (org.knowm.xchange.dto.Order.OrderType)6 LgoProductsTest (org.knowm.xchange.lgo.dto.product.LgoProductsTest)6 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)5 IOException (java.io.IOException)4 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 Exchange (org.knowm.xchange.Exchange)4 StopOrder (org.knowm.xchange.dto.trade.StopOrder)4 OrderStatus (org.knowm.xchange.dto.Order.OrderStatus)3 ArrayList (java.util.ArrayList)2 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)2 UserTrade (org.knowm.xchange.dto.trade.UserTrade)2