Search in sources :

Example 1 with KucoinOrderFlags

use of org.knowm.xchange.kucoin.KucoinTradeService.KucoinOrderFlags in project XChange by knowm.

the class KucoinAdapters method adaptOrder.

/**
 * Returns {@code Object} instead of the Lombok builder in order to avoid a Lombok limitation with
 * Javadoc.
 */
private static Object adaptOrder(Order order) {
    OrderCreateApiRequest.OrderCreateApiRequestBuilder request = OrderCreateApiRequest.builder();
    boolean hasClientId = false;
    for (IOrderFlags flag : order.getOrderFlags()) {
        if (flag instanceof KucoinOrderFlags) {
            request.clientOid(((KucoinOrderFlags) flag).getClientId());
            hasClientId = true;
        } else if (flag instanceof TimeInForce) {
            request.timeInForce(((TimeInForce) flag).name());
        }
    }
    if (!hasClientId) {
        request.clientOid(UUID.randomUUID().toString());
    }
    return request.symbol(adaptCurrencyPair((CurrencyPair) order.getInstrument())).size(order.getOriginalAmount()).side(adaptSide(order.getType()));
}
Also used : IOrderFlags(org.knowm.xchange.dto.Order.IOrderFlags) KucoinOrderFlags(org.knowm.xchange.kucoin.KucoinTradeService.KucoinOrderFlags) OrderCreateApiRequest(org.knowm.xchange.kucoin.dto.request.OrderCreateApiRequest) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 IOrderFlags (org.knowm.xchange.dto.Order.IOrderFlags)1 KucoinOrderFlags (org.knowm.xchange.kucoin.KucoinTradeService.KucoinOrderFlags)1 OrderCreateApiRequest (org.knowm.xchange.kucoin.dto.request.OrderCreateApiRequest)1