use of com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManagerTest method testOrderChannelHandler2.
/**
* Test the order channel handler - snapshot
* @throws APIException
*/
@Test
public void testOrderChannelHandler2() throws APIException {
final String jsonString = "[0,\"on\",[[6784335053,null,1514956504945000,\"tIOTUSD\",1514956505134,1514956505164,-24.175121,-24.175121,\"EXCHANGE STOP\",null,null,null,0,\"ACTIVE\",null,null,3.84,0,null,null,null,null,null,0,0,0], [67843353243,null,1514956234945000,\"tBTCUSD\",1514956505134,1514956505164,-24.175121,-24.175121,\"EXCHANGE STOP\",null,null,null,0,\"ACTIVE\",null,null,3.84,0,null,null,null,null,null,0,0,0]]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final OrderHandler orderHandler = new OrderHandler();
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
final OrderManager orderManager = bitfinexApiBroker.getOrderManager();
Assert.assertTrue(orderManager.getOrders().isEmpty());
orderHandler.handleChannelData(bitfinexApiBroker, jsonArray);
Assert.assertEquals(2, orderManager.getOrders().size());
orderManager.clear();
Assert.assertTrue(orderManager.getOrders().isEmpty());
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManagerTest method testOrderChannelHandler3.
/**
* Test the order channel handler - posclose order
* @throws APIException
*/
@Test
public void testOrderChannelHandler3() throws APIException {
final String jsonString = "[0,\"on\",[6827301913,null,null,\"tXRPUSD\",1515069803530,1515069803530,-60,-60,\"MARKET\",null,null,null,0,\"ACTIVE (note:POSCLOSE)\",null,null,0,3.2041,null,null,null,null,null,0,0,0]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final OrderHandler orderHandler = new OrderHandler();
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
final OrderManager orderManager = bitfinexApiBroker.getOrderManager();
Assert.assertTrue(orderManager.getOrders().isEmpty());
orderHandler.handleChannelData(bitfinexApiBroker, jsonArray);
Assert.assertEquals(1, orderManager.getOrders().size());
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManagerTest method testOrderChannelHandler1.
/**
* Test the order channel handler - single order
* @throws APIException
*/
@Test
public void testOrderChannelHandler1() throws APIException {
final String jsonString = "[0,\"on\",[6784335053,null,1514956504945000,\"tIOTUSD\",1514956505134,1514956505164,-24.175121,-24.175121,\"EXCHANGE STOP\",null,null,null,0,\"ACTIVE\",null,null,3.84,0,null,null,null,null,null,0,0,0]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final OrderHandler orderHandler = new OrderHandler();
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
final OrderManager orderManager = bitfinexApiBroker.getOrderManager();
Assert.assertTrue(orderManager.getOrders().isEmpty());
orderHandler.handleChannelData(bitfinexApiBroker, jsonArray);
Assert.assertEquals(1, orderManager.getOrders().size());
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler 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