use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class TradeServiceIntegration method marketSellTest.
/*
* @Test public void marketBuyTest() throws Exception { Exchange exchange = ExchangeUtils.createExchangeFromJsonConfiguration(); if (exchange ==
* null) { return; // forces pass if not configuration is available } assertNotNull(exchange); TradeService service = exchange.getTradeService();
* assertNotNull(service); String id = service.placeMarketOrder(new MarketOrder(Order.OrderType.BID, new BigDecimal("0.1"), CurrencyPair.BTC_EUR));
* System.out.println("Market buy order id = " + id); }
*/
@Test
public void marketSellTest() throws Exception {
Exchange exchange = ExchangeUtils.createExchangeFromJsonConfiguration();
if (exchange == null) {
// forces pass if not configuration is available
return;
}
assertNotNull(exchange);
TradeService service = exchange.getTradeService();
assertNotNull(service);
service.placeMarketOrder(new MarketOrder(Order.OrderType.ASK, new BigDecimal("0.001"), CurrencyPair.BTC_EUR));
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class DsxTradeServiceRawIntegration method testPlaceMarketOrderRaw.
@Test
public void testPlaceMarketOrderRaw() throws IOException {
Date date = new Date();
String id = date.toString().replace(" ", "");
LOGGER.info("Placing order id : " + id);
exception.expect(DsxException.class);
exception.expectMessage("Insufficient funds");
MarketOrder limitOrder = new MarketOrder(Order.OrderType.BID, new BigDecimal("0.01"), CurrencyPair.BTC_USD, id, new Date());
service.placeMarketOrderRaw(limitOrder);
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class BinanceAdaptersTest method testFilledMarketOrder.
@Test
public void testFilledMarketOrder() throws IOException {
BinanceOrder binanceOrder = ObjectMapperHelper.readValue(BinanceAdaptersTest.class.getResource("/org/knowm/xchange/binance/filled-market-order.json"), BinanceOrder.class);
Order order = BinanceAdapters.adaptOrder(binanceOrder);
assertThat(order).isInstanceOf(MarketOrder.class);
MarketOrder marketOrder = (MarketOrder) order;
assertThat(marketOrder.getStatus()).isEqualByComparingTo(Order.OrderStatus.FILLED);
assertThat(marketOrder.getOriginalAmount()).isEqualByComparingTo("0.10700000");
assertThat(marketOrder.getCumulativeAmount()).isEqualByComparingTo("0.10700000");
assertThat(marketOrder.getRemainingAmount()).isEqualByComparingTo(BigDecimal.ZERO);
assertThat(marketOrder.getAveragePrice()).isEqualByComparingTo("0.01858383");
assertThat(marketOrder.getOrderFlags()).contains(BinanceOrderFlags.withClientId("gzcLIkn86ag3FycOCEl6Vi"));
MarketOrder copy = ObjectMapperHelper.viaJSON(marketOrder);
assertThat(copy).isEqualToComparingFieldByField(marketOrder);
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class TradeServiceIntegration method testPlaceTestOrderMarketOrderShouldNotThrowAnyException.
@Test
public void testPlaceTestOrderMarketOrderShouldNotThrowAnyException() throws IOException {
final MarketOrder marketOrder = sampleMarketOrder();
tradeService.placeTestOrder(MARKET, marketOrder, null, null);
}
use of org.knowm.xchange.dto.trade.MarketOrder in project XChange by knowm.
the class BTCMarketsTradeServiceTest method shouldPlaceMarketOrder.
@Test
public void shouldPlaceMarketOrder() throws IOException {
MarketOrder marketOrder = new MarketOrder.Builder(Order.OrderType.BID, CurrencyPair.BTC_AUD).originalAmount(new BigDecimal("10.00000000")).build();
BTCMarketsPlaceOrderRequest btcMarketsOrder = new BTCMarketsPlaceOrderRequest("BTC-AUD", "0", "10.00000000", "Market", "Bid", null, null, "GTC", false, null, null);
BTCMarketsPlaceOrderResponse orderResponse = new BTCMarketsPlaceOrderResponse("11111");
when(btcMarketsAuthenticatedV3.placeOrder(Mockito.eq(SPECIFICATION_API_KEY), Mockito.any(SynchronizedValueFactory.class), Mockito.any(BTCMarketsDigestV3.class), Mockito.refEq(btcMarketsOrder))).thenReturn(orderResponse);
// when
String placed = btcMarketsTradeService.placeMarketOrder(marketOrder);
// then
assertThat(placed).isEqualTo("11111");
}
Aggregations