Miss any of our Open RFC calls?Watch the recordings here! »

deribit-ws-js

3.1.0 • Public • Published

deribit-ws-js

Deribit.com WebSocket browser generic library

Install

yarn add deribit-ws-js

Constructor

import Deribit from 'deribit-ws-js'
const ws = new Deribit({
  key: 'deribit_key',
  secret: 'secret',
  testnet: false,
  message: msg => console.log(msg),
 
  // see documentation for possible events
  trade: trade => console.log(msg),
 
})

Wait for connection

await ws.connected
// or ws.connected.then(() => console.log('Ready') )

Disconnect when done

ws.disconnect()

Actions

    ws.action('positions').then(console.log)
  ws.action('buy', {
    instrument: 'BTC-28DEC18-15000-C',
    quantity: 1,
    type: 'market',
    label: '1123123',
  }).then(console.log)

Event hooks

Filters and events (see https://www.deribit.com/main#/pages/docs/api -> WebSocket API -> Subscribe)

let filters = ['all', 'futures', 'options', 'index', 'any_instrument_name']
let events = ['order_book', 'trade', 'user_order', 'my_trade']

Hooks

ws.hook('my_trade', trade => console.log(trade))

With filter

ws.hook('order_book', 'BTC-28SEP18', cb)

Array as filter

ws.hook('trade', ['BTC-28SEP18','BTC-28DEC18'], cb)

Keywords

none

Install

npm i deribit-ws-js

DownloadsWeekly Downloads

10

Version

3.1.0

License

MIT

Unpacked Size

14.3 kB

Total Files

4

Last publish

Collaborators

  • avatar