Search in sources :

Example 1 with ExchangeOrderState

use of com.github.jnidzwetzki.bitfinex.v2.entity.ExchangeOrderState in project bitfinex-v2-wss-api-java by jnidzwetzki.

the class OrderHandler method handleOrderCallback.

/**
 * Handle a single order callback
 * @param bitfinexApiBroker
 * @param orderArray
 * @throws APIException
 */
private void handleOrderCallback(BitfinexApiBroker bitfinexApiBroker, final JSONArray order) throws APIException {
    final ExchangeOrder exchangeOrder = new ExchangeOrder();
    exchangeOrder.setApikey(bitfinexApiBroker.getApiKey());
    exchangeOrder.setOrderId(order.getLong(0));
    exchangeOrder.setGroupId(order.optInt(1, -1));
    exchangeOrder.setCid(order.optLong(2, -1));
    exchangeOrder.setSymbol(order.getString(3));
    exchangeOrder.setCreated(order.getLong(4));
    exchangeOrder.setUpdated(order.getLong(5));
    exchangeOrder.setAmount(order.getBigDecimal(6));
    exchangeOrder.setAmountAtCreation(order.getBigDecimal(7));
    exchangeOrder.setOrderType(BitfinexOrderType.fromString(order.getString(8)));
    final ExchangeOrderState orderState = ExchangeOrderState.fromString(order.getString(13));
    exchangeOrder.setState(orderState);
    exchangeOrder.setPrice(order.optBigDecimal(16, BigDecimal.valueOf(-1)));
    exchangeOrder.setPriceAvg(order.optBigDecimal(17, BigDecimal.valueOf(-1)));
    exchangeOrder.setPriceTrailing(order.optBigDecimal(18, BigDecimal.valueOf(-1)));
    exchangeOrder.setPriceAuxLimit(order.optBigDecimal(19, BigDecimal.valueOf(-1)));
    exchangeOrder.setNotify(order.getInt(23) == 1 ? true : false);
    exchangeOrder.setHidden(order.getInt(24) == 1 ? true : false);
    bitfinexApiBroker.getOrderManager().updateOrder(exchangeOrder);
}
Also used : ExchangeOrderState(com.github.jnidzwetzki.bitfinex.v2.entity.ExchangeOrderState) ExchangeOrder(com.github.jnidzwetzki.bitfinex.v2.entity.ExchangeOrder)

Aggregations

ExchangeOrder (com.github.jnidzwetzki.bitfinex.v2.entity.ExchangeOrder)1 ExchangeOrderState (com.github.jnidzwetzki.bitfinex.v2.entity.ExchangeOrderState)1