use of com.github.jnidzwetzki.bitfinex.v2.entity.Trade in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class QuoteManager method subscribeExecutedTrades.
/**
* Subscribe a executed trade channel
* @param currencyPair
* @param orderBookPrecision
* @param orderBookFrequency
* @param pricePoints
*/
public void subscribeExecutedTrades(final BitfinexExecutedTradeSymbol tradeSymbol) {
final SubscribeTradesCommand subscribeOrderbookCommand = new SubscribeTradesCommand(tradeSymbol);
bitfinexApiBroker.sendCommand(subscribeOrderbookCommand);
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.Trade in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class CandlestickHandler method handleChannelData.
/**
* Handle a candlestick callback
* @param channel
* @param subarray
*/
@Override
public void handleChannelData(final BitfinexApiBroker bitfinexApiBroker, final BitfinexStreamSymbol channelSymbol, final JSONArray jsonArray) throws APIException {
// channel symbol trade:1m:tLTCUSD
final List<BitfinexTick> ticksBuffer = new ArrayList<>();
// Snapshots contain multiple Bars, Updates only one
if (jsonArray.get(0) instanceof JSONArray) {
for (int pos = 0; pos < jsonArray.length(); pos++) {
final JSONArray parts = jsonArray.getJSONArray(pos);
parseCandlestick(ticksBuffer, parts);
}
} else {
parseCandlestick(ticksBuffer, jsonArray);
}
// Use natural ordering
ticksBuffer.sort(null);
final BitfinexCandlestickSymbol candlestickSymbol = (BitfinexCandlestickSymbol) channelSymbol;
bitfinexApiBroker.getQuoteManager().handleCandlestickList(candlestickSymbol, ticksBuffer);
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.Trade 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());
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.Trade in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class ExecutedTradeHandler method handleEntry.
/**
* Handle a new executed trade entry
* @param bitfinexApiBroker
* @param symbol
* @param jsonArray
*/
private void handleEntry(final BitfinexApiBroker bitfinexApiBroker, final BitfinexExecutedTradeSymbol symbol, final JSONArray jsonArray) {
final ExecutedTrade executedTrade = new ExecutedTrade();
final long id = jsonArray.getNumber(0).longValue();
executedTrade.setId(id);
final long timestamp = jsonArray.getNumber(1).longValue();
executedTrade.setTimestamp(timestamp);
final BigDecimal amount = jsonArray.getBigDecimal(2);
executedTrade.setAmount(amount);
// Funding or Currency
if (jsonArray.optNumber(4) != null) {
final BigDecimal rate = jsonArray.getBigDecimal(3);
executedTrade.setRate(rate);
final int period = jsonArray.getNumber(4).intValue();
executedTrade.setPeriod(period);
} else {
final BigDecimal price = jsonArray.getBigDecimal(3);
executedTrade.setPrice(price);
}
bitfinexApiBroker.getQuoteManager().handleExecutedTradeEntry(symbol, executedTrade);
}
Aggregations