Search in sources :

Example 11 with Wallet

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

the class WalletManager method calculateWalletFundingBalance.

/**
 * Calculate the wallet funding balance for the given currency (e.g., BTC)
 *
 * @param symbol
 * @throws APIException
 */
public void calculateWalletFundingBalance(final String symbol) throws APIException {
    throwExceptionIfUnauthenticated();
    bitfinexApiBroker.sendCommand(new CalculateCommand("wallet_funding_" + symbol));
}
Also used : CalculateCommand(com.github.jnidzwetzki.bitfinex.v2.commands.CalculateCommand)

Example 12 with Wallet

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

the class WalletHandler method handleWalletcallback.

/**
 * Handle the callback for a single wallet
 * @param bitfinexApiBroker
 * @param walletArray
 * @throws APIException
 */
private void handleWalletcallback(final BitfinexApiBroker bitfinexApiBroker, final JSONArray walletArray) throws APIException {
    final String walletType = walletArray.getString(0);
    final String currency = walletArray.getString(1);
    final BigDecimal balance = walletArray.getBigDecimal(2);
    final BigDecimal unsettledInterest = walletArray.getBigDecimal(3);
    final BigDecimal balanceAvailable = walletArray.optBigDecimal(4, BigDecimal.valueOf(-1));
    final Wallet wallet = new Wallet(walletType, currency, balance, unsettledInterest, balanceAvailable);
    final WalletManager walletManager = bitfinexApiBroker.getWalletManager();
    final Table<String, String, Wallet> walletTable = walletManager.getWalletTable();
    synchronized (walletTable) {
        walletTable.put(walletType, currency, wallet);
        walletTable.notifyAll();
    }
}
Also used : WalletManager(com.github.jnidzwetzki.bitfinex.v2.manager.WalletManager) Wallet(com.github.jnidzwetzki.bitfinex.v2.entity.Wallet) BigDecimal(java.math.BigDecimal)

Example 13 with Wallet

use of com.github.jnidzwetzki.bitfinex.v2.entity.Wallet 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());
}
Also used : HeartbeatHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.HeartbeatHandler) PositionHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.PositionHandler) NotificationHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.NotificationHandler) DoNothingHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.DoNothingHandler) WalletHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.WalletHandler) TradeHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.TradeHandler) ExecutedTradeHandler(com.github.jnidzwetzki.bitfinex.v2.callback.channel.ExecutedTradeHandler) OrderHandler(com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler)

Aggregations

Wallet (com.github.jnidzwetzki.bitfinex.v2.entity.Wallet)9 BitfinexApiBroker (com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker)4 WalletManager (com.github.jnidzwetzki.bitfinex.v2.manager.WalletManager)4 WalletHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.WalletHandler)3 BitfinexCurrencyPair (com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexCurrencyPair)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 CalculateCommand (com.github.jnidzwetzki.bitfinex.v2.commands.CalculateCommand)2 APIException (com.github.jnidzwetzki.bitfinex.v2.entity.APIException)2 BitfinexTick (com.github.jnidzwetzki.bitfinex.v2.entity.BitfinexTick)2 BitfinexTickerSymbol (com.github.jnidzwetzki.bitfinex.v2.entity.symbol.BitfinexTickerSymbol)2 BasePortfolioManager (com.github.jnidzwetzki.cryptobot.portfolio.BasePortfolioManager)2 ArrayList (java.util.ArrayList)2 JSONArray (org.json.JSONArray)2 Test (org.junit.Test)2 DoNothingHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.DoNothingHandler)1 HeartbeatHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.HeartbeatHandler)1 NotificationHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.NotificationHandler)1 OrderHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.OrderHandler)1 PositionHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.PositionHandler)1 TradeHandler (com.github.jnidzwetzki.bitfinex.v2.callback.api.TradeHandler)1