{"id":18405684,"url":"https://github.com/bitfinexcom/bfx-api-node-plugin-managed-ob","last_synced_at":"2025-04-07T08:32:10.611Z","repository":{"id":47341601,"uuid":"146894420","full_name":"bitfinexcom/bfx-api-node-plugin-managed-ob","owner":"bitfinexcom","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-18T14:25:37.000Z","size":38,"stargazers_count":2,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-18T21:53:15.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-31T13:17:22.000Z","updated_at":"2022-02-18T14:25:40.000Z","dependencies_parsed_at":"2022-08-27T22:31:54.637Z","dependency_job_id":null,"html_url":"https://github.com/bitfinexcom/bfx-api-node-plugin-managed-ob","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-plugin-managed-ob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-plugin-managed-ob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-plugin-managed-ob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-plugin-managed-ob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/bfx-api-node-plugin-managed-ob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247620239,"owners_count":20968168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T03:03:37.864Z","updated_at":"2025-04-07T08:32:10.130Z","avatar_url":"https://github.com/bitfinexcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitfinex Managed OrderBook Plugin for the Node.JS API\n\n[![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-plugin-managed-ob.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-plugin-managed-ob)\n\nThis plugin maintains an internal `OrderBook` model and keeps it up to date with incoming ws2 data packets. On each update, a `data:managed:book` event is emitted on the socket, providing a complete `OrderBook` model instance (from `bfx-api-node-models`).\n\nNote that the manager proxies the event as `managed:book`. If subscribing on a socket instance (`wsState.ev.on(...)`) use the internal event name, otherwise use the manager name with `manager.onWS(...)`.\n\n### Features\n\n* Maintains up-to-date `OrderBook` models internally\n* Emits a new 'managed:book' event with a full `OrderBook` instance on each update\n\n### Installation\n\n```bash\nnpm i --save bfx-api-node-plugin-managed-ob\n```\n\n### Quickstart\n\n```js\nconst { Manager } = require('bfx-api-node-core')\nconst ManagedOBPlugin = require('bfx-api-node-plugin-managed-ob')\n\nconst mgr = new Manager({\n  plugins: [ManagedOBPlugin()]\n})\n\n// set up a connection, event listeners, etc\n\nmgr.onWS('managed:book', {}, (ob) =\u003e {\n  debug('checksum: %s', ob.checksum())\n})\n```\n\n### Docs\n\nFor an executable example, [see `examples/usage.js`](/examples/usage.js)\n\n### Example\n```js\nconst debug = require('debug')('bfx:api:plugins:managed-ob:example')\nconst { Manager, subscribe } = require('bfx-api-node-core')\nconst ManagedOBPlugin = require('../')\n\nconst SYMBOL = 'tBTCUSD'\nconst mgr = new Manager({\n  transform: true,\n  plugins: [ManagedOBPlugin()]\n})\n\nmgr.onWS('open', {}, () =\u003e debug('connection open'))\n\n// Receive updated ob\nmgr.onWS('managed:book', {}, (ob) =\u003e {\n  debug('--')\n  debug('recv ob update')\n  debug('spread %f, mid price %f', ob.spread(), ob.midPrice())\n  debug('best ask %f, total ask size %f', ob.topAsk(), ob.askAmount())\n  debug('best bid %f, total bid size %f', ob.topBid(), ob.bidAmount())\n  debug('checksum: %s', ob.checksum())\n})\n\nconst wsState = mgr.openWS()\n\nsubscribe(wsState, 'book', {\n  symbol: SYMBOL,\n  len: '25',\n  prec: 'P0',\n})\n```\n\n### Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-plugin-managed-ob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-plugin-managed-ob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-plugin-managed-ob/lists"}