use of com.github.jnidzwetzki.bitfinex.v2.callback.api.NotificationHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManagerTest method testOrderSubmissionFailed.
/**
* Test order submit failed
* @throws APIException
* @throws InterruptedException
*/
@Test(timeout = 10000)
public void testOrderSubmissionFailed() throws APIException, InterruptedException {
final String jsonString = "[0,\"n\",[null,\"on-req\",null,null,[null,null,1513970684865000,\"tBTCUSD\",null,null,0.001,0.001,\"EXCHANGE MARKET\",null,null,null,null,null,null,null,12940,null,null,null,null,null,null,0,null,null],null,\"ERROR\",\"Invalid order: minimum size for BTC/USD is 0.002\"]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final CountDownLatch latch = new CountDownLatch(1);
final Consumer<ExchangeOrder> orderCallback = (e) -> {
Assert.assertEquals(ExchangeOrderState.STATE_ERROR, e.getState());
Assert.assertEquals(API_KEY, e.getApikey());
Assert.assertEquals(1513970684865000l, e.getCid());
Assert.assertEquals(BitfinexCurrencyPair.BTC_USD.toBitfinexString(), e.getSymbol());
latch.countDown();
};
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
bitfinexApiBroker.getOrderManager().registerCallback(orderCallback);
final NotificationHandler notificationHandler = new NotificationHandler();
notificationHandler.handleChannelData(bitfinexApiBroker, jsonArray);
latch.await();
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.NotificationHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexApiBroker method setupChannelHandler.
/**
* Setup the channel handler
*/
private void setupChannelHandler() {
// Heartbeat
channelHandler.put("hb", new HeartbeatHandler());
// Position snapshot
channelHandler.put("ps", new PositionHandler());
// Position new
channelHandler.put("pn", new PositionHandler());
// Position updated
channelHandler.put("pu", new PositionHandler());
// Position caneled
channelHandler.put("pc", new PositionHandler());
// Founding offers
channelHandler.put("fos", new DoNothingHandler());
// Founding credits
channelHandler.put("fcs", new DoNothingHandler());
// Founding loans
channelHandler.put("fls", new DoNothingHandler());
// Ats - Unkown
channelHandler.put("ats", new DoNothingHandler());
// Wallet snapshot
channelHandler.put("ws", new WalletHandler());
// Wallet update
channelHandler.put("wu", new WalletHandler());
// Order snapshot
channelHandler.put("os", new OrderHandler());
// Order notification
channelHandler.put("on", new OrderHandler());
// Order update
channelHandler.put("ou", new OrderHandler());
// Order cancelation
channelHandler.put("oc", new OrderHandler());
// Trade executed
channelHandler.put("te", new TradeHandler());
// Trade update
channelHandler.put("tu", new TradeHandler());
// General notification
channelHandler.put("n", new NotificationHandler());
}
Aggregations