1.2.0 • Published 3 years ago

bitfinex-terminal-order-book v1.2.0

Weekly downloads
11
License
Apache-2.0
Repository
github
Last release
3 years ago

bitfinex-terminal-order-book

Bitfinex Orderbook Query API

npm install bitfinex-terminal-order-book

Usage

const buyer = dazaar.buy(card)

// make sure to follow the payment guide
buyer.on('feed', function (feed) {
  const o = new Orderbook(feed)
})

See https://github.com/bitfinexcom/bitfinex-terminal for more.

Orderbook API

const o = new Orderbook(feed, [pair])

Create a new orderbook. feed should be a Hypercore and pair is the string key identifying the order book pair. You only need to pass in pair if you plan to append to the feed.

When using Dazaar, you'd get the feed from the feed event.

buyer.on('feed', function (feed) {
  const o = new Orderbook(feed)
})

const book = await o.get(timestamp)

Will find the first orderbook snapshot >= than the timestamp.

const stream = o.createReadStream([options])

Make a stream of snapshots. Options include:

{
  gte: <timestamp> // find timestamps greater or equal to this
  le: <timestamp>, // find timestamps less than this
  limit: <number>, // how many to get at max?
  live: <bool> // keep the stream open?
}

The stream is also async iterable.

const { pair } = await o.info()

Get metadata about the orderbook. pair is the currency pair for it.

const book = await o.latest()

Get the latest entry added.