use of com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class RawOrderbookHandler method handleChannelData.
@Override
public void handleChannelData(final BitfinexApiBroker bitfinexApiBroker, final BitfinexStreamSymbol channelSymbol, final JSONArray jsonArray) throws APIException {
final RawOrderbookConfiguration configuration = (RawOrderbookConfiguration) channelSymbol;
// Example: [13182,1,-0.1]
try {
// Snapshots contain multiple Orderbook entries, updates only one
if (jsonArray.get(0) instanceof JSONArray) {
for (int pos = 0; pos < jsonArray.length(); pos++) {
final JSONArray parts = jsonArray.getJSONArray(pos);
handleEntry(bitfinexApiBroker, configuration, parts);
}
} else {
handleEntry(bitfinexApiBroker, configuration, jsonArray);
}
} catch (JSONException e) {
throw new APIException(e);
}
}
use of com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class TickHandler method handleChannelData.
/**
* Handle a tick callback
* @param channel
* @param subarray
*/
@Override
public void handleChannelData(final BitfinexApiBroker bitfinexApiBroker, final BitfinexStreamSymbol channelSymbol, final JSONArray jsonArray) throws APIException {
final BitfinexTickerSymbol currencyPair = (BitfinexTickerSymbol) channelSymbol;
// 0 = BID
// 2 = ASK
// 6 = Price
final BigDecimal price = jsonArray.getBigDecimal(6);
// Volume is set to 0, because the ticker contains only the daily volume
final BitfinexTick tick = new BitfinexTick(System.currentTimeMillis(), price, price, price, price);
bitfinexApiBroker.getQuoteManager().handleNewTick(currencyPair, tick);
}
use of com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class SubscribedCallback method handleCandlesCallback.
/**
* Handle the candles callback
*
* @param bitfinexApiBroker
* @param jsonObject
* @param channelId
*/
private void handleCandlesCallback(final BitfinexApiBroker bitfinexApiBroker, final JSONObject jsonObject, final int channelId) {
final String key = jsonObject.getString("key");
logger.info("Registering key {} on channel {}", key, channelId);
final BitfinexCandlestickSymbol candleStickSymbol = BitfinexCandlestickSymbol.fromBitfinexString(key);
bitfinexApiBroker.addToChannelSymbolMap(channelId, candleStickSymbol);
}
use of com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class SubscribedCallback method handleTradesCallback.
/**
* Handle the trades callback
*
* @param bitfinexApiBroker
* @param jsonObject
* @param channelId
*/
private void handleTradesCallback(final BitfinexApiBroker bitfinexApiBroker, final JSONObject jsonObject, final int channelId) {
final String symbol2 = jsonObject.getString("symbol");
final BitfinexExecutedTradeSymbol currencyPair = BitfinexExecutedTradeSymbol.fromBitfinexString(symbol2);
logger.info("Registering symbol {} on channel {}", currencyPair, channelId);
bitfinexApiBroker.addToChannelSymbolMap(channelId, currencyPair);
}
use of com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class SubscribedCallback method handleTickerCallback.
/**
* Handle the ticker callback
*
* @param bitfinexApiBroker
* @param jsonObject
* @param channelId
*/
private void handleTickerCallback(final BitfinexApiBroker bitfinexApiBroker, final JSONObject jsonObject, final int channelId) {
final String symbol = jsonObject.getString("symbol");
final BitfinexTickerSymbol tickerSymbol = BitfinexTickerSymbol.fromBitfinexString(symbol);
logger.info("Registering symbol {} on channel {}", tickerSymbol, channelId);
bitfinexApiBroker.addToChannelSymbolMap(channelId, tickerSymbol);
}
Aggregations