Account events

You can subscribe to events that may occur on your exchange accounts. Event types include balance changes, withdrawal alerts, new internal transactions, and so on.

Account balance

Fetch Exchanger account balance

Rest API

/**
 * @param exchanger: string
 * @param market: string
 */
const accountBalance = await egRest.fetchWalletBalance(
    'binance',
    'btc-usdt'
);

/* Expected `accountBalance`:
{
    exchanger: string,
    market: string,
    balance: {
        btc: {
            locked: string,
            available: string
        },
        usdt: {
            locked: string,
            available: string
        }
    }
}*/

Socket RPC

/**
 * @param exchanger: string
 * @param market: string
 */
const accountBalance = await egRealtime.rpc.fetchWalletBalance(
    'binance',
    'btc-usdt'
);

/* Expected `accountBalance`:
{
    exchanger: string,
    market: string,
    balance: {
        btc: {
            locked: string,
            available: string
        },
        usdt: {
            locked: string,
            available: string
        }
    }
}*/

Stream

Subscribe my exchanger account balance changes

/**
 * @param exchanger: string
 * @param market: string
 */
const streamSubscription = egRealtime.stream.walletBalance(
    'binance',
    'btc-usdt'
);

(async () => {
    for await (const event of streamSubscription.consumer()) {
        console.log('event', event.name, event.data);
        /* Expected `event.data`:
        {
            btc: {
                locked: string,
                available: string
            },
            usdt: {
                locked: string,
                available: string
            }
        }*/
    }
})();