Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitmex-orderbook

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitmex-orderbook - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "bitmex-orderbook",
"version": "1.0.0",
"version": "1.0.1",
"description": "BitMEX WebSocket-driven Orderbook",

@@ -5,0 +5,0 @@ "main": "src/OrderBook.js",

@@ -16,23 +16,20 @@ # BitMEX OrderBook

```js
const OrderBook = require("./src/OrderBook");
const OrderBook = require("bitmex-orderbook");
const main = async () => {
const orderBookL2 = await OrderBook.open("XBTH18", {
onUpdate(orderBookL2) {
// Top 10 ask prices.
const bestAskPrices = orderBookL2.getAskPrices(10);
// Top 5 bid prices, starting at third best (index: 2).
const [thirdBestBid] = orderBookL2.getBidprices(5, 2);
thirdBestBid.side; // "Buy"
thirdBestBid.price; // 17341.5
thirdBestBid.size; // 400
thirdBestBid.cumulative; // 57 + 372 + 400
thirdBestBid.timestamp; // Date()
},
});
};
OrderBook.open("XBTH18", {
onUpdate(orderBookL2) {
// Top 10 ask prices.
const bestAskPrices = orderBookL2.getAskPrices(10);
// Top 5 bid prices, starting at third best (index: 2).
const [thirdBestBid] = orderBookL2.getBidprices(5, 2);
thirdBestBid.side; // "Buy"
thirdBestBid.price; // 17341.5
thirdBestBid.size; // 400
thirdBestBid.cumulative; // 57 + 372 + 400
thirdBestBid.timestamp; // Date()
},
});
main();

@@ -45,21 +42,15 @@ ```

* `symbol: String` - The instrument symbol. Required.
* `symbol : String` - The instrument symbol. Required.
* `options.table : String` - The order book table to subscribe to. Default: `orderBookL2`, the fastest table on BitMEX.
* `options.depth : Integer` - Number of entries to remember for each side bid and ask. The worst prices are evicted. Default: `20`.
* `options.cumulative : Boolean` - Calculate cumulative sizes automatically at tiny processing cost. Default: `true`, it's very useful.
* `options.onUpdate : Function(OrderBook)` - A function that is invoked whenever the prices are updated.
* `options.socket : WebSocket` - An existing BitMEX WebSocket connection. If left empty a new WebSocket connection will be opened, and stored in `orderBook._client.socket`.
* `options.testmode : Boolean` - Connect to the BitMEX test environment. Only used if `options.socket` is empty. Default: `false`.
* `options.hearbeat : Integer` - Milliseconds between WebSocket connection pings. Default: `15000`.
* `options.endpoint : String` - Specifies the wss:// address for a new WebSocket connection. Only used if `options.socket` is empty. Default: `wss://www.bitmex.com/realtime`.
* `options.table: String` - The order book table to subscribe to. Default: `orderBookL2`, the fastest table on BitMEX.
Returns a Promise that resolves when the connection is opened.
* `options.depth: Integer` - Number of entries to remember for each side bid and ask. The worst prices are evicted. Default: `20`.
* `options.cumulative: Boolean` - Calculate cumulative sizes automatically (at tiny processing cost). Default: `true`, it's very useful.
* `options.socket: WebSocket` - An open BitMEX WebSocket connection. If left empty a new WebSocket connection will be opened, and stored in `orderBook._client.socket`.
* `options.onUpdate: Function(OrderBook)` - A function that is invoked whenever the prices are updated.
* `options.testmode` - Connect to the BitMEX test environment. Only used if `options.socket` is empty. Default: `false`.
* `options.hearbeat` - Milliseconds between WebSocket connection pings. Default: `15000`.
* `options.endpoint` - Specifies the wss:// address for a new WebSocket connection. Only used if `options.socket` is empty. Default: `wss://www.bitmex.com/realtime`.
### `OrderBook.getAskPrices(count, skip = 0) : OrderBookEntry`
### `orderBook.getAskPrices(count, skip = 0) : OrderBookEntry`

@@ -70,3 +61,3 @@ * `count: Integer` - Max number of prices to return. Sorted by best price first. Default: `options.depth`.

### `OrderBook.getBidPrices(count, skip = 0) : OrderBookEntry`
### `orderBook.getBidPrices(count, skip = 0) : OrderBookEntry`

@@ -73,0 +64,0 @@ Same as `getAskPrices`. Also sorted by best price first.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc