# bfx-api-node-plugin-ob-checksum

> Automatic order book checksum verification plugin for the Bitfinex Node API

Latest version **1.0.2** (published 2019-10-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install bfx-api-node-plugin-ob-checksum
pnpm add bfx-api-node-plugin-ob-checksum
yarn add bfx-api-node-plugin-ob-checksum
bun add bfx-api-node-plugin-ob-checksum
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-10-10 |
| First published | 2018-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7 |
| Dependencies | 5 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Bitfinex |
| Maintainers | jacob_plaster |
| Keywords | bitfinex, bitcoin, BTC |

## Links

- npm: https://www.npmjs.com/package/bfx-api-node-plugin-ob-checksum
- Repository: https://github.com/bitfinexcom/bfx-api-node-plugin-ob-checksum
- Homepage: https://github.com/bitfinexcom/bfx-api-node-plugin-ob-checksum#readme
- Issues: https://github.com/bitfinexcom/bfx-api-node-plugin-ob-checksum/issues
- npm.io page: https://npm.io/package/bfx-api-node-plugin-ob-checksum

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.5
- [bfx-api-node-core](https://npm.io/package/bfx-api-node-core.md) ^1.1.0
- [bfx-api-node-models](https://npm.io/package/bfx-api-node-models.md) ^1.0.12

## Recent versions

- 1.0.2 (latest) — 2019-10-10
- 1.0.1 — 2019-09-26
- 1.0.0 — 2018-10-17

## README

# Bitfinex Managed Order Book Checksum Plugin for the Node.JS API

[![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-plugin-ob-cs.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-plugin-ob-cs)

This plugin enables the order book checksum flag upon connecting, and maintains internal `OrderBook` model instances for all subscribed book channels. Upon receiving a checksum from the server, the relevant internal model is audited and an `error` event is emitted on checksum miss-match. Valid checksums are reported in debug output.

Note that the manager proxies the event as `ws2:error`. If subscribing on a socket instance (`wsState.ev.on(...)`) use the internal event name, otherwise use the manager name with `manager.onWS(...)`.

### Features

* Maintains up-to-date internal `OrderBook` model instances
* Verfies managed `OrderBook` checksums with each incoming remote checksum packet
* Emits a `ws2:error` event on checksum miss-match

### Installation

```bash
npm i --save bfx-api-node-plugin-ob-checksum
```

### Docs

For an executable example, [see `examples/usage.js`](/examples/usage.js)

### Quickstart & Example

```js
const debug = require('debug')('bfx:api:plugins:managed-ob-cs:example')
const { Manager, subscribe } = require('bfx-api-node-core')
const ManagedOBChecksumPlugin = require('../')

const SYMBOL = 'tBTCUSD'
const mgr = new Manager({
  transform: true,
  plugins: [ManagedOBChecksumPlugin()]
})

mgr.onWS('open', {}, () => debug('connection open'))

// Catch checksum errors
mgr.onWS('ws2:error', {}, (err) => {
  if (err.message.match(/ob checksum/)) {
    debug('recv ob checksum error: %s', err.message)
  }
})

const wsState = mgr.openWS()

subscribe(wsState, 'book', {
  symbol: SYMBOL,
  len: '25',
  prec: 'P0'
})
```

### Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

---
_Source: https://npm.io/package/bfx-api-node-plugin-ob-checksum · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
