Search in sources :

Example 1 with LatokenTestOrder

use of org.knowm.xchange.latoken.dto.trade.LatokenTestOrder in project XChange by knowm.

the class LatokenTradeServiceIntegration method newOrder.

@Test
public void newOrder() throws Exception {
    CurrencyPair pair = CurrencyPair.ETH_BTC;
    OrderType type = OrderType.BID;
    BigDecimal amount = BigDecimal.valueOf(0.01);
    BigDecimal limitPrice = BigDecimal.valueOf(0.018881);
    LimitOrder newOrder = new LimitOrder.Builder(type, pair).originalAmount(amount).limitPrice(limitPrice).timestamp(new Date(System.currentTimeMillis())).build();
    // Test order
    LatokenTestOrder testOrder = tradeService.placeLatokenTestOrder(pair, "", LatokenOrderSide.buy, limitPrice, amount);
    System.out.println(testOrder);
    // Place order
    String newOrderId = tradeService.placeLimitOrder(newOrder);
    System.out.println(newOrderId);
    // Check open orders
    DefaultOpenOrdersParamCurrencyPair params = (DefaultOpenOrdersParamCurrencyPair) tradeService.createOpenOrdersParams();
    params.setCurrencyPair(CurrencyPair.ETH_BTC);
    List<LimitOrder> openOrders = tradeService.getOpenOrders(params).getOpenOrders();
    System.out.println(openOrders);
    // Cancel
    tradeService.cancelLatokenOrder(newOrderId);
    // Check open orders
    openOrders = tradeService.getOpenOrders().getOpenOrders();
    System.out.println(openOrders);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) LatokenTestOrder(org.knowm.xchange.latoken.dto.trade.LatokenTestOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) Date(java.util.Date) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) Test(org.junit.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 Test (org.junit.Test)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 LatokenTestOrder (org.knowm.xchange.latoken.dto.trade.LatokenTestOrder)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1