Skip to content

vorandrew/deribit-ws-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deribit-ws-nodejs

Deribit.com WebSocket NodeJS generic library

Install

yarn add deribit-ws-nodejs

Constructor

import Deribit from 'deribit-ws-nodejs'
const ws = new Deribit({
  key: 'deribit_key',
  secret: 'secret',
  testnet: false,
  message: msg => console.log(msg),
  error: err => console.error(err),

  // 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)

About

Deribit.com WebSocket NodeJS generic library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published