Search in sources :

Example 11 with BitfinexExecutedTradeSymbol

use of com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexExecutedTradeSymbol in project bitfinex-v2-wss-api-java by jnidzwetzki.

the class ExecutedTradeHandler method handleChannelData.

@Override
public void handleChannelData(final BitfinexApiBroker bitfinexApiBroker, final BitfinexStreamSymbol channelSymbol, final JSONArray jsonArray) throws APIException {
    final BitfinexExecutedTradeSymbol configuration = (BitfinexExecutedTradeSymbol) channelSymbol;
    try {
        // Snapshots contain multiple executes 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);
    }
}
Also used : BitfinexExecutedTradeSymbol(com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexExecutedTradeSymbol) APIException(com.github.jnidzwetzki.bitfinex.v2.entity.APIException) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Aggregations

BitfinexExecutedTradeSymbol (com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexExecutedTradeSymbol)8 BitfinexApiBroker (com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker)4 OrderbookConfiguration (com.github.jnidzwetzki.bitfinex.v2.entity.OrderbookConfiguration)4 RawOrderbookConfiguration (com.github.jnidzwetzki.bitfinex.v2.entity.RawOrderbookConfiguration)4 BitfinexCandlestickSymbol (com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexCandlestickSymbol)4 BitfinexTickerSymbol (com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexTickerSymbol)4 JSONArray (org.json.JSONArray)4 Test (org.junit.Test)4 ExecutedTradeHandler (com.github.jnidzwetzki.bitfinex.v2.callback.channel.ExecutedTradeHandler)3 SubscribeTradesCommand (com.github.jnidzwetzki.bitfinex.v2.commands.SubscribeTradesCommand)3 QuoteManager (com.github.jnidzwetzki.bitfinex.v2.manager.QuoteManager)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 SubscribeCandlesCommand (com.github.jnidzwetzki.bitfinex.v2.commands.SubscribeCandlesCommand)2 SubscribeOrderbookCommand (com.github.jnidzwetzki.bitfinex.v2.commands.SubscribeOrderbookCommand)2 SubscribeRawOrderbookCommand (com.github.jnidzwetzki.bitfinex.v2.commands.SubscribeRawOrderbookCommand)2 SubscribeTickerCommand (com.github.jnidzwetzki.bitfinex.v2.commands.SubscribeTickerCommand)2 UnsubscribeChannelCommand (com.github.jnidzwetzki.bitfinex.v2.commands.UnsubscribeChannelCommand)2 APIException (com.github.jnidzwetzki.bitfinex.v2.entity.APIException)2 ExecutedTrade (com.github.jnidzwetzki.bitfinex.v2.entity.ExecutedTrade)2 ExecutorService (java.util.concurrent.ExecutorService)2