https://github.com/bitfinexcom/bitfinex-terminal-order-book
https://github.com/bitfinexcom/bitfinex-terminal-order-book
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bitfinexcom/bitfinex-terminal-order-book
- Owner: bitfinexcom
- License: apache-2.0
- Created: 2020-12-17T19:33:10.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-21T10:04:41.000Z (about 5 years ago)
- Last Synced: 2024-04-26T01:20:17.579Z (about 2 years ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bitfinex-terminal-order-book
Bitfinex Orderbook Query API
```
npm install bitfinex-terminal-order-book
```
## Usage
```js
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.
```js
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:
```js
{
gte: // find timestamps greater or equal to this
le: , // find timestamps less than this
limit: , // how many to get at max?
live: // 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.