A JavaScript library for cryptocurrency trading using authenticated websocket connections.
- Provides data structure compatibility to CCXT.
- Typescript support
- Missing websocket features are executed via REST API using CCXT
WARNING THIS PROJECT IS IN AN EARLY STAGE, HAS NO TESTS AND GIVES YOU NO GUARANTEES ON ANYTHING!
Exchange | Orders | Account | Notes |
---|---|---|---|
Bitfinex | ✅ | ✅ | |
Binance | ✅ | ✅ | Order creation/cancellation via REST API |
Kraken | ✅ | ❌ | Order creation/cancellation via REST API |
Ftx | ✅ | ❌ | Order creation/cancellation via REST API |
yarn install ccxt-private-ws
Import the library:
import * as CcxtPrivateWs from 'ccxt-private-ws';
Create an exchange instance using your credentials:
const exchange = new CcxtPrivateWs['bitfinex']({ credentials: { apiKey: 'XXX', secret: 'YYY' } });
Subscribe the channels you are interested in and start the connection.
exchange.subscribeOrders({
callback: event => console.log(event.type, event.order)
});
exchange.connect();
await exchange.createOrder({
symbol: 'USDT/USD';
type: 'limit';
side: 'buy';
amount: 1;
price: 1.001;
})
await exchange.createOrder({
id: 'XXXX-XXXX-XXXX-XXXX';
})
Starts the connection to the exchange and does the authentication.
Stops the connection to the exchange.
Enable order update subscription. For each order update an order
event is emitted. Subscribe to the order
event using exchange.on('order, listener)
.
Enable balance update subscription. For each balance update a balance
event is emitted. Subscribe to the balance
event using exchange.on('balance, listener)
.
Creates an order.
Cancels an order.
Creates an exchange compliant order client id that can be used when calling createOrder
.
Returns the lowercase exchange name.
Emitted when an order update is received. The listener event contains the full order that has been aggregated over all subsequent updates.
Emitted when a balance update is received. The listener event might only contain the updated balances but will always contain current values for total
, used
and free
.
Emitted when a balance update is received. This always contains all account balances for the specific exchange. Some exchanges might only send balance
events.
Emitted when the websocket connection was established and the authentication succeeded.