use of com.github.jnidzwetzki.bitfinex.v2.callback.api.PositionHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class PositionTest method testPositionHandlerUpdate.
/**
* Test the position handler
* @throws APIException
*/
@Test
public void testPositionHandlerUpdate() throws APIException {
final String jsonString = "[0,\"pu\",[\"tETHUSD\",\"ACTIVE\",0.14,713.78,-0.00330012,0,null,null,null,null]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final PositionHandler positionHandler = new PositionHandler();
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
Assert.assertTrue(bitfinexApiBroker.getPositionManager().getPositions().isEmpty());
positionHandler.handleChannelData(bitfinexApiBroker, jsonArray);
Assert.assertEquals(1, bitfinexApiBroker.getPositionManager().getPositions().size());
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.PositionHandler in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class PositionTest method testPositionHandlerSnapshot.
/**
* Test the position handler
* @throws APIException
*/
@Test
public void testPositionHandlerSnapshot() throws APIException {
final String jsonString = "[0,\"ps\",[[\"tETHUSD\",\"ACTIVE\",0.14,713.78,-0.00330012,0,null,null,null,null], [\"tBTCUSD\",\"ACTIVE\",0.14,713.78,-0.00330012,0,null,null,null,null]]]";
final JSONArray jsonArray = new JSONArray(jsonString);
final PositionHandler positionHandler = new PositionHandler();
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
Assert.assertTrue(bitfinexApiBroker.getPositionManager().getPositions().isEmpty());
positionHandler.handleChannelData(bitfinexApiBroker, jsonArray);
Assert.assertEquals(2, bitfinexApiBroker.getPositionManager().getPositions().size());
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.api.PositionHandler 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