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

deribit-rxjs

2.1.1 • Public • Published

deribit-rxjs

Deribit.com RxJS bindings

Install

yarn add deribit-rxjs

Setup

ENV vars

DERIBIT_KEY=key_here        // API Key
DERIBIT_SECRET=secret_here  // API Secret

Import

import { ohlc, quote, index, positions$, orders$, trades$, sec$, read$, deribit } from 'deribit-rxjs'

Deribit Websocket

See https://www.deribit.com/apiconsole/v2

Websocket messages observable

read$.subscribe(console.log)

Connected

deribit.connected
  .then(() => deribit.msg({'method': 'public/get_time'}))
  .then(timestamp => console.log(timestamp))

Authenticated

deribit.authenticated
  .then(() =>
    deribit.msg({
      method: 'private/get_positions',
      params: { currency: 'BTC' },
    }),
  )
  .then(positions => console.log(positions))

Send message

deribit
  .msg({'method': 'public/get_time'})
  .then(timestamp => console.log(timestamp))

Seconds (no drift)

sec$.subscribe(console.log) // 1545007679000

Index

index('btc').subscribe(console.log) // 3500

Quote

quote('BTC-PERPETUAL').subscribe(console.log) // One instrument
quote('future', 'ETH').subscribe(console.log) // By kind - ['all', 'future', 'option']

OHLC

const { s1$, s5$, s15$, m1$, m15$, m30$, h1$, h4$, d1$ } = ohlc('BTC-PERPETUAL')
s5$.subscribe(console.log) // { t: 1545007679000, o: 333, h: 555, l: 222, c: 4444, v: 12355 }

Order management

import { order, edit, cancel, stop } from 'deribit-rxjs'
 
order(opts).subscribe(console.log)
edit(opts).subscribe(console.log)
cancel(order_id).subscribe(console.log)
stop(opts).subscribe(console.log)

Trades

trades$.subscribe(console.log)

Positions

positions$.subscribe(console.log)

Orders

orders$.subscribe(console.log)

Keywords

none

Install

npm i deribit-rxjs

DownloadsWeekly Downloads

8

Version

2.1.1

License

MIT

Unpacked Size

21.3 kB

Total Files

17

Last publish

Collaborators

  • avatar