use of com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class IntegrationTest method testReconnect.
/**
* Test the session reconnect
* @throws APIException
* @throws InterruptedException
*/
@Test
public void testReconnect() throws APIException, InterruptedException {
final BitfinexApiBroker bitfinexClient = new BitfinexApiBroker();
bitfinexClient.connect();
final BitfinexTickerSymbol symbol = new BitfinexTickerSymbol(BitfinexCurrencyPair.BTC_USD);
final QuoteManager orderbookManager = bitfinexClient.getQuoteManager();
orderbookManager.subscribeTicker(symbol);
Thread.sleep(1000);
bitfinexClient.reconnect();
// Await at least 2 callbacks
final CountDownLatch latch = new CountDownLatch(2);
final BiConsumer<BitfinexTickerSymbol, BitfinexTick> callback = (c, o) -> {
latch.countDown();
};
orderbookManager.registerTickCallback(symbol, callback);
latch.await();
Assert.assertTrue(bitfinexClient.isTickerActive(symbol));
orderbookManager.unsubscribeTicker(symbol);
Assert.assertFalse(bitfinexClient.isTickerActive(symbol));
bitfinexClient.close();
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexTickTest method testCompareTo.
@Test
public void testCompareTo() {
final BitfinexTick tick1 = new BitfinexTick(210, 11d, 16d, 18d, 10d, 100d);
final BitfinexTick tick2 = new BitfinexTick(213, 12d, 15d, 18d, 12d, 100d);
Assert.assertTrue(tick1.compareTo(tick2) < 0);
Assert.assertTrue(tick2.compareTo(tick1) > 0);
Assert.assertTrue(tick1.compareTo(tick1) == 0);
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexTickTest method testToString.
@Test
public void testToString() {
final BitfinexTick tick1 = new BitfinexTick(213, 12d, 15d, 18d, 12d, 100d);
Assert.assertTrue(tick1.toString().length() > 10);
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexTickTest method testEquals.
@Test
public void testEquals() {
final BitfinexTick tick1 = new BitfinexTick(210, new BigDecimal(11), new BigDecimal(16), new BigDecimal(18), new BigDecimal(10), new BigDecimal(45));
final BitfinexTick tick2 = new BitfinexTick(213, new BigDecimal(12), new BigDecimal(15), new BigDecimal(18), new BigDecimal(10));
final BitfinexTick tick3 = new BitfinexTick(213, new BigDecimal(12), new BigDecimal(15), new BigDecimal(18), new BigDecimal(10));
Assert.assertEquals(tick2, tick3);
Assert.assertEquals(tick2.hashCode(), tick3.hashCode());
Assert.assertEquals(tick3.hashCode(), tick3.hashCode());
Assert.assertFalse(tick1.equals(tick2));
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexTickTest method testGetter.
@Test
public void testGetter() {
final BitfinexTick tick1 = new BitfinexTick(210, 11, 16, 18, 10, 45);
final BitfinexTick tick2 = new BitfinexTick(210, new BigDecimal(11), new BigDecimal(16), new BigDecimal(18), new BigDecimal(10));
Assert.assertEquals(210, tick1.getTimestamp());
Assert.assertEquals(11, tick1.getOpen().doubleValue(), DELTA);
Assert.assertEquals(16, tick1.getClose().doubleValue(), DELTA);
Assert.assertEquals(18, tick1.getHigh().doubleValue(), DELTA);
Assert.assertEquals(10, tick1.getLow().doubleValue(), DELTA);
Assert.assertEquals(45, tick1.getVolume().doubleValue(), DELTA);
Assert.assertEquals(BitfinexTick.INVALID_VOLUME, tick2.getVolume());
}
Aggregations