Search in sources :

Example 1 with TimeInForce

use of org.knowm.xchange.binance.dto.trade.TimeInForce in project XChange by knowm.

the class BinanceTradeService method placeStopOrder.

@Override
public String placeStopOrder(StopOrder order) throws IOException {
    // Time-in-force should not be provided for market orders but is required for
    // limit orders, order we only default it for limit orders. If the caller
    // specifies one for a market order, we don't remove it, since Binance might
    // allow
    // it at some point.
    TimeInForce tif = timeInForceFromOrder(order).orElse(order.getLimitPrice() != null ? TimeInForce.GTC : null);
    OrderType orderType = BinanceAdapters.adaptOrderType(order);
    return placeOrder(orderType, order, order.getLimitPrice(), order.getStopPrice(), tif);
}
Also used : OrderType(org.knowm.xchange.binance.dto.trade.OrderType) TimeInForce(org.knowm.xchange.binance.dto.trade.TimeInForce)

Example 2 with TimeInForce

use of org.knowm.xchange.binance.dto.trade.TimeInForce in project XChange by knowm.

the class BinanceTradeService method placeTestOrder.

public void placeTestOrder(OrderType type, Order order, BigDecimal limitPrice, BigDecimal stopPrice) throws IOException {
    try {
        TimeInForce tif = timeInForceFromOrder(order).orElse(null);
        Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
        testNewOrder(order.getCurrencyPair(), BinanceAdapters.convert(order.getType()), type, tif, order.getOriginalAmount(), limitPrice, getClientOrderId(order), stopPrice, null);
    } catch (BinanceException e) {
        throw BinanceErrorAdapter.adapt(e);
    }
}
Also used : BinanceException(org.knowm.xchange.binance.dto.BinanceException) TimeInForce(org.knowm.xchange.binance.dto.trade.TimeInForce)

Example 3 with TimeInForce

use of org.knowm.xchange.binance.dto.trade.TimeInForce in project XChange by knowm.

the class BinanceTradeService method placeLimitOrder.

@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
    TimeInForce tif = timeInForceFromOrder(limitOrder).orElse(TimeInForce.GTC);
    OrderType type;
    if (limitOrder.hasFlag(org.knowm.xchange.binance.dto.trade.BinanceOrderFlags.LIMIT_MAKER)) {
        type = OrderType.LIMIT_MAKER;
        tif = null;
    } else {
        type = OrderType.LIMIT;
    }
    return placeOrder(type, limitOrder, limitOrder.getLimitPrice(), null, tif);
}
Also used : OrderType(org.knowm.xchange.binance.dto.trade.OrderType) TimeInForce(org.knowm.xchange.binance.dto.trade.TimeInForce)

Aggregations

TimeInForce (org.knowm.xchange.binance.dto.trade.TimeInForce)3 OrderType (org.knowm.xchange.binance.dto.trade.OrderType)2 BinanceException (org.knowm.xchange.binance.dto.BinanceException)1