use of com.github.jnidzwetzki.bitfinex.v2.commands.AuthCommand in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexApiBroker method executeAuthentification.
/**
* Execute the authentication and wait until the socket is ready
* @throws InterruptedException
* @throws APIException
*/
private void executeAuthentification() throws InterruptedException, APIException {
connectionReadyLatch = new CountDownLatch(CONNECTION_READY_EVENTS);
if (isAuthenticatedConnection()) {
sendCommand(new AuthCommand());
logger.info("Waiting for connection ready events");
connectionReadyLatch.await(10, TimeUnit.SECONDS);
if (!authenticated) {
throw new APIException("Unable to perform authentification, capabilities are: " + capabilities);
}
}
}
use of com.github.jnidzwetzki.bitfinex.v2.commands.AuthCommand in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class CommandsTest method testCommandsJSON.
/**
* Call all commands and check for excepion
* @throws CommandException
*/
@Test
public void testCommandsJSON() throws CommandException {
final BitfinexOrder order = BitfinexOrderBuilder.create(BitfinexCurrencyPair.BCH_USD, BitfinexOrderType.EXCHANGE_STOP, 2).build();
final BitfinexCandlestickSymbol candleSymbol = new BitfinexCandlestickSymbol(BitfinexCurrencyPair.BCH_USD, Timeframe.HOUR_1);
final OrderbookConfiguration orderbookConfiguration = new OrderbookConfiguration(BitfinexCurrencyPair.BCH_USD, OrderBookPrecision.P0, OrderBookFrequency.F0, 50);
final RawOrderbookConfiguration rawOrderbookConfiguration = new RawOrderbookConfiguration(BitfinexCurrencyPair.BAT_BTC);
final List<AbstractAPICommand> commands = Arrays.asList(new AuthCommand(), new CancelOrderCommand(123), new CancelOrderGroupCommand(1), new OrderCommand(order), new PingCommand(), new SubscribeCandlesCommand(candleSymbol), new SubscribeTickerCommand(new BitfinexTickerSymbol(BitfinexCurrencyPair.BCH_USD)), new SubscribeTradesCommand(new BitfinexExecutedTradeSymbol(BitfinexCurrencyPair.BAT_BTC)), new SubscribeOrderbookCommand(orderbookConfiguration), new SubscribeRawOrderbookCommand(rawOrderbookConfiguration), new UnsubscribeChannelCommand(12));
final BitfinexApiBroker bitfinexApiBroker = buildMockedBitfinexConnection();
for (final AbstractAPICommand command : commands) {
final String commandValue = command.getCommand(bitfinexApiBroker);
Assert.assertNotNull(commandValue);
Assert.assertTrue(commandValue.length() > 10);
}
}
Aggregations