diff --git a/.babelrc b/.babelrc index 10266dd..6a13c6a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,9 +1,13 @@ { "presets": [ - "env" + ["@babel/preset-env", { + "targets": { + "node": "8.3.0" + } + }] ], "plugins": [ - "transform-regenerator", - "transform-object-rest-spread" + "@babel/plugin-transform-regenerator", + "@babel/plugin-proposal-object-rest-spread" ] } diff --git a/.eslintrc.json b/.eslintrc.json index 307b7e5..71c4cbc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,6 @@ { + "root": true, + "plugins": [ "jsdoc", "mocha" diff --git a/.jsdoc.json b/.jsdoc.json index 54320f4..df0c300 100644 --- a/.jsdoc.json +++ b/.jsdoc.json @@ -4,7 +4,7 @@ "dictionaries": ["jsdoc"] }, "source": { - "include": ["lib", "DOCUMENTATION.md"], + "include": ["index.js", "lib", "DOCUMENTATION.md"], "includePattern": ".js$", "excludePattern": "(node_modules/|docs)" }, @@ -24,7 +24,6 @@ "recurse": true, "template": "./node_modules/docdash" }, - "package": "", "docdash": { "static": true, "sort": true, diff --git a/CHANGELOG b/CHANGELOG index c689dcc..7736bef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +# 1.2.10 +- meta: bump deps +- meta: normalize eslint config +- refactor: improve doclets + # 1.2.9 - feature: add Invoice model diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md deleted file mode 100644 index 564d374..0000000 --- a/DOCUMENTATION.md +++ /dev/null @@ -1,142 +0,0 @@ -# Bitfinex Data Models for Node.JS - -This repo contains model classes for working with the data structures returned -by the Bitfinex REST & WebSocket APIs. The models can all be initialized with -an array-format payload as returned by an API call, and can be unserialized -back to the array format when needed. - -Some models, such as {@link Order} and {@link OrderBook} provide higher level -methods which operate on the underlying data sets. - -All models provide `serialize()` and `unserialize()` methods, which convert -to/from array-format payloads respectively. All model constructors can take -either array-format payloads, or objects/other model instances. A helper -`toJS()` method is also provided for converting models to plain JS objects -(POJOs). - -### Features - -* Convert between array, object, and class representations of API data -* Class methods for operating on model data where applicable (i.e. `OrderBook`) - -Classes for the following Bitfinex API data types: -* {@link Alert} -* {@link BalanceInfo} -* {@link Candle} -* {@link Currency} -* {@link FundingCredit} -* {@link FundingInfo} -* {@link FundingLoan} -* {@link FundingOffer} -* {@link FundingTickerHist} -* {@link FundingTicker} -* {@link FundingTrade} -* {@link LedgerEntry} -* {@link Liquidations} -* {@link MarginInfo} -* {@link Movement} -* {@link Notification} -* {@link OrderBook} -* {@link Order} -* {@link Position} -* {@link PublicTrade} -* {@link StatusMessagesDeriv} -* {@link Trade} -* {@link TradingTicker} -* {@link TradingTickerHist} -* {@link UserInfo} -* {@link Wallet} -* {@link WalletHist} -* {@link Currency} - -### Installation - -```js -npm i --save bfx-api-node-models -``` - -### Quickstart - -```js -const { Order } = require('bfx-api-node-models') - -const o = new Order({ - cid: Date.now(), - symbol: 'tBTCUSD', - price: 7000.0, - amount: -0.02, - type: Order.type.EXCHANGE_LIMIT -}) - -// Generate an API-compatible order creation packet for later submit -console.log(o.toNewOrderPacket()) -``` - -### Examples - -The order model provides helper methods for order submission, updates, and cancellation. These methods are compatible with version 2.0.0 of `bitfinex-api-node`, and return promises which resolve upon receival of the relevant success/error notifications. - -Orders are matched with their API packets by one/all of `id`, `gid`, and `cid`. - -Example usage: -```js -const { Order } = require('bfx-api-node-models') -const ws = ... // setup WSv2 instance for order updates/submission - -// Build new order -const o = new Order({ - cid: Date.now(), - symbol: 'tBTCUSD', - price: 7000.0, - amount: -0.02, - type: Order.type.EXCHANGE_LIMIT -}, ws) // note WSv2 client passed in here - -let closed = false - -// Enable automatic updates -o.registerListeners() - -o.on('update', () => { - debug('order updated: %j', o.serialize()) -}) - -o.on('close', () => { - debug('order closed: %s', o.status) - closed = true -}) - -debug('submitting order %d', o.cid) - -o.submit().then(() => { - debug('got submit confirmation for order %d [%d]', o.cid, o.id) -}).catch((err) => { - debug('failed to submit order: %s', err.message) -}) -``` - -The order book model constructor takes either entire book snapshots as returned by the WSv2 API, or individual update packets with single bids/asks. Once constructed, order books may be updated either with complete snapshots via `updateFromSnapshot(snapshot)` or individual update packets via `updateWidth(entry)`. - -Static helpers are also provided for working with array-format order books, in the form of `updateArrayOBWith(ob, entry, raw)`, `arrayOBMidPrice(ob, raw)`, and `checksumArr(ob, raw)`. - -Checksums may be calculated for normal books via `checksum()`, for comparison with the checksums reported by the WSv2 API. - -Example usage: -```js -const ob = new OrderBook([ - [140, 1, 10], - [145, 1, 10], - [148, 1, 10], - [149, 1, 10], - [151, 1, -10], - [152, 1, -10], - [158, 1, -10], - [160, 1, -10] -]) - -ob.updateWith([145, 3, 15]) // update bid -ob.updateWith([158, 3, -15]) // update ask - -console.log(ob.serialize()) -``` - diff --git a/README.md b/README.md index e20a2c6..894f1d0 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,19 @@ [![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-models.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-models) -This repo contains model classes for working with the data structures returned by the Bitfinex REST & WebSocket APIs. The models can all be initialized with an array-format payload as returned by an API call, and can be unserialized back to the array format when needed. +This repo contains model classes for working with the data structures returned +by the Bitfinex REST & WebSocket APIs. The models can all be initialized with +an array-format payload as returned by an API call, and can be unserialized +back to the array format when needed. -Some models, such as `Order` and `OrderBook` provide higher level methods which operate on the underlying data sets. +Some models, such as `Order` and `OrderBook` provide higher level methods which +operate on the underlying data sets. -All models provide `serialize()` and `unserialize()` methods, which convert to/from array-format payloads respectively. All model constructors can take either array-format payloads, or objects/other model instances. A helper `toJS()` method is also provided for converting models to plain JS objects (POJOs). +All models provide `serialize()` and `unserialize()` methods, which convert +to/from array-format payloads respectively. All model constructors can take +either array-format payloads, or objects/other model instances. A helper +`toJS()` method is also provided for converting models to plain JS objects +(POJOs). ### Features @@ -68,12 +76,15 @@ console.log(o.toNewOrderPacket()) ### Docs -Refer to the [docs/](https://cdn.statically.io/gh/bitfinexcom/bfx-api-node-models/master/docs/index.html) -folder for JSDoc-generated API documentation covering each model class. +Refer to [docs/reference.md](docs/reference.md) for JSDoc-generated API +documentation. ### Examples -The order model provides helper methods for order submission, updates, and cancellation. These methods are compatible with version 2.0.0 of `bitfinex-api-node`, and return promises which resolve upon receival of the relevant success/error notifications. +The order model provides helper methods for order submission, updates, and +cancellation. These methods are compatible with version 2.0.0 of +`bitfinex-api-node`, and return promises which resolve upon receival of the +relevant success/error notifications. Orders are matched with their API packets by one/all of `id`, `gid`, and `cid`. @@ -114,13 +125,21 @@ o.submit().then(() => { }) ``` -The order book model constructor takes either entire book snapshots as returned by the WSv2 API, or individual update packets with single bids/asks. Once constructed, order books may be updated either with complete snapshots via `updateFromSnapshot(snapshot)` or individual update packets via `updateWidth(entry)`. +The order book model constructor takes either entire book snapshots as returned +by the WSv2 API, or individual update packets with single bids/asks. Once +constructed, order books may be updated either with complete snapshots via +`updateFromSnapshot(snapshot)` or individual update packets via +`updateWidth(entry)`. -Static helpers are also provided for working with array-format order books, in the form of `updateArrayOBWith(ob, entry, raw)`, `arrayOBMidPrice(ob, raw)`, and `checksumArr(ob, raw)`. +Static helpers are also provided for working with array-format order books, in +the form of `updateArrayOBWith(ob, entry, raw)`, `arrayOBMidPrice(ob, raw)`, +and `checksumArr(ob, raw)`. -Checksums may be calculated for normal books via `checksum()`, for comparison with the checksums reported by the WSv2 API. +Checksums may be calculated for normal books via `checksum()`, for comparison +with the checksums reported by the WSv2 API. Example usage: + ```js const ob = new OrderBook([ [140, 1, 10], diff --git a/docs/.keep b/docs/.keep new file mode 100644 index 0000000..e69de29 diff --git a/docs/fonts/Montserrat/Montserrat-Bold.eot b/docs/fonts/Montserrat/Montserrat-Bold.eot deleted file mode 100644 index f2970bb..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Bold.eot and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Bold.ttf b/docs/fonts/Montserrat/Montserrat-Bold.ttf deleted file mode 100644 index 3bfd79b..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Bold.ttf and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Bold.woff b/docs/fonts/Montserrat/Montserrat-Bold.woff deleted file mode 100644 index 9260765..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Bold.woff and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Bold.woff2 b/docs/fonts/Montserrat/Montserrat-Bold.woff2 deleted file mode 100644 index d9940cd..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Bold.woff2 and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Regular.eot b/docs/fonts/Montserrat/Montserrat-Regular.eot deleted file mode 100644 index 735d12b..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Regular.eot and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Regular.ttf b/docs/fonts/Montserrat/Montserrat-Regular.ttf deleted file mode 100644 index 5da852a..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Regular.ttf and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Regular.woff b/docs/fonts/Montserrat/Montserrat-Regular.woff deleted file mode 100644 index bf91832..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Regular.woff and /dev/null differ diff --git a/docs/fonts/Montserrat/Montserrat-Regular.woff2 b/docs/fonts/Montserrat/Montserrat-Regular.woff2 deleted file mode 100644 index 72d13c6..0000000 Binary files a/docs/fonts/Montserrat/Montserrat-Regular.woff2 and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot b/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot deleted file mode 100644 index 0f24510..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg b/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg deleted file mode 100644 index 5384f98..0000000 --- a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +++ /dev/null @@ -1,978 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf b/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf deleted file mode 100644 index e6c158c..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff b/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff deleted file mode 100644 index d0a1c29..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 b/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 deleted file mode 100644 index d286974..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot b/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot deleted file mode 100644 index b420448..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg b/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg deleted file mode 100644 index dee0949..0000000 --- a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +++ /dev/null @@ -1,1049 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf b/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf deleted file mode 100644 index 4d56c33..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff b/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff deleted file mode 100644 index 4681019..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff and /dev/null differ diff --git a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 b/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 deleted file mode 100644 index 8ddcae3..0000000 Binary files a/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 and /dev/null differ diff --git a/docs/reference.md b/docs/reference.md new file mode 100644 index 0000000..8cb9563 --- /dev/null +++ b/docs/reference.md @@ -0,0 +1,4625 @@ +## Modules + +
+
bfx-api-node-models
+

This module contains model classes for working with the data structures +returned by the Bitfinex REST & +WebSocket APIs. The models can all be +initialized with an array-format payload as returned by an API call, and can +be unserialized back to the array format when needed.

+

Some models, such as Order and OrderBook provide higher +level methods which operate on the underlying data sets.

+

All models provide serialize() and unserialize() methods, which convert +to/from array-format payloads respectively. All model constructors can take +either array-format payloads, or objects/other model instances. A helper +toJS() method is also provided for converting models to plain JS objects +(POJOs).

+
+
+ +## Classes + +
+
AlertModel
+

Price alert model

+
+
BalanceInfoModel
+

Balance information model

+
+
CandleModel
+

OHLCV Candle model

+
+
ChangeLogModel
+

Change log model

+
+
CurrencyModel
+

Currency model

+
+
FundingCreditModel
+

Funding Credit model

+
+
FundingInfoModel
+

Account Funding Info model

+
+
FundingLoanModel
+

Funding Loan model

+
+
FundingOfferModel
+

Funding Offer model

+
+
FundingTickerHistModel
+

Historical Funding Ticker model

+
+
FundingTickerModel
+

Funding Ticker model

+
+
FundingTradeModel
+

Funding Trade model

+
+
Invoice
+

Deposit Invoice model

+
+
LedgerEntryModel
+

Ledger Entry model; wallet field is automatically populated if a description +is provided.

+
+
LiquidationsModel
+

Liquidation Info model

+
+
LoginModel
+

Login event model

+
+
MarginInfoModel
+

Margin Info model

+
+
Modelevents.EventEmitter
+

Base model class, providing format-conversion methods

+
+
MovementModel
+

Currency Movement model

+
+
NotificationModel
+

Notification model. Broadcast notification body schema may be found at +BroadcastPayload.

+
+
OrderBookevents.EventEmitter
+

High level OB model to automatically integrate WS updates & maintain sort

+
+
OrderModel
+

High level order model; provides methods for execution & can stay updated via +a WSv2 connection or used to execute as a rest payload

+
+
PositionModel
+

Position model

+
+
PublicPulseProfileModel
+

Public PulseProfile model

+
+
PublicTradeModel
+

Public Trade model, supporting both funding & ordinary trades

+
+
PulseMessageModel
+

Private PulseMessage model

+
+
StatusMessagesDerivModel
+

Derivatives Status Message model

+
+
TradeModel
+

Private Trade model

+
+
TradingTickerHistModel
+

Historical Trading Ticker model

+
+
TradingTickerModel
+

Trading Ticker model

+
+
UserInfoModel
+

User Info model

+
+
WalletHistModel
+

Historical Wallet Update model

+
+
WalletModel
+

Wallet model

+
+
+ +## Functions + +
+
isCollection(data)boolean
+

Checks if the provided data is a collection of models

+
+
+ + + +## bfx-api-node-models +This module contains model classes for working with the data structures +returned by the Bitfinex [REST](https://github.com/bitfinexcom/bfx-api-node-rest) & +[WebSocket](https://github.com/bitfinexcom/bitfinex-api-node) APIs. The models can all be +initialized with an array-format payload as returned by an API call, and can +be unserialized back to the array format when needed. + +Some models, such as [Order](#Order) and [OrderBook](#OrderBook) provide higher +level methods which operate on the underlying data sets. + +All models provide `serialize()` and `unserialize()` methods, which convert +to/from array-format payloads respectively. All model constructors can take +either array-format payloads, or objects/other model instances. A helper +`toJS()` method is also provided for converting models to plain JS objects +(POJOs). + +**License**: MIT + + +## Alert ⇐ [Model](#Model) +Price alert model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Alert](#Alert) ⇐ [Model](#Model) + * [new Alert(data)](#new_Alert_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Alert.unserialize) ⇒ [ObjectData](#Alert..ObjectData) + * [.validate(data)](#Alert.validate) ⇒ string + * _inner_ + * [~ArrayData](#Alert..ArrayData) : Array + * [~Data](#Alert..Data) : [Alert](#Alert) \| [ObjectData](#Alert..ObjectData) \| [ArrayData](#Alert..ArrayData) + * [~ObjectData](#Alert..ObjectData) : object + + + +### new Alert(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Alert..Data) \| [Array.<Data>](#Alert..Data) | data | + + + +### alert.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Alert](#Alert) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### alert.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Alert](#Alert) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Alert.unserialize(data) ⇒ [ObjectData](#Alert..ObjectData) +**Kind**: static method of [Alert](#Alert) +**Returns**: [ObjectData](#Alert..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Alert..Data) \| [Array.<Data>](#Alert..Data) | data to convert to POJO | + + + +### Alert.validate(data) ⇒ string +Validates a given alert instance + +**Kind**: static method of [Alert](#Alert) +**Returns**: string - error - null if instance is valid +**Todo** + +- [ ] validate type (get a list) + + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Alert..Data) \| [Array.<Data>](#Alert..Data) | instance(s) to validate | + + + +### Alert~ArrayData : Array +[Alert](#Alert) data in WSv2 array format. Suitable for passing to +[Alert](#Alert) to construct a model instance. + +**Kind**: inner typedef of [Alert](#Alert) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | key | +| 1 | string | type | +| 2 | string | symbol | +| 3 | string | price | + + + +### Alert~Data : [Alert](#Alert) \| [ObjectData](#Alert..ObjectData) \| [ArrayData](#Alert..ArrayData) +[Alert](#Alert) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Alert](#Alert) + + +### Alert~ObjectData : object +[Alert](#Alert) data in plain object format. Suitable for passing to +[Alert](#Alert) to construct a model instance. + +**Kind**: inner typedef of [Alert](#Alert) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| key | string | alert key | +| type | string | alert type | +| symbol | string | configured symbol | +| price | string | configured price | + + + +## BalanceInfo ⇐ [Model](#Model) +Balance information model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [BalanceInfo](#BalanceInfo) ⇐ [Model](#Model) + * [new BalanceInfo(data)](#new_BalanceInfo_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#BalanceInfo.unserialize) ⇒ object + * [.validate(data)](#BalanceInfo.validate) ⇒ string + * _inner_ + * [~ArrayData](#BalanceInfo..ArrayData) : Array + * [~Data](#BalanceInfo..Data) : [BalanceInfo](#BalanceInfo) \| [ObjectData](#BalanceInfo..ObjectData) \| [ArrayData](#BalanceInfo..ArrayData) + * [~ObjectData](#BalanceInfo..ObjectData) : object + + + +### new BalanceInfo(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#BalanceInfo..Data) \| [Array.<Data>](#BalanceInfo..Data) | data | + + + +### balanceInfo.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [BalanceInfo](#BalanceInfo) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### balanceInfo.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [BalanceInfo](#BalanceInfo) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### BalanceInfo.unserialize(data) ⇒ object +**Kind**: static method of [BalanceInfo](#BalanceInfo) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#BalanceInfo..Data) \| [Array.<Data>](#BalanceInfo..Data) | data to convert to POJO | + + + +### BalanceInfo.validate(data) ⇒ string +Validates a given balance info instance + +**Kind**: static method of [BalanceInfo](#BalanceInfo) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#BalanceInfo..Data) \| [Array.<Data>](#BalanceInfo..Data) | instance(s) to validate | + + + +### BalanceInfo~ArrayData : Array +[BalanceInfo](#BalanceInfo) data in WSv2 array format. Suitable for passing to +[BalanceInfo](#BalanceInfo) to construct a model instance. + +**Kind**: inner typedef of [BalanceInfo](#BalanceInfo) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | amount | +| 1 | number | amountNet | + + + +### BalanceInfo~Data : [BalanceInfo](#BalanceInfo) \| [ObjectData](#BalanceInfo..ObjectData) \| [ArrayData](#BalanceInfo..ArrayData) +Balance info data either in WSv2 array or object format. + +**Kind**: inner typedef of [BalanceInfo](#BalanceInfo) + + +### BalanceInfo~ObjectData : object +[BalanceInfo](#BalanceInfo) data in plain object format. Suitable for passing to +[BalanceInfo](#BalanceInfo) to construct a model instance. + +**Kind**: inner typedef of [BalanceInfo](#BalanceInfo) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| amount | number | total balance | +| amountNet | number | net balance | + + + +## Candle ⇐ [Model](#Model) +OHLCV Candle model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Candle](#Candle) ⇐ [Model](#Model) + * [new Candle(data)](#new_Candle_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Candle.unserialize) ⇒ [ObjectData](#Candle..ObjectData) + * [.validate(data)](#Candle.validate) ⇒ string + * _inner_ + * [~ArrayData](#Candle..ArrayData) : Array + * [~Data](#Candle..Data) : [Candle](#Candle) \| [ObjectData](#Candle..ObjectData) \| [ArrayData](#Candle..ArrayData) + * [~ObjectData](#Candle..ObjectData) : object + + + +### new Candle(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Candle..Data) \| [Array.<Data>](#Candle..Data) | data | + + + +### candle.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Candle](#Candle) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### candle.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Candle](#Candle) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Candle.unserialize(data) ⇒ [ObjectData](#Candle..ObjectData) +**Kind**: static method of [Candle](#Candle) +**Returns**: [ObjectData](#Candle..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Candle..Data) \| [Array.<Data>](#Candle..Data) | data to convert to POJO | + + + +### Candle.validate(data) ⇒ string +Validates a given Candle instance + +**Kind**: static method of [Candle](#Candle) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Candle..Data) \| [Array.<Data>](#Candle..Data) | instance(s) to validate | + + + +### Candle~ArrayData : Array +[Candle](#Candle) data in WSv2 array format. Suitable for passing to +[Candle](#Candle) to construct a model instance. + +**Kind**: inner typedef of [Candle](#Candle) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | mts | +| 1 | number | open | +| 2 | number | close | +| 3 | number | high | +| 4 | number | low | +| 5 | number | volume | + + + +### Candle~Data : [Candle](#Candle) \| [ObjectData](#Candle..ObjectData) \| [ArrayData](#Candle..ArrayData) +Candle data either in WSv2 array or object format. + +**Kind**: inner typedef of [Candle](#Candle) + + +### Candle~ObjectData : object +[Candle](#Candle) data in plain object format. Suitable for passing to +[Candle](#Candle) to construct a model instance. + +**Kind**: inner typedef of [Candle](#Candle) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| mts | number | timestamp | +| open | number | open price | +| close | number | close price | +| high | number | highest price in period | +| low | number | lowest price in period | +| volume | number | total volume in period | + + + +## ChangeLog ⇐ [Model](#Model) +Change log model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [ChangeLog](#ChangeLog) ⇐ [Model](#Model) + * [new ChangeLog(data)](#new_ChangeLog_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#ChangeLog.unserialize) ⇒ object + * [.validate(data)](#ChangeLog.validate) ⇒ string + * _inner_ + * [~ArrayData](#ChangeLog..ArrayData) : Array + * [~Data](#ChangeLog..Data) : [ChangeLog](#ChangeLog) \| [ObjectData](#ChangeLog..ObjectData) \| [ArrayData](#ChangeLog..ArrayData) + * [~ObjectData](#ChangeLog..ObjectData) : object + + + +### new ChangeLog(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#ChangeLog..Data) \| [Array.<Data>](#ChangeLog..Data) | data | + + + +### changeLog.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [ChangeLog](#ChangeLog) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### changeLog.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [ChangeLog](#ChangeLog) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### ChangeLog.unserialize(data) ⇒ object +**Kind**: static method of [ChangeLog](#ChangeLog) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#ChangeLog..Data) \| [Array.<Data>](#ChangeLog..Data) | data to convert to POJO | + + + +### ChangeLog.validate(data) ⇒ string +Validates a given wallet instance + +**Kind**: static method of [ChangeLog](#ChangeLog) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#ChangeLog..Data) \| [Array.<Data>](#ChangeLog..Data) | instance(s) to validate | + + + +### ChangeLog~ArrayData : Array +[ChangeLog](#ChangeLog) data in WSv2 array format. Suitable for passing to +[ChangeLog](#ChangeLog) to construct a model instance. + +**Kind**: inner typedef of [ChangeLog](#ChangeLog) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | mtsCreate | +| 2 | string | log | +| 5 | string | ip | +| 6 | string | userAgent | + + + +### ChangeLog~Data : [ChangeLog](#ChangeLog) \| [ObjectData](#ChangeLog..ObjectData) \| [ArrayData](#ChangeLog..ArrayData) +Change log data either in WSv2 array or object format. + +**Kind**: inner typedef of [ChangeLog](#ChangeLog) + + +### ChangeLog~ObjectData : object +[ChangeLog](#ChangeLog) data in plain object format. Suitable for passing to +[ChangeLog](#ChangeLog) to construct a model instance. + +**Kind**: inner typedef of [ChangeLog](#ChangeLog) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| mtsCreate | number | timestamp | +| log | string | log data | +| ip | string | ip | +| userAgent | string | user agent | + + + +## Currency ⇐ [Model](#Model) +Currency model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Currency](#Currency) ⇐ [Model](#Model) + * [new Currency(data)](#new_Currency_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Currency.unserialize) ⇒ [ObjectData](#Currency..ObjectData) + * [.validate(data)](#Currency.validate) ⇒ string + * _inner_ + * [~ArrayData](#Currency..ArrayData) : Array + * [~Data](#Currency..Data) : [Currency](#Currency) \| [ObjectData](#Currency..ObjectData) \| [ArrayData](#Currency..ArrayData) + * [~ObjectData](#Currency..ObjectData) : object + + + +### new Currency(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Currency..Data) \| [Array.<Data>](#Currency..Data) | data | + + + +### currency.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Currency](#Currency) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### currency.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Currency](#Currency) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Currency.unserialize(data) ⇒ [ObjectData](#Currency..ObjectData) +**Kind**: static method of [Currency](#Currency) +**Returns**: [ObjectData](#Currency..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Currency..Data) \| [Array.<Data>](#Currency..Data) | data to convert to POJO | + + + +### Currency.validate(data) ⇒ string +Validates a given currency instance + +**Kind**: static method of [Currency](#Currency) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Currency..Data) \| [Array.<Data>](#Currency..Data) | instance(s) to validate | + + + +### Currency~ArrayData : Array +[Currency](#Currency) data in WSv2 array format. Suitable for passing to +[Currency](#Currency) to construct a model instance. + +**Kind**: inner typedef of [Currency](#Currency) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | id | +| 1 | string | name | +| 2 | string | pool | +| 3 | string | explorer | +| 4 | string | symbol | + + + +### Currency~Data : [Currency](#Currency) \| [ObjectData](#Currency..ObjectData) \| [ArrayData](#Currency..ArrayData) +Currency data either in WSv2 array or object format. + +**Kind**: inner typedef of [Currency](#Currency) + + +### Currency~ObjectData : object +[Currency](#Currency) data in plain object format. Suitable for passing to +[Currency](#Currency) to construct a model instance. + +**Kind**: inner typedef of [Currency](#Currency) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | string | id | +| name | string | currency name ('Ethereum') | +| pool | string | pool | +| exporer | string | explorer URL | +| symbol | string | symbol ('ETH') | + + + +## FundingCredit ⇐ [Model](#Model) +Funding Credit model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingCredit](#FundingCredit) ⇐ [Model](#Model) + * [new FundingCredit(data)](#new_FundingCredit_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingCredit.unserialize) ⇒ [ObjectData](#FundingCredit..ObjectData) + * [.validate(data)](#FundingCredit.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingCredit..ArrayData) : Array + * [~Data](#FundingCredit..Data) : [FundingCredit](#FundingCredit) \| [ObjectData](#FundingCredit..ObjectData) \| [ArrayData](#FundingCredit..ArrayData) + * [~ObjectData](#FundingCredit..ObjectData) : object + + + +### new FundingCredit(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingCredit..Data) \| [Array.<Data>](#FundingCredit..Data) | data | + + + +### fundingCredit.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingCredit](#FundingCredit) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingCredit.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingCredit](#FundingCredit) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingCredit.unserialize(data) ⇒ [ObjectData](#FundingCredit..ObjectData) +**Kind**: static method of [FundingCredit](#FundingCredit) +**Returns**: [ObjectData](#FundingCredit..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingCredit..Data) \| [Array.<Data>](#FundingCredit..Data) | data to convert to POJO | + + + +### FundingCredit.validate(data) ⇒ string +Validates a given funding credit instance + +**Kind**: static method of [FundingCredit](#FundingCredit) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingCredit..Data) \| [Array.<Data>](#FundingCredit..Data) | instance(s) to validate | + + + +### FundingCredit~ArrayData : Array +[FundingCredit](#FundingCredit) data in WSv2 array format. Suitable for passing to a +[FundingCredit](#FundingCredit) instance. + +**Kind**: inner typedef of [FundingCredit](#FundingCredit) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | symbol | +| 2 | number | side | +| 3 | number | mtsCreate | +| 4 | number | mtsUpdate | +| 13 | number | mtsOpening | +| 14 | number | mtsLastPayout | +| 5 | number | amount | +| 6 | number | flags | +| 7 | number | status | +| 11 | number | rate | +| 19 | number | rateReal | +| 12 | number | period | +| 21 | string | positionPair | +| 15 | number | notify | +| 16 | number | hidden | +| 18 | number | renew | +| 20 | number | noClose | + + + +### FundingCredit~Data : [FundingCredit](#FundingCredit) \| [ObjectData](#FundingCredit..ObjectData) \| [ArrayData](#FundingCredit..ArrayData) +[FundingCredit](#FundingCredit) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingCredit](#FundingCredit) + + +### FundingCredit~ObjectData : object +[FundingCredit](#FundingCredit) data in plain object format. Suitable for passing to +[FundingCredit](#FundingCredit) to construct a model instance. + +**Kind**: inner typedef of [FundingCredit](#FundingCredit) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| symbol | string | symbol | +| side | number | side | +| mtsCreate | number | creation timestamp | +| mtsUpdate | number | last update timestamp | +| mtsOpening | number | open timestamp | +| mtsLastPayout | number | last payout timestamp | +| amount | number | remaining amount | +| flags | number | flags | +| status | number | current status | +| rate | number | rate | +| rateReal | number | rate | +| period | number | period | +| positionPair | string | position pair | +| notify | number \| boolean | notify flag | +| hidden | number \| boolean | hidden flag | +| renew | number \| boolean | renew flag | +| noClose | number \| boolean | no-close flag | + + + +## FundingInfo ⇐ [Model](#Model) +Account Funding Info model + +**Kind**: global class +**Extends**: [Model](#Model) +**Todo** + +- [ ] Extract type defs (varying format) + + +* [FundingInfo](#FundingInfo) ⇐ [Model](#Model) + * [new FundingInfo(data)](#new_FundingInfo_new) + * _instance_ + * [.serialize()](#FundingInfo+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingInfo.unserialize) ⇒ object + * [.validate(data)](#FundingInfo.validate) ⇒ string + + + +### new FundingInfo(data) +Create a new instance from a data payload + + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | funding info data | + + + +### fundingInfo.serialize() ⇒ Array +Return an array representation of this model + +**Kind**: instance method of [FundingInfo](#FundingInfo) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingInfo.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingInfo](#FundingInfo) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingInfo.unserialize(data) ⇒ object +TODO: Figure out a better object key for 'payload', as we need to support + both arrays and POJOs + +**Kind**: static method of [FundingInfo](#FundingInfo) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | data to convert to POJO | + + + +### FundingInfo.validate(data) ⇒ string +Validates a given funding info instance + +**Kind**: static method of [FundingInfo](#FundingInfo) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| [Array.<FundingInfo>](#FundingInfo) \| [FundingInfo](#FundingInfo) | data to validate | + + + +## FundingLoan ⇐ [Model](#Model) +Funding Loan model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingLoan](#FundingLoan) ⇐ [Model](#Model) + * [new FundingLoan(data)](#new_FundingLoan_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingLoan.unserialize) ⇒ [ObjectData](#FundingLoan..ObjectData) + * [.validate(data)](#FundingLoan.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingLoan..ArrayData) : Array + * [~Data](#FundingLoan..Data) : [FundingLoan](#FundingLoan) \| [ObjectData](#FundingLoan..ObjectData) \| [ArrayData](#FundingLoan..ArrayData) + * [~ObjectData](#FundingLoan..ObjectData) : object + + + +### new FundingLoan(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingLoan..Data) \| [Array.<Data>](#FundingLoan..Data) | data | + + + +### fundingLoan.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingLoan](#FundingLoan) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingLoan.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingLoan](#FundingLoan) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingLoan.unserialize(data) ⇒ [ObjectData](#FundingLoan..ObjectData) +**Kind**: static method of [FundingLoan](#FundingLoan) +**Returns**: [ObjectData](#FundingLoan..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingLoan..Data) \| [Array.<Data>](#FundingLoan..Data) | data to convert to POJO | + + + +### FundingLoan.validate(data) ⇒ string +Validates a given funding loan instance + +**Kind**: static method of [FundingLoan](#FundingLoan) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingLoan..Data) \| [Array.<Data>](#FundingLoan..Data) | instance(s) to validate | + + + +### FundingLoan~ArrayData : Array +[FundingLoan](#FundingLoan) data in WSv2 array format. Suitable for passing to +[FundingLoan](#FundingLoan) to construct a model instance. + +**Kind**: inner typedef of [FundingLoan](#FundingLoan) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | symbol | +| 2 | number | side | +| 3 | number | mtsCreate | +| 4 | number | mtsUpdate | +| 13 | number | mtsOpening | +| 14 | number | mtsLastPayout | +| 5 | number | amount | +| 6 | number | flags | +| 7 | number | status | +| 8 | string | type | +| 11 | number | rate | +| 19 | number | rateReal | +| 12 | number | period | +| 15 | number | notify | +| 16 | number | hidden | +| 18 | number | renew | +| 20 | number | noClose | + + + +### FundingLoan~Data : [FundingLoan](#FundingLoan) \| [ObjectData](#FundingLoan..ObjectData) \| [ArrayData](#FundingLoan..ArrayData) +[FundingLoan](#FundingLoan) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingLoan](#FundingLoan) + + +### FundingLoan~ObjectData : object +[FundingLoan](#FundingLoan) data in plain object format. Suitable for passing to +[FundingLoan](#FundingLoan) to construct a model instance. + +**Kind**: inner typedef of [FundingLoan](#FundingLoan) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| symbol | string | symbol | +| side | number | side | +| mtsCreate | number | creation timestamp | +| mtsUpdate | number | last update timestamp | +| mtsOpening | number | open timestamp | +| mtsLastPayout | number | last payout timestamp | +| amount | number | amount | +| flags | number | flags | +| status | number | status | +| rate | number | rate | +| rateReal | number | rate real | +| period | number | period flag | +| notify | number \| boolean | notify flag | +| hidden | number \| boolean | hidden flag | +| renew | number \| boolean | renew flag | +| noClose | number \| boolean | no-close flag | + + + +## FundingOffer ⇐ [Model](#Model) +Funding Offer model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingOffer](#FundingOffer) ⇐ [Model](#Model) + * [new FundingOffer(data, [apiInterface])](#new_FundingOffer_new) + * _instance_ + * [.toNewOfferPacket()](#FundingOffer+toNewOfferPacket) ⇒ [SubmitPayload](#FundingOffer..SubmitPayload) + * [.submit([apiInterface])](#FundingOffer+submit) ⇒ Promise + * [.cancel([apiInterface])](#FundingOffer+cancel) ⇒ Promise + * [.close([apiInterface])](#FundingOffer+close) ⇒ Promise + * [.toString()](#FundingOffer+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingOffer.unserialize) ⇒ [ObjectData](#FundingOffer..ObjectData) + * [.validate(data)](#FundingOffer.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingOffer..ArrayData) : Array + * [~Data](#FundingOffer..Data) : [FundingOffer](#FundingOffer) \| [ObjectData](#FundingOffer..ObjectData) \| [ArrayData](#FundingOffer..ArrayData) + * [~ObjectData](#FundingOffer..ObjectData) : object + * [~SubmitPayload](#FundingOffer..SubmitPayload) : object + + + +### new FundingOffer(data, [apiInterface]) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingOffer..Data) \| [Array.<Data>](#FundingOffer..Data) | data | +| [apiInterface] | object | rest or websocket object capable of submitting funding offers | + + + +### fundingOffer.toNewOfferPacket() ⇒ [SubmitPayload](#FundingOffer..SubmitPayload) +Creates an order map that can be used in either the websocket `on` +command or a rest request body + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Returns**: [SubmitPayload](#FundingOffer..SubmitPayload) - on + + +### fundingOffer.submit([apiInterface]) ⇒ Promise +Submit the funding offer + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bfx-api-node-rest.RESTv2 | rest instance | + + + +### fundingOffer.cancel([apiInterface]) ⇒ Promise +Cancel the funding offer + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bfx-api-node-rest.RESTv2 | rest instance | + + + +### fundingOffer.close([apiInterface]) ⇒ Promise +Close the funding offer + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bfx-api-node-rest.RESTv2 | rest instance | + + + +### fundingOffer.toString() ⇒ string +Returns a string representation of the position + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Returns**: string - desc + + +### fundingOffer.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingOffer.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingOffer](#FundingOffer) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingOffer.unserialize(data) ⇒ [ObjectData](#FundingOffer..ObjectData) +**Kind**: static method of [FundingOffer](#FundingOffer) +**Returns**: [ObjectData](#FundingOffer..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingOffer..Data) \| [Array.<Data>](#FundingOffer..Data) | data to convert to POJO | + + + +### FundingOffer.validate(data) ⇒ string +Validates a given funding offer instance + +**Kind**: static method of [FundingOffer](#FundingOffer) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingOffer..Data) \| [Array.<Data>](#FundingOffer..Data) | instance(s) to validate | + + + +### FundingOffer~ArrayData : Array +[FundingOffer](#FundingOffer) data in WSv2 array format. Suitable for passing to +[FundingOffer](#FundingOffer) to construct a model instance. + +**Kind**: inner typedef of [FundingOffer](#FundingOffer) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | symbol | +| 2 | number | mtsCreate | +| 3 | number | mtsUpdate | +| 4 | number | amount | +| 5 | number | amountOrig | +| 6 | string | type | +| 9 | number | flags | +| 10 | string | status | +| 14 | number | rate | +| 15 | number | period | +| 16 | number | notify | +| 17 | number | hidden | +| 19 | number | renew | +| 20 | number | rateReal | + + + +### FundingOffer~Data : [FundingOffer](#FundingOffer) \| [ObjectData](#FundingOffer..ObjectData) \| [ArrayData](#FundingOffer..ArrayData) +[FundingOffer](#FundingOffer) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingOffer](#FundingOffer) + + +### FundingOffer~ObjectData : object +[FundingOffer](#FundingOffer) data in plain object format. Suitable for passing to +[FundingOffer](#FundingOffer) to construct a model instance. + +**Kind**: inner typedef of [FundingOffer](#FundingOffer) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| symbol | string | symbol | +| mtsCreate | number | creation timestamp | +| mtsUpdate | number | last update timestamp | +| amount | string | remaining amount | +| amountOrig | string | original amount | +| type | string | funding offer type | +| flags | number | flags | +| status | string | current status | +| rate | number | rate | +| rateReal | number | rate real | +| period | number | period for the offer | +| notify | number \| boolean | notify flag | +| hidden | number \| boolean | hidden flag | +| renew | number \| boolean | renew flag | + + + +### FundingOffer~SubmitPayload : object +A set of parameters describing an atomic [FundingOffer](#FundingOffer) that can be +sent via the WSv2 API. + +**Kind**: inner typedef of [FundingOffer](#FundingOffer) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| type | string | type | +| symbol | string | symbol | +| amount | string | amount | +| rate | string | rate | +| period | number | period | +| flags | number | flags | + + + +## FundingTickerHist ⇐ [Model](#Model) +Historical Funding Ticker model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingTickerHist](#FundingTickerHist) ⇐ [Model](#Model) + * [new FundingTickerHist(data)](#new_FundingTickerHist_new) + * _instance_ + * [.quote()](#FundingTickerHist+quote) ⇒ string + * [.base()](#FundingTickerHist+base) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingTickerHist.unserialize) ⇒ [ObjectData](#FundingTickerHist..ObjectData) + * [.validate(data)](#FundingTickerHist.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingTickerHist..ArrayData) : Array + * [~Data](#FundingTickerHist..Data) : [FundingTickerHist](#FundingTickerHist) \| [ObjectData](#FundingTickerHist..ObjectData) \| [ArrayData](#FundingTickerHist..ArrayData) + * [~ObjectData](#FundingTickerHist..ObjectData) : object + + + +### new FundingTickerHist(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTickerHist..Data) \| [Array.<Data>](#FundingTickerHist..Data) | data | + + + +### fundingTickerHist.quote() ⇒ string +Get the quote currency for the historical ticker. + +**Kind**: instance method of [FundingTickerHist](#FundingTickerHist) +**Returns**: string - quoteCurrency + + +### fundingTickerHist.base() ⇒ string +Get the base currency for the historical ticker. + +**Kind**: instance method of [FundingTickerHist](#FundingTickerHist) +**Returns**: string - baseCurrency + + +### fundingTickerHist.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingTickerHist](#FundingTickerHist) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingTickerHist.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingTickerHist](#FundingTickerHist) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingTickerHist.unserialize(data) ⇒ [ObjectData](#FundingTickerHist..ObjectData) +**Kind**: static method of [FundingTickerHist](#FundingTickerHist) +**Returns**: [ObjectData](#FundingTickerHist..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTickerHist..Data) \| [Array.<Data>](#FundingTickerHist..Data) | data to convert to POJO | + + + +### FundingTickerHist.validate(data) ⇒ string +Validates a given historical funding ticker instance. + +**Kind**: static method of [FundingTickerHist](#FundingTickerHist) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTickerHist..Data) \| [Array.<Data>](#FundingTickerHist..Data) | models to validate | + + + +### FundingTickerHist~ArrayData : Array +[FundingTickerHist](#FundingTickerHist) data in WSv2 array format. Suitable for passing to +[FundingTickerHist](#FundingTickerHist) to construct a model instance. + +**Kind**: inner typedef of [FundingTickerHist](#FundingTickerHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | symbol | +| 2 | number | bid | +| 4 | number | bidPeriod | +| 5 | number | ask | +| 15 | number | mtsUpdate | + + + +### FundingTickerHist~Data : [FundingTickerHist](#FundingTickerHist) \| [ObjectData](#FundingTickerHist..ObjectData) \| [ArrayData](#FundingTickerHist..ArrayData) +[FundingTickerHist](#FundingTickerHist) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingTickerHist](#FundingTickerHist) + + +### FundingTickerHist~ObjectData : object +[FundingTickerHist](#FundingTickerHist) data in plain object format. Suitable for passing +to [FundingTickerHist](#FundingTickerHist) to construct a model instance. + +**Kind**: inner typedef of [FundingTickerHist](#FundingTickerHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| symbol | string | symbol | +| bid | number | bid | +| bidPeriod | number | bid period | +| ask | number | ask | +| mtsUpdate | number | timestamp | + + + +## FundingTicker ⇐ [Model](#Model) +Funding Ticker model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingTicker](#FundingTicker) ⇐ [Model](#Model) + * [new FundingTicker(data)](#new_FundingTicker_new) + * _instance_ + * [.quote()](#FundingTicker+quote) ⇒ string + * [.base()](#FundingTicker+base) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingTicker.unserialize) ⇒ [ObjectData](#FundingTicker..ObjectData) + * [.validate(data)](#FundingTicker.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingTicker..ArrayData) : Array + * [~Data](#FundingTicker..Data) : [FundingTicker](#FundingTicker) \| [ObjectData](#FundingTicker..ObjectData) \| [ArrayData](#FundingTicker..ArrayData) + * [~ObjectData](#FundingTicker..ObjectData) : object + + + +### new FundingTicker(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTicker..Data) \| [Array.<Data>](#FundingTicker..Data) | data | + + + +### fundingTicker.quote() ⇒ string +Get the quote currency for the ticker. + +**Kind**: instance method of [FundingTicker](#FundingTicker) +**Returns**: string - quoteCurrency + + +### fundingTicker.base() ⇒ string +Get the base currency for the ticker. + +**Kind**: instance method of [FundingTicker](#FundingTicker) +**Returns**: string - baseCurrency + + +### fundingTicker.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingTicker](#FundingTicker) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingTicker.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingTicker](#FundingTicker) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingTicker.unserialize(data) ⇒ [ObjectData](#FundingTicker..ObjectData) +**Kind**: static method of [FundingTicker](#FundingTicker) +**Returns**: [ObjectData](#FundingTicker..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTicker..Data) \| [Array.<Data>](#FundingTicker..Data) | data to convert to POJO | + + + +### FundingTicker.validate(data) ⇒ string +Validates a given funding ticker instance + +**Kind**: static method of [FundingTicker](#FundingTicker) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTicker..Data) \| [Array.<Data>](#FundingTicker..Data) | instance(s) to validate | + + + +### FundingTicker~ArrayData : Array +[FundingTicker](#FundingTicker) data in WSv2 array format. Suitable for passing to +[FundingTicker](#FundingTicker) instance. + +**Kind**: inner typedef of [FundingTicker](#FundingTicker) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | symbol | +| 1 | number | frr | +| 2 | number | bid | +| 3 | number | bidSize | +| 4 | number | bidPeriod | +| 5 | number | ask | +| 6 | number | askSize | +| 7 | number | askPeriod | +| 8 | number | dailyChange | +| 9 | number | dailyChangePerc | +| 10 | number | lastPrice | +| 11 | number | volume | +| 12 | number | high | +| 13 | number | low | + + + +### FundingTicker~Data : [FundingTicker](#FundingTicker) \| [ObjectData](#FundingTicker..ObjectData) \| [ArrayData](#FundingTicker..ArrayData) +[FundingTicker](#FundingTicker) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingTicker](#FundingTicker) + + +### FundingTicker~ObjectData : object +[FundingTicker](#FundingTicker) data in plain object format. Suitable for passing to +[FundingTicker](#FundingTicker) to construct a model instance. + +**Kind**: inner typedef of [FundingTicker](#FundingTicker) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| symbol | string | symbol | +| frr | number \| boolean | current FRR | +| bid | number | best bid | +| bidSize | number | total bid amount | +| bidPeriod | number | bid period | +| ask | number | best ask | +| askSize | number | total ask amount | +| askPeriod | number | ask period | +| dailyChange | number | net 24h period change | +| dailyChangePerc | number | net 24h period change as percent | +| lastPrice | number | last price | +| volume | number | total volume in last 24h period | +| high | number | highest rate in last 24h period | +| low | number | lowest rate in last 24h period | + + + +## FundingTrade ⇐ [Model](#Model) +Funding Trade model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [FundingTrade](#FundingTrade) ⇐ [Model](#Model) + * [new FundingTrade(data)](#new_FundingTrade_new) + * _instance_ + * [.toString()](#FundingTrade+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#FundingTrade.unserialize) ⇒ [ObjectData](#FundingTrade..ObjectData) + * [.validate(data)](#FundingTrade.validate) ⇒ string + * _inner_ + * [~ArrayData](#FundingTrade..ArrayData) : Array + * [~Data](#FundingTrade..Data) : [FundingTrade](#FundingTrade) \| [ObjectData](#FundingTrade..ObjectData) \| [ArrayData](#FundingTrade..ArrayData) + * [~ObjectData](#FundingTrade..ObjectData) : object + + + +### new FundingTrade(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTrade..Data) \| [Array.<Data>](#FundingTrade..Data) | data | + + + +### fundingTrade.toString() ⇒ string +Returns a string representation of the model, containing pertinent +information. + +**Kind**: instance method of [FundingTrade](#FundingTrade) +**Returns**: string - str + + +### fundingTrade.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [FundingTrade](#FundingTrade) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### fundingTrade.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [FundingTrade](#FundingTrade) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### FundingTrade.unserialize(data) ⇒ [ObjectData](#FundingTrade..ObjectData) +**Kind**: static method of [FundingTrade](#FundingTrade) +**Returns**: [ObjectData](#FundingTrade..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTrade..Data) \| [Array.<Data>](#FundingTrade..Data) | data to convert to POJO | + + + +### FundingTrade.validate(data) ⇒ string +Validates a given funding trade instance + +**Kind**: static method of [FundingTrade](#FundingTrade) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#FundingTrade..Data) \| [Array.<Data>](#FundingTrade..Data) | instance(s) to validate | + + + +### FundingTrade~ArrayData : Array +[FundingTrade](#FundingTrade) data in WSv2 array format. Suitable for passing to +[FundingTrade](#FundingTrade) to construct a model instance. + +**Kind**: inner typedef of [FundingTrade](#FundingTrade) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | symbol | +| 2 | number | mtsCreate | +| 3 | number | offerID | +| 4 | number | amount | +| 5 | number | rate | +| 6 | number | period | +| 7 | number | maker | + + + +### FundingTrade~Data : [FundingTrade](#FundingTrade) \| [ObjectData](#FundingTrade..ObjectData) \| [ArrayData](#FundingTrade..ArrayData) +[FundingTrade](#FundingTrade) data either in WSv2 array or object format. + +**Kind**: inner typedef of [FundingTrade](#FundingTrade) + + +### FundingTrade~ObjectData : object +[FundingTrade](#FundingTrade) data in plain object format. Suitable for passing to +[FundingTrade](#FundingTrade) to construct a model instance. + +**Kind**: inner typedef of [FundingTrade](#FundingTrade) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| symbol | string | symbol | +| mtsCreate | number | creation timestamp | +| offerID | number | taken offer ID | +| amount | number | amount | +| rate | number | rate | +| period | number | period | +| maker | number \| boolean | maker flag | + + + +## Invoice +Deposit Invoice model + +**Kind**: global class + +* [Invoice](#Invoice) + * [new Invoice(data)](#new_Invoice_new) + * _instance_ + * [.toString()](#Invoice+toString) ⇒ string + * _static_ + * [.unserialize(data)](#Invoice.unserialize) ⇒ object + * [.validate(data)](#Invoice.validate) ⇒ string + + + +### new Invoice(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | object \| Array | deposit invoice | +| data.invoiceHash | string | Hashed invoice | +| data.invoice | string | Requested invoice | +| data.amount | string | Amount of invoice | + + + +### invoice.toString() ⇒ string +**Kind**: instance method of [Invoice](#Invoice) +**Returns**: string - str + + +### Invoice.unserialize(data) ⇒ object +**Kind**: static method of [Invoice](#Invoice) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | data to convert to POJO | + + + +### Invoice.validate(data) ⇒ string +Validates a given invoice instance + +**Kind**: static method of [Invoice](#Invoice) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| [Array.<Invoice>](#Invoice) \| [Invoice](#Invoice) \| Array | instance to validate | + + + +## LedgerEntry ⇐ [Model](#Model) +Ledger Entry model; wallet field is automatically populated if a description +is provided. + +**Kind**: global class +**Extends**: [Model](#Model) + +* [LedgerEntry](#LedgerEntry) ⇐ [Model](#Model) + * [new LedgerEntry(data)](#new_LedgerEntry_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#LedgerEntry.unserialize) ⇒ [ObjectData](#LedgerEntry..ObjectData) + * [.validate(data)](#LedgerEntry.validate) ⇒ string + * _inner_ + * [~ArrayData](#LedgerEntry..ArrayData) : Array + * [~Data](#LedgerEntry..Data) : [LedgerEntry](#LedgerEntry) \| [ObjectData](#LedgerEntry..ObjectData) \| [ArrayData](#LedgerEntry..ArrayData) + * [~ObjectData](#LedgerEntry..ObjectData) : object + + + +### new LedgerEntry(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#LedgerEntry..Data) \| [Array.<Data>](#LedgerEntry..Data) | data | + + + +### ledgerEntry.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [LedgerEntry](#LedgerEntry) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### ledgerEntry.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [LedgerEntry](#LedgerEntry) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### LedgerEntry.unserialize(data) ⇒ [ObjectData](#LedgerEntry..ObjectData) +**Kind**: static method of [LedgerEntry](#LedgerEntry) +**Returns**: [ObjectData](#LedgerEntry..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#LedgerEntry..Data) \| [Array.<Data>](#LedgerEntry..Data) | data to convert to POJO | + + + +### LedgerEntry.validate(data) ⇒ string +Validates a given ledger entry instance + +**Kind**: static method of [LedgerEntry](#LedgerEntry) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#LedgerEntry..Data) \| [Array.<Data>](#LedgerEntry..Data) | instance(s) to validate | + + + +### LedgerEntry~ArrayData : Array +[LedgerEntry](#LedgerEntry) data in WSv2 array format. Suitable for passing to +[LedgerEntry](#LedgerEntry) to construct a model instance. + +**Kind**: inner typedef of [LedgerEntry](#LedgerEntry) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | currency | +| 3 | number | mts | +| 5 | number | amount | +| 6 | number | balance | +| 8 | string | description | + + + +### LedgerEntry~Data : [LedgerEntry](#LedgerEntry) \| [ObjectData](#LedgerEntry..ObjectData) \| [ArrayData](#LedgerEntry..ArrayData) +[LedgerEntry](#LedgerEntry) data either in WSv2 array or object format. + +**Kind**: inner typedef of [LedgerEntry](#LedgerEntry) + + +### LedgerEntry~ObjectData : object +[LedgerEntry](#LedgerEntry) data in plain object format. Suitable for passing to +[LedgerEntry](#LedgerEntry) to construct a model instance. + +**Kind**: inner typedef of [LedgerEntry](#LedgerEntry) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| currency | string | currency | +| mts | number | transaction timestamp | +| amount | number | transaction amount | +| balance | number | balance at time of transaction | +| description | string | transaction description | + + + +## Liquidations ⇐ [Model](#Model) +Liquidation Info model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Liquidations](#Liquidations) ⇐ [Model](#Model) + * [new Liquidations(data)](#new_Liquidations_new) + * _instance_ + * [.toString()](#Liquidations+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Liquidations.unserialize) ⇒ [ObjectData](#Liquidations..ObjectData) + * [.validate(data)](#Liquidations.validate) ⇒ string + * _inner_ + * [~ArrayData](#Liquidations..ArrayData) : Array + * [~Data](#Liquidations..Data) : [Liquidations](#Liquidations) \| [ObjectData](#Liquidations..ObjectData) \| [ArrayData](#Liquidations..ArrayData) + * [~ObjectData](#Liquidations..ObjectData) : object + + + +### new Liquidations(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Liquidations..Data) \| [Array.<Data>](#Liquidations..Data) | data | + + + +### liquidations.toString() ⇒ string +**Kind**: instance method of [Liquidations](#Liquidations) +**Returns**: string - str + + +### liquidations.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Liquidations](#Liquidations) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### liquidations.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Liquidations](#Liquidations) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Liquidations.unserialize(data) ⇒ [ObjectData](#Liquidations..ObjectData) +**Kind**: static method of [Liquidations](#Liquidations) +**Returns**: [ObjectData](#Liquidations..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Liquidations..Data) \| [Array.<Data>](#Liquidations..Data) | data to convert to POJO | + + + +### Liquidations.validate(data) ⇒ string +Validates a given liquidation instance + +**Kind**: static method of [Liquidations](#Liquidations) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Liquidations..Data) \| [Array.<Data>](#Liquidations..Data) | instance(s) to validate | + + + +### Liquidations~ArrayData : Array +[Liquidations](#Liquidations) data in WSv2 array format. Suitable for passing to +[Liquidations](#Liquidations) to construct a model instance. + +**Kind**: inner typedef of [Liquidations](#Liquidations) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 1 | number | posId | +| 2 | number | mtsUpdated | +| 4 | string | symbol | +| 5 | number | amount | +| 6 | number | basePrice | +| 8 | number | isMatch | +| 9 | number | isMarketSold | + + + +### Liquidations~Data : [Liquidations](#Liquidations) \| [ObjectData](#Liquidations..ObjectData) \| [ArrayData](#Liquidations..ArrayData) +[Liquidations](#Liquidations) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Liquidations](#Liquidations) + + +### Liquidations~ObjectData : object +[Liquidations](#Liquidations) data in plain object format. Suitable for passing to +[Liquidations](#Liquidations) to construct a model instance. + +**Kind**: inner typedef of [Liquidations](#Liquidations) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| posId | number | position ID | +| mtsUpdated | number | timestamp | +| symbol | string | symbol | +| amount | number | amount | +| basePrice | number | base price | +| isMatch | number \| boolean | matched flag | +| isMarketSold | number \| boolean | sold flag | + + + +## Login ⇐ [Model](#Model) +Login event model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Login](#Login) ⇐ [Model](#Model) + * [new Login(data)](#new_Login_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Login.unserialize) ⇒ [ObjectData](#Login..ObjectData) + * [.validate(data)](#Login.validate) ⇒ string + * _inner_ + * [~ArrayData](#Login..ArrayData) : Array + * [~Data](#Login..Data) : [Login](#Login) \| [ObjectData](#Login..ObjectData) \| [ArrayData](#Login..ArrayData) + * [~ObjectData](#Login..ObjectData) : object + + + +### new Login(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Login..Data) \| [Array.<Data>](#Login..Data) | data | + + + +### login.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Login](#Login) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### login.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Login](#Login) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Login.unserialize(data) ⇒ [ObjectData](#Login..ObjectData) +**Kind**: static method of [Login](#Login) +**Returns**: [ObjectData](#Login..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Login..Data) \| [Array.<Data>](#Login..Data) | data to convert to POJO | + + + +### Login.validate(data) ⇒ string +Validates a given login instance + +**Kind**: static method of [Login](#Login) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Login..Data) \| [Array.<Data>](#Login..Data) | instance(s) to validate | + + + +### Login~ArrayData : Array +[Login](#Login) data in WSv2 array format. Suitable for passing to +[Login](#Login) to construct a model instance. + +**Kind**: inner typedef of [Login](#Login) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 2 | number | time | +| 4 | string | ip | +| 7 | object | extraData | + + + +### Login~Data : [Login](#Login) \| [ObjectData](#Login..ObjectData) \| [ArrayData](#Login..ArrayData) +[Login](#Login) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Login](#Login) + + +### Login~ObjectData : object +[Login](#Login) data in plain object format. Suitable for passing to +[Login](#Login) to construct a model instance. + +**Kind**: inner typedef of [Login](#Login) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| time | number | timestamp | +| ip | string | client IP address | +| extraData | object | metadata | + + + +## MarginInfo ⇐ [Model](#Model) +Margin Info model + +**Kind**: global class +**Extends**: [Model](#Model) +**Todo** + +- [ ] Extract type defs (varying format) + + +* [MarginInfo](#MarginInfo) ⇐ [Model](#Model) + * [new MarginInfo(data)](#new_MarginInfo_new) + * _instance_ + * [.serialize()](#MarginInfo+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#MarginInfo.unserialize) ⇒ object + * [.validate(data)](#MarginInfo.validate) ⇒ string + + + +### new MarginInfo(data) +Create a new instance from a data payload + + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | margin info data | + + + +### marginInfo.serialize() ⇒ Array +Return an array representation of this model + +**Kind**: instance method of [MarginInfo](#MarginInfo) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### marginInfo.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [MarginInfo](#MarginInfo) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### MarginInfo.unserialize(data) ⇒ object +TODO: Figure out a better object key for 'payload', as we need to support + both arrays and POJOs + +**Kind**: static method of [MarginInfo](#MarginInfo) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | data to convert to POJO | + + + +### MarginInfo.validate(data) ⇒ string +Validates a given margin info instance + +**Kind**: static method of [MarginInfo](#MarginInfo) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| [Array.<MarginInfo>](#MarginInfo) \| [MarginInfo](#MarginInfo) \| Array | instance(s) to validate | + + + +## Model ⇐ events.EventEmitter +Base model class, providing format-conversion methods + +**Kind**: global class +**Extends**: events.EventEmitter + +* [Model](#Model) ⇐ events.EventEmitter + * [new Model(params)](#new_Model_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(args)](#Model.unserialize) ⇒ object + * [.validate(args)](#Model.validate) ⇒ Error \| null + + + +### new Model(params) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| params | object | | model parameters | +| [params.data] | Array.<object> \| object \| Array | | model data | +| [params.fields] | object | {} | field definitions, { [index]: key } | +| [params.boolFields] | Array.<string> | [] | array of boolean field keys | + + + +### model.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Model](#Model) +**Returns**: Array - arr + + +### model.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Model](#Model) +**Returns**: object - pojo + + +### Model.unserialize(args) ⇒ object +Generic method for converting either an array, object, or model instance to +a POJO. + +**Kind**: static method of [Model](#Model) +**Returns**: object - pojo + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| args | object | | arguments | +| args.data | Array.<object> \| object \| Array | | can also be a model instance | +| args.fields | object | | field definitions, { [index]: key } | +| [args.boolFields] | Array.<string> | [] | array of boolean field keys | + + + +### Model.validate(args) ⇒ Error \| null +Validates either a single model instance or a collection of model instances +against a set of validation functions defined per-key. + +Returns the first error found. + +**Kind**: static method of [Model](#Model) +**Returns**: Error \| null - error - null if instance is valid + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| args | object | | arguments | +| args.data | Array.<object> \| object \| Array | | model or collection to validate | +| args.fields | object | | map of fields to array indexes | +| args.validators | object | | map of field names to validation funcs | +| [args.boolFields] | Array.<string> | [] | array of boolean field keys | + + + +## Movement ⇐ [Model](#Model) +Currency Movement model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Movement](#Movement) ⇐ [Model](#Model) + * [new Movement(data)](#new_Movement_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Movement.unserialize) ⇒ object + * [.validate(data)](#Movement.validate) ⇒ string + * _inner_ + * [~ArrayData](#Movement..ArrayData) : Array + * [~Data](#Movement..Data) : [Movement](#Movement) \| [ObjectData](#Movement..ObjectData) \| [ArrayData](#Movement..ArrayData) + * [~ObjectData](#Movement..ObjectData) : object + + + +### new Movement(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Movement..Data) \| [Array.<Data>](#Movement..Data) | data | + + + +### movement.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Movement](#Movement) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### movement.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Movement](#Movement) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Movement.unserialize(data) ⇒ object +**Kind**: static method of [Movement](#Movement) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Movement..Data) \| [Array.<Data>](#Movement..Data) | data to convert to POJO | + + + +### Movement.validate(data) ⇒ string +Validates a given movement instance + +**Kind**: static method of [Movement](#Movement) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Movement..Data) \| [Array.<Data>](#Movement..Data) | instance(s) to validate | + + + +### Movement~ArrayData : Array +[Movement](#Movement) data in WSv2 array format. Suitable for passing to +[Movement](#Movement) to construct a model instance. + +**Kind**: inner typedef of [Movement](#Movement) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | currency | +| 2 | string | currencyName | +| 5 | number | mtsStarted | +| 6 | number | mtsUpdated | +| 9 | string | status | +| 12 | number | amount | +| 13 | number | fees | +| 16 | string | destinationAddress | +| 20 | number | transactionId | + + + +### Movement~Data : [Movement](#Movement) \| [ObjectData](#Movement..ObjectData) \| [ArrayData](#Movement..ArrayData) +[Movement](#Movement) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Movement](#Movement) + + +### Movement~ObjectData : object +[Movement](#Movement) data in plain object format. Suitable for passing to +[Movement](#Movement) to construct a model instance. + +**Kind**: inner typedef of [Movement](#Movement) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| currency | string | currency | +| currencyName | string | currency name | +| mtsStarted | number | movement start timestamp | +| mtsUpdated | number | last update timestamp | +| status | string | status | +| amount | number | moved amount | +| fees | number | paid fees | +| destinationAddress | string | destination address | +| transactionId | number | transaction ID | + + + +## Notification ⇐ [Model](#Model) +Notification model. Broadcast notification body schema may be found at +[BroadcastPayload](#Notification..BroadcastPayload). + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Notification](#Notification) ⇐ [Model](#Model) + * [new Notification(data)](#new_Notification_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Notification.unserialize) ⇒ [ObjectData](#Notification..ObjectData) + * [.validate(data)](#Notification.validate) ⇒ string + * _inner_ + * [~ArrayData](#Notification..ArrayData) : Array + * [~BroadcastPayload](#Notification..BroadcastPayload) : object + * [~Data](#Notification..Data) : [Notification](#Notification) \| [ObjectData](#Notification..ObjectData) \| [ArrayData](#Notification..ArrayData) + * [~ObjectData](#Notification..ObjectData) : object + + + +### new Notification(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Notification..Data) \| [Array.<Data>](#Notification..Data) | data | + + + +### notification.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Notification](#Notification) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### notification.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Notification](#Notification) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Notification.unserialize(data) ⇒ [ObjectData](#Notification..ObjectData) +**Kind**: static method of [Notification](#Notification) +**Returns**: [ObjectData](#Notification..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Notification..Data) \| [Array.<Data>](#Notification..Data) | data to convert to POJO | + + + +### Notification.validate(data) ⇒ string +Validates a given notification instance + +**Kind**: static method of [Notification](#Notification) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Notification..Data) \| [Array.<Data>](#Notification..Data) | instance(s) to validate | + + + +### Notification~ArrayData : Array +[Notification](#Notification) data in WSv2 array format. Suitable for passing to +[Notification](#Notification) to construct a model instance. + +**Kind**: inner typedef of [Notification](#Notification) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | mts | +| 1 | string | type | +| 2 | number | messageID | +| 4 | object | notifyInfo | +| 5 | number | code | +| 6 | string | status | +| 7 | string | text | + + + +### Notification~BroadcastPayload : object +Body of a broadcast (`ucm-*`) [Notification](#Notification)} which may be sent via +the WSv2 API. + +**Kind**: inner typedef of [Notification](#Notification) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| [message] | string | message to display | +| [type] | string | notification type, must be prefixed with 'ucm-*' for broadcasts | +| [level] | string | 'info', 'error', or 'success' | +| [image] | string | link to an image to be shown | +| [link] | string | URL the notification should forward too | +| [sound] | string | URL of sound to play | + + + +### Notification~Data : [Notification](#Notification) \| [ObjectData](#Notification..ObjectData) \| [ArrayData](#Notification..ArrayData) +[Notification](#Notification) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Notification](#Notification) + + +### Notification~ObjectData : object +[Notification](#Notification) data in plain object format. Suitable for passing to +[Notification](#Notification) to construct a model instance. + +**Kind**: inner typedef of [Notification](#Notification) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| mts | number | timestamp | +| type | string | type (i.e. 'ucm-*' for broadcasts) | +| messageID | number | message ID | +| notifyInfo | object | metadata, set by client for broadcasts | +| code | number | code | +| status | string | status (i.e. 'error') | +| text | string | notification text to display to user | + + + +## OrderBook ⇐ events.EventEmitter +High level OB model to automatically integrate WS updates & maintain sort + +**Kind**: global class +**Extends**: events.EventEmitter + +* [OrderBook](#OrderBook) ⇐ events.EventEmitter + * [new OrderBook(snap, [raw])](#new_OrderBook_new) + * _instance_ + * [.volBPSMid(bps)](#OrderBook+volBPSMid) ⇒ number + * [.checksum()](#OrderBook+checksum) ⇒ number + * [.updateFromSnapshot(snapshot)](#OrderBook+updateFromSnapshot) + * [.updateWith(entry)](#OrderBook+updateWith) ⇒ boolean + * [.topBid()](#OrderBook+topBid) ⇒ number + * [.topBidLevel()](#OrderBook+topBidLevel) ⇒ number + * [.topAsk()](#OrderBook+topAsk) ⇒ number + * [.topAskLevel()](#OrderBook+topAskLevel) ⇒ number + * [.midPrice()](#OrderBook+midPrice) ⇒ number + * [.spread()](#OrderBook+spread) ⇒ number + * [.bidAmount()](#OrderBook+bidAmount) ⇒ number + * [.askAmount()](#OrderBook+askAmount) ⇒ number + * [.getEntry(price)](#OrderBook+getEntry) ⇒ object + * [.toJS()](#OrderBook+toJS) ⇒ object + * _static_ + * [.checksumArr(arr, [raw])](#OrderBook.checksumArr) ⇒ number + * [.updateArrayOBWith(ob, entry, [raw])](#OrderBook.updateArrayOBWith) ⇒ boolean + * [.arrayOBMidPrice(ob, [raw])](#OrderBook.arrayOBMidPrice) ⇒ number + * [.unserialize(arr, [raw])](#OrderBook.unserialize) ⇒ object + * _inner_ + * [~AggregatedFundingPriceLevel](#OrderBook..AggregatedFundingPriceLevel) : object + * [~AggregatedPriceLevel](#OrderBook..AggregatedPriceLevel) : object + * [~ArrayData](#OrderBook..ArrayData) : [Array.<ArrayPriceLevel>](#OrderBook..ArrayPriceLevel) + * [~ArrayPriceLevel](#OrderBook..ArrayPriceLevel) : Array.<number> + * [~Data](#OrderBook..Data) : [OrderBook](#OrderBook) \| [ObjectData](#OrderBook..ObjectData) \| [ArrayData](#OrderBook..ArrayData) + * [~ObjectData](#OrderBook..ObjectData) : [Array.<ObjectPriceLevel>](#OrderBook..ObjectPriceLevel) + * [~ObjectPriceLevel](#OrderBook..ObjectPriceLevel) : [AggregatedFundingPriceLevel](#OrderBook..AggregatedFundingPriceLevel) \| [AggregatedPriceLevel](#OrderBook..AggregatedPriceLevel) \| [RawFundingPriceLevel](#OrderBook..RawFundingPriceLevel) \| [RawPriceLevel](#OrderBook..RawPriceLevel) + * [~RawFundingPriceLevel](#OrderBook..RawFundingPriceLevel) : object + * [~RawPriceLevel](#OrderBook..RawPriceLevel) : object + + + +### new OrderBook(snap, [raw]) +Initializes the order book with an existing snapshot (array form) + + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| snap | [Data](#OrderBook..Data) | | snapshot | +| [raw] | boolean | false | true for raw 'R0' order books | + + + +### orderBook.volBPSMid(bps) ⇒ number +Returns the total volume at n basis points from the mid price + +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - vol - total volume + +| Param | Type | Description | +| --- | --- | --- | +| bps | number | basis points from mid price | + + + +### orderBook.checksum() ⇒ number +Generates a crc-32 checksum of our current state. The checksum'ed string +itself is a concatenated list of the top 25 bids & asks, alternating. + +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - cs +**See**: http://blog.bitfinex.com/api/bitfinex-api-order-books-checksums + + +### orderBook.updateFromSnapshot(snapshot) +Sets bids/asks to those in the provided snapshot + +**Kind**: instance method of [OrderBook](#OrderBook) + +| Param | Type | Description | +| --- | --- | --- | +| snapshot | [ArrayData](#OrderBook..ArrayData) | snapshot | + + + +### orderBook.updateWith(entry) ⇒ boolean +Integrate an update packet (add, update, or remove a price level). Emits an +'update' event on success + +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: boolean - success - false if entry doesn't match OB + +| Param | Type | Description | +| --- | --- | --- | +| entry | Array | price level to update with | + + + +### orderBook.topBid() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - topBid - may be null + + +### orderBook.topBidLevel() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - topBidLevel - may be null + + +### orderBook.topAsk() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - topAsk - may be null + + +### orderBook.topAskLevel() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - topAskLevel - may be null + + +### orderBook.midPrice() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - price + + +### orderBook.spread() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - spread - top bid/ask difference + + +### orderBook.bidAmount() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - amount - total buy-side volume + + +### orderBook.askAmount() ⇒ number +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: number - amount - total sell-side volume + + +### orderBook.getEntry(price) ⇒ object +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: object - entry - unserialized, null if not found + +| Param | Type | Description | +| --- | --- | --- | +| price | number | price level to fetch | + + + +### orderBook.toJS() ⇒ object +**Kind**: instance method of [OrderBook](#OrderBook) +**Returns**: object - pojo + + +### OrderBook.checksumArr(arr, [raw]) ⇒ number +Like checksum(), but for raw array-format order books + +**Kind**: static method of [OrderBook](#OrderBook) +**Returns**: number - cs + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| arr | [ArrayData](#OrderBook..ArrayData) | | assumed sorted, `[topBid, bid, ..., topAsk, ask, ...]` | +| [raw] | boolean | false | true for raw 'R0' order books | + + + +### OrderBook.updateArrayOBWith(ob, entry, [raw]) ⇒ boolean +Modifies an array-format OB in place with an update entry. Maintains sort + +**Kind**: static method of [OrderBook](#OrderBook) +**Returns**: boolean - success - false if entry doesn't match OB + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| ob | [ArrayData](#OrderBook..ArrayData) | | array-format order book | +| entry | [ArrayPriceLevel](#OrderBook..ArrayPriceLevel) | | price level to update with | +| [raw] | boolean | false | true for raw 'R0' order books | + + + +### OrderBook.arrayOBMidPrice(ob, [raw]) ⇒ number +Finds the mid price of the provided array-format OB + +**Kind**: static method of [OrderBook](#OrderBook) +**Returns**: number - midPrice - null if book is empty + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| ob | [ArrayData](#OrderBook..ArrayData) | | orderbook | +| [raw] | boolean | false | true for `raw` books | + + + +### OrderBook.unserialize(arr, [raw]) ⇒ object +Converts an array order book entry or snapshot to an object, with 'price', +'count', and 'amount' keys on entries + +**Kind**: static method of [OrderBook](#OrderBook) +**Returns**: object - ob - either a map w/ bids & asks, or single entry object + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| arr | [ArrayData](#OrderBook..ArrayData) \| [ArrayPriceLevel](#OrderBook..ArrayPriceLevel) | | array format order book | +| [raw] | boolean | false | true for raw 'R0' order books | + + + +### OrderBook~AggregatedFundingPriceLevel : object +An aggregate (non-raw) [OrderBook](#OrderBook) **funding** ticker price level in +object format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rate | number | rate | +| period | number | period | +| amount | number | amount | +| count | number | count | + + + +### OrderBook~AggregatedPriceLevel : object +An aggregate (non-raw) [OrderBook](#OrderBook) price level in object format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| price | number | price | +| amount | number | amount | +| count | number | count | + + + +### OrderBook~ArrayData : [Array.<ArrayPriceLevel>](#OrderBook..ArrayPriceLevel) +[OrderBook](#OrderBook) data in WSv2 array format. Suitable for passing to +[OrderBook](#OrderBook) to construct a model instance. + +**Kind**: inner typedef of [OrderBook](#OrderBook) + + +### OrderBook~ArrayPriceLevel : Array.<number> +A single price level for an [OrderBook](#OrderBook) model, in WSv2 array format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) + + +### OrderBook~Data : [OrderBook](#OrderBook) \| [ObjectData](#OrderBook..ObjectData) \| [ArrayData](#OrderBook..ArrayData) +[OrderBook](#OrderBook) data either in WSv2 array or object format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) + + +### OrderBook~ObjectData : [Array.<ObjectPriceLevel>](#OrderBook..ObjectPriceLevel) +[OrderBook](#OrderBook) data as an array of price levels in object format. +Suitable for passing to [OrderBook](#OrderBook) to construct a model instance. + +**Kind**: inner typedef of [OrderBook](#OrderBook) + + +### OrderBook~ObjectPriceLevel : [AggregatedFundingPriceLevel](#OrderBook..AggregatedFundingPriceLevel) \| [AggregatedPriceLevel](#OrderBook..AggregatedPriceLevel) \| [RawFundingPriceLevel](#OrderBook..RawFundingPriceLevel) \| [RawPriceLevel](#OrderBook..RawPriceLevel) +A single price level for an [OrderBook](#OrderBook) model, in object format. +Contents vary depending between raw & standard order books, and between +trading & funding tickers. + +**Kind**: inner typedef of [OrderBook](#OrderBook) + + +### OrderBook~RawFundingPriceLevel : object +A raw [OrderBook](#OrderBook) **funding** price level in object format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| rate | number | rate | +| period | number | period | +| amount | number | amount | +| orderID | number | order ID | + + + +### OrderBook~RawPriceLevel : object +A raw [OrderBook](#OrderBook) price level in object format. + +**Kind**: inner typedef of [OrderBook](#OrderBook) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| price | number | price | +| amount | number | amount | +| orderID | number | order ID | + + + +## Order ⇐ [Model](#Model) +High level order model; provides methods for execution & can stay updated via +a WSv2 connection or used to execute as a rest payload + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Order](#Order) ⇐ [Model](#Model) + * [new Order([data], [apiInterface])](#new_Order_new) + * _instance_ + * [.toString()](#Order+toString) ⇒ string + * [.isOCO()](#Order+isOCO) ⇒ boolean + * [.isHidden()](#Order+isHidden) ⇒ boolean + * [.isPostOnly()](#Order+isPostOnly) ⇒ boolean + * [.includesVariableRates()](#Order+includesVariableRates) ⇒ boolean + * [.isPositionClose()](#Order+isPositionClose) ⇒ boolean + * [.isReduceOnly()](#Order+isReduceOnly) ⇒ boolean + * [.setOCO(v, [stopPrice], [cidOCO])](#Order+setOCO) ⇒ number + * [.setHidden(v)](#Order+setHidden) ⇒ number + * [.setPostOnly(v)](#Order+setPostOnly) ⇒ number + * [.setNoVariableRates(v)](#Order+setNoVariableRates) ⇒ number + * [.setPositionClose(v)](#Order+setPositionClose) ⇒ number + * [.setReduceOnly(v)](#Order+setReduceOnly) ⇒ number + * [.modifyFlag(flag, active)](#Order+modifyFlag) ⇒ number + * [.update(changes, [apiInterface])](#Order+update) ⇒ Promise + * [.toPreview()](#Order+toPreview) ⇒ [Preview](#Order..Preview) + * [.registerListeners([apiInterface])](#Order+registerListeners) + * [.removeListeners([apiInterface])](#Order+removeListeners) + * [.cbGID()](#Order+cbGID) ⇒ string + * [.submit([apiInterface])](#Order+submit) ⇒ Promise + * [.cancel([apiInterface])](#Order+cancel) ⇒ Promise + * [.recreate([apiInterface])](#Order+recreate) ⇒ Promise + * [.updateFrom(order)](#Order+updateFrom) + * [.getLastFillAmount()](#Order+getLastFillAmount) ⇒ number + * [.resetFilledAmount()](#Order+resetFilledAmount) + * [.getBaseCurrency()](#Order+getBaseCurrency) ⇒ string + * [.getQuoteCurrency()](#Order+getQuoteCurrency) ⇒ string + * [.getNotionalValue()](#Order+getNotionalValue) ⇒ number + * [.isPartiallyFilled()](#Order+isPartiallyFilled) ⇒ boolean + * [.toNewOrderPacket()](#Order+toNewOrderPacket) ⇒ [SubmitPayload](#Order..SubmitPayload) + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.flags](#Order.flags) : enum + * [.unserialize(data)](#Order.unserialize) ⇒ [ObjectData](#Order..ObjectData) + * [.getBaseCurrency(arr)](#Order.getBaseCurrency) ⇒ string + * [.getQuoteCurrency(arr)](#Order.getQuoteCurrency) ⇒ string + * [.validate(data)](#Order.validate) ⇒ string + * _inner_ + * [~ArrayData](#Order..ArrayData) : Array + * [~Data](#Order..Data) : [Order](#Order) \| [ObjectData](#Order..ObjectData) \| [ArrayData](#Order..ArrayData) + * [~ObjectData](#Order..ObjectData) : object + * [~Preview](#Order..Preview) : object + * [~SubmitPayload](#Order..SubmitPayload) : object + * [~Type](#Order..Type) : 'MARKET' \| 'EXCHANGE MARKET' \| 'LIMIT' \| 'EXCHANGE LIMIT' \| 'STOP' \| 'EXCHANGE STOP' \| 'TRAILING STOP' \| 'EXCHANGE TRAILING STOP' \| 'FOK' \| 'EXCHANGE FOK' \| 'STOP LIMIT' \| 'EXCHANGE STOP LIMIT' + + + +### new Order([data], [apiInterface]) + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| [data] | [Data](#Order..Data) | {} | order data | +| [apiInterface] | object | | saved for a later call to `registerListeners()`` | + +**Example** +```js +const debug = require('debug')('bfx:api:models:examples:order') +const { Order } = require('../') +const o = new Order({ + type: Order.type.EXCHANGE_LIMIT, + symbol: 'tBTCUSD', + amount: 0.05, + price: 10000, + hidden: true +}) + +debug('generated ws2 compatible new order packet:') +debug(JSON.stringify(o.toNewOrderPacket(), null, 2)) +``` + + +### order.toString() ⇒ string +Returns a string representation of the order + +**Kind**: instance method of [Order](#Order) +**Returns**: string - str +**Todo** + +- [ ] add verbose option to log all order information (TIF, etc) + + + +### order.isOCO() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - oco + + +### order.isHidden() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - hidden + + +### order.isPostOnly() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - postonly + + +### order.includesVariableRates() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - includesVR + + +### order.isPositionClose() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - posclose + + +### order.isReduceOnly() ⇒ boolean +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - reduceonly + + +### order.setOCO(v, [stopPrice], [cidOCO]) ⇒ number +Set the OCO flag and optionally update the stop price and OCO client ID. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | +| [stopPrice] | number | optional, defaults to current value | +| [cidOCO] | number | optional, defaults to current value | + + + +### order.setHidden(v) ⇒ number +Update the hidden flag value. If hidden and the order is inserted into +the order book, it will not be shown to other users or available via the +API. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | + + + +### order.setPostOnly(v) ⇒ number +Update the post-only flag value. If post-only and the order would +immediately fill, the order is automatically cancelled. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | + + + +### order.setNoVariableRates(v) ⇒ number +Update the no-variable-rates flag value. Limits orders on margin from +taking funding with variable rates. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | + + + +### order.setPositionClose(v) ⇒ number +Update the position-close flag value. If set, the order is cancelled if it +would not close an open position. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | + + + +### order.setReduceOnly(v) ⇒ number +Update the reduce-only flag. If set and the order would open a new +position, or increase the size of an existing position, it is +automatically cancelled. + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| v | boolean | flag value | + + + +### order.modifyFlag(flag, active) ⇒ number +Updates a specific flag + +**Kind**: instance method of [Order](#Order) +**Returns**: number - finalFlags + +| Param | Type | Description | +| --- | --- | --- | +| flag | number | flag value | +| active | boolean | active status | + + + +### order.update(changes, [apiInterface]) ⇒ Promise +Send an order update packet to the WS server, and update local state. This +updates the order atomically without changing its position in the queue for +its price level. + +Rejects with an error if an attempt is made to apply a delta to a missing +amount. + +**Kind**: instance method of [Order](#Order) +**Returns**: Promise - p - resolves on ws2 confirmation or rest response + +| Param | Type | Description | +| --- | --- | --- | +| changes | object | changeset to apply to this order | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | optional ws or rest, defaults to internal instance | + +**Example** +```js +const ws = new WSv2({ ... }) + +await ws.open() +await ws.auth() + +const o = new Order({ ... }, ws) + +await o.submit() +await o.update({ price: '2.0' }) // update price +await o.update({ delta: '18.0' }) // update amount with delta + +console.log(o.toString())) // inspect order +``` + + +### order.toPreview() ⇒ [Preview](#Order..Preview) +Returns a POJO that can be used as a preview order in Honey Framework +algorithmic orders. + +**Kind**: instance method of [Order](#Order) +**Returns**: [Preview](#Order..Preview) - preview + + +### order.registerListeners([apiInterface]) +Registers for updates/persistence on the specified ws2 instance. + +**Kind**: instance method of [Order](#Order) + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | object | optional, defaults to internal ws | + + + +### order.removeListeners([apiInterface]) +Removes update listeners from the specified ws2 instance. +Will fail if rest interface is provided. + +**Kind**: instance method of [Order](#Order) + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | optional ws defaults to internal ws | + + + +### order.cbGID() ⇒ string +Return the callback group ID for the order, used to bind listeners on +an API interface. + +**Kind**: instance method of [Order](#Order) +**Returns**: string - cbGID + + +### order.submit([apiInterface]) ⇒ Promise +Submit the order + +**Kind**: instance method of [Order](#Order) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | defaults to internal ws | + + + +### order.cancel([apiInterface]) ⇒ Promise +Cancel the order if open + +**Kind**: instance method of [Order](#Order) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | defaults to internal ws | + + + +### order.recreate([apiInterface]) ⇒ Promise +Equivalent to calling cancel() followed by submit() + +**Kind**: instance method of [Order](#Order) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | defaults to internal ws | + + + +### order.updateFrom(order) +Updates order information from the provided order. + +**Kind**: instance method of [Order](#Order) +**Throws**: + +- Error fails if the order ID/CID/GID do not match + + +| Param | Type | Description | +| --- | --- | --- | +| order | [Order](#Order) | order to update from | + + + +### order.getLastFillAmount() ⇒ number +Query the amount that was filled on the last order update + +**Kind**: instance method of [Order](#Order) +**Returns**: number - amount + + +### order.resetFilledAmount() +Resets the last amount, so getLastFillAmount() returns 0 + +**Kind**: instance method of [Order](#Order) +**See** + +- [Order~getLastFillAmount](Order~getLastFillAmount) +- [Order~isPartiallyFilled](Order~isPartiallyFilled) + + + +### order.getBaseCurrency() ⇒ string +Returns the base currency of the order. + +**Kind**: instance method of [Order](#Order) +**Returns**: string - currency + + +### order.getQuoteCurrency() ⇒ string +Returns the quote currency of the order. + +**Kind**: instance method of [Order](#Order) +**Returns**: string - currency + + +### order.getNotionalValue() ⇒ number +Returns the notional value of the order + +**Kind**: instance method of [Order](#Order) +**Returns**: number - value + + +### order.isPartiallyFilled() ⇒ boolean +Indicates if the order is partially filled, based on the original and +current amounts. + +**Kind**: instance method of [Order](#Order) +**Returns**: boolean - isPartiallyFilled +**See**: modules:bfx-api-node-models.Order~resetFilledAmount + + +### order.toNewOrderPacket() ⇒ [SubmitPayload](#Order..SubmitPayload) +Creates an order map that can be passed to the `on` command. + +**Kind**: instance method of [Order](#Order) +**Returns**: [SubmitPayload](#Order..SubmitPayload) - o +**Example** +```js +const ws = new WSv2({ apiKey: '...', apiSecret: '...' }) +await ws.open() +await ws.auth() + +const o = new Order({ + type: 'MARKET' + symbol: 'tLEOUSD', + amount: -6, +}) + +ws.send([0, 'on', null, o.toNewOrderPacket()]) +``` + + +### order.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Order](#Order) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### order.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Order](#Order) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Order.flags : enum +Valid order flag values + +**Kind**: static enum of [Order](#Order) +**Read only**: true +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| OCO | number | | Order cancels order (16384). Requires `priceAuxLimit` and `cidOCO` to be set, resolved to `price_oco_stop` and `cid_oco` on the generated `on` packet. | +| POSTONLY | number | | Post-only (4096) orders are cancelled if they would execute immediately | +| HIDDEN | number | | Hidden (64) orders are inserted into the book, not visible to other traders, and always pay the **taker** fee. | +| NO_VR | number | | Excludes variable rate (524288) funding | +| POS_CLOSE | number | | Position-close (512) orders are cancelled if they would not close an open position. | +| REDUCE_ONLY | number | | Reduce-only (1024) orders are cancelled if they would open or increase the size of an existing position. | + + + +### Order.unserialize(data) ⇒ [ObjectData](#Order..ObjectData) +**Kind**: static method of [Order](#Order) +**Returns**: [ObjectData](#Order..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Order..Data) \| [Array.<Data>](#Order..Data) | data to convert to POJO | + + + +### Order.getBaseCurrency(arr) ⇒ string +Get the base currency for an order in WSv2 array format. + +**Kind**: static method of [Order](#Order) +**Returns**: string - currency - base currency from symbol + +| Param | Type | Description | +| --- | --- | --- | +| arr | [ArrayData](#Order..ArrayData) | order in ws2 array format | + + + +### Order.getQuoteCurrency(arr) ⇒ string +Get the quote currency for an order in WSv2 array format. + +**Kind**: static method of [Order](#Order) +**Returns**: string - currency - quote currency from symbol + +| Param | Type | Description | +| --- | --- | --- | +| arr | [ArrayData](#Order..ArrayData) | order in ws2 array format | + + + +### Order.validate(data) ⇒ string +Validates a given order instance + +**Kind**: static method of [Order](#Order) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Order..Data) \| [Array.<Data>](#Order..Data) | instance(s) to validate | + + + +### Order~ArrayData : Array +[Order](#Order) data in WSv2 array format. Suitable for passing to +[Order](#Order) to construct a model instance. + +**Kind**: inner typedef of [Order](#Order) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | number | gid | +| 2 | number | cid | +| 3 | string | symbol | +| 4 | number | mtsCreate | +| 5 | number | mtsUpdate | +| 6 | number | amount | +| 7 | number | amountOrig | +| 8 | [Type](#Order..Type) | type | +| 9 | [Type](#Order..Type) | typePrev | +| 10 | number | mtsTIF | +| 12 | number | flags | +| 13 | string | status | +| 16 | number | price | +| 17 | number | priceAvg | +| 18 | number | priceTrailing | +| 19 | number | priceAuxLimit | +| 23 | number | notify | +| 24 | number | hidden | +| 25 | number | placedId | +| 28 | string | routing | +| 31 | object | meta | + + + +### Order~Data : [Order](#Order) \| [ObjectData](#Order..ObjectData) \| [ArrayData](#Order..ArrayData) +[Order](#Order) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Order](#Order) + + +### Order~ObjectData : object +[Order](#Order) data in plain object format. Suitable for passing to +[Order](#Order) to construct a model instance. + +**Kind**: inner typedef of [Order](#Order) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | ID | +| [gid] | number | group ID | +| [cid] | number | client ID | +| symbol | string | symbol | +| [mtsCreate] | number | creation timestamp | +| [mtsUpdate] | number | last update timestamp | +| amount | string | remaining order amount | +| [amountOrig] | string | original/initial order amount | +| [type] | [Type](#Order..Type) | order type | +| [typePrev] | [Type](#Order..Type) | previous type | +| [mtsTIF] | number | TIF timestamp, if set | +| [flags] | number | order flags | +| [status] | string | current order status | +| price | string | order price | +| [priceAvg] | string | average execution price | +| [priceTrailing] | string | trailing distance for TRAILING STOP orders | +| [priceAuxLimit] | string | stop price for STOP LIMIT and OCO orders | +| [notify] | number \| boolean | notify flag | +| [placedId] | number | placed ID | +| [affiliateCode] | string | affiliate code | +| [lev] | number | leverage | + + + +### Order~Preview : object +Preview of an [Order](#Order) for display in an UI, prior to submission + +**Kind**: inner typedef of [Order](#Order) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| gid | number | group id | +| cid | number | client ID | +| symbol | string | symbol | +| amount | number | amount | +| type | [Type](#Order..Type) | type | +| [price] | number | price, optional for `MARKET` orders | +| notify | number | notify flag | +| flags | number | flags | +| [lev] | number | leverage | + + + +### Order~SubmitPayload : object +A set of parameters describing an atomic order that can be sent via the WSv2 +API to submit it. + +**Kind**: inner typedef of [Order](#Order) +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [gid] | number | | group ID | +| [cid] | number | | client ID | +| symbol | string | | symbol | +| type | [Type](#Order..Type) | | type | +| amount | number | | amount | +| [price] | number | | optional for `MARKET` orders | +| [price_trailing] | number | | required for `TRAILING STOP` orders | +| [price_aux_limit] | number | | required for `STOP LIMIT` and `OCO` orders | +| [price_oco_stop] | number | | required for `OCO` orders | +| [cid_oco] | number | | required for `OCO` orders | +| [lev] | number | | leverage | +| [flags] | number | 0 | flags | +| [meta] | object | {} | metadata | +| [meta.aff_code] | string | | affiliate code | +| [tif] | number | | time in force | + + + +### Order~Type : 'MARKET' \| 'EXCHANGE MARKET' \| 'LIMIT' \| 'EXCHANGE LIMIT' \| 'STOP' \| 'EXCHANGE STOP' \| 'TRAILING STOP' \| 'EXCHANGE TRAILING STOP' \| 'FOK' \| 'EXCHANGE FOK' \| 'STOP LIMIT' \| 'EXCHANGE STOP LIMIT' +Valid atomic order types, see the [Order](#Order) model. + +**Kind**: inner typedef of [Order](#Order) + + +## Position ⇐ [Model](#Model) +Position model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Position](#Position) ⇐ [Model](#Model) + * [new Position(data, [apiInterface])](#new_Position_new) + * _instance_ + * [.claim([apiInterface])](#Position+claim) ⇒ Promise + * [.close([apiInterface])](#Position+close) ⇒ Promise + * [.orderToClose([apiInterface])](#Position+orderToClose) ⇒ Promise + * [.toString()](#Position+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Position.unserialize) ⇒ [ObjectData](#Position..ObjectData) + * [.validate(data)](#Position.validate) ⇒ string + * _inner_ + * [~ArrayData](#Position..ArrayData) : Array + * [~Data](#Position..Data) : [Position](#Position) \| [ObjectData](#Position..ObjectData) \| [ArrayData](#Position..ArrayData) + * [~ObjectData](#Position..ObjectData) : object + + + +### new Position(data, [apiInterface]) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Position..Data) \| [Array.<Data>](#Position..Data) | data | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | rest or websocket object that's capable of submitting position changes | + + + +### position.claim([apiInterface]) ⇒ Promise +Claim the position + +**Kind**: instance method of [Position](#Position) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bfx-api-node-rest.RESTv2 | api | + + + +### position.close([apiInterface]) ⇒ Promise +Close the position + +**Kind**: instance method of [Position](#Position) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bfx-api-node-rest.RESTv2 | api | + + + +### position.orderToClose([apiInterface]) ⇒ Promise +Generate an order that can be used to close the position. + +**Kind**: instance method of [Position](#Position) +**Returns**: Promise - p + +| Param | Type | Description | +| --- | --- | --- | +| [apiInterface] | bitfinex-api-node.WSv2 \| bfx-api-node-rest.RESTv2 | provided to returned `Order` instance | + + + +### position.toString() ⇒ string +Returns a string representation of the position. + +**Kind**: instance method of [Position](#Position) +**Returns**: string - str + + +### position.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Position](#Position) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### position.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Position](#Position) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Position.unserialize(data) ⇒ [ObjectData](#Position..ObjectData) +**Kind**: static method of [Position](#Position) +**Returns**: [ObjectData](#Position..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Position..Data) \| [Array.<Data>](#Position..Data) | data to convert to POJO | + + + +### Position.validate(data) ⇒ string +Validates a given position instance + +**Kind**: static method of [Position](#Position) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Position..Data) \| [Array.<Data>](#Position..Data) | instance(s) to validate | + + + +### Position~ArrayData : Array +[Position](#Position) data in WSv2 array format. Suitable for passing to +[Position](#Position) to construct a model instance. + +**Kind**: inner typedef of [Position](#Position) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | symbol | +| 1 | string | status | +| 2 | number | amount | +| 3 | string | basePrice | +| 4 | string | marginFunding | +| 5 | string | marginFundingType | +| 6 | string | pl | +| 7 | string | plPerc | +| 8 | string | liquidationPrice | +| 9 | number | leverage | +| 11 | number | id | +| 12 | number | mtsCreate | +| 13 | number | mtsUpdate | +| 15 | string | type | +| 17 | number | collateral | +| 18 | number | collateralMin | +| 19 | object | meta | + + + +### Position~Data : [Position](#Position) \| [ObjectData](#Position..ObjectData) \| [ArrayData](#Position..ArrayData) +[Position](#Position) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Position](#Position) + + +### Position~ObjectData : object +[Position](#Position) data in plain object format. Suitable for passing to +[Position](#Position) to construct a model instance. + +**Kind**: inner typedef of [Position](#Position) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| mtsCreate | number | creation timestamp | +| mtsUpdate | number | last update timestamp | +| symbol | string | symbol | +| status | string | status | +| type | string | type | +| amount | string | amount | +| basePrice | string | base price | +| marginFunding | string | margin funding | +| marginFundingType | string | margin funding type | +| pl | string | profit/loss | +| plPerc | string | profit/loss as percentage | +| liquidationPrice | string | liquidation price | +| leverage | number | leverage | +| collateral | number | collateral | +| collateralMin | number | minimum collateral to maintain position | +| meta | object | metadata | + + + +## PublicPulseProfile ⇐ [Model](#Model) +Public PulseProfile model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [PublicPulseProfile](#PublicPulseProfile) ⇐ [Model](#Model) + * [new PublicPulseProfile(data)](#new_PublicPulseProfile_new) + * _instance_ + * [.toString()](#PublicPulseProfile+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#PublicPulseProfile.unserialize) ⇒ [ObjectData](#PublicPulseProfile..ObjectData) + * [.validate(data)](#PublicPulseProfile.validate) ⇒ string + * _inner_ + * [~ArrayData](#PublicPulseProfile..ArrayData) : Array + * [~Data](#PublicPulseProfile..Data) : [PublicPulseProfile](#PublicPulseProfile) \| [ObjectData](#PublicPulseProfile..ObjectData) \| [ArrayData](#PublicPulseProfile..ArrayData) + * [~ObjectData](#PublicPulseProfile..ObjectData) : object + + + +### new PublicPulseProfile(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PublicPulseProfile..Data) \| [Array.<Data>](#PublicPulseProfile..Data) | data | + + + +### publicPulseProfile.toString() ⇒ string +**Kind**: instance method of [PublicPulseProfile](#PublicPulseProfile) +**Returns**: string - str + + +### publicPulseProfile.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [PublicPulseProfile](#PublicPulseProfile) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### publicPulseProfile.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [PublicPulseProfile](#PublicPulseProfile) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### PublicPulseProfile.unserialize(data) ⇒ [ObjectData](#PublicPulseProfile..ObjectData) +**Kind**: static method of [PublicPulseProfile](#PublicPulseProfile) +**Returns**: [ObjectData](#PublicPulseProfile..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PublicPulseProfile..Data) \| [Array.<Data>](#PublicPulseProfile..Data) | data to convert to POJO | + + + +### PublicPulseProfile.validate(data) ⇒ string +Validates a given public pulse profile instance + +**Kind**: static method of [PublicPulseProfile](#PublicPulseProfile) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PublicPulseProfile..Data) \| [Array.<Data>](#PublicPulseProfile..Data) | models to validate | + + + +### PublicPulseProfile~ArrayData : Array +[PublicPulseProfile](#PublicPulseProfile) data in WSv2 array format. Suitable for passing +to [PublicPulseProfile](#PublicPulseProfile) instance. + +**Kind**: inner typedef of [PublicPulseProfile](#PublicPulseProfile) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | id | +| 1 | number | mtsCreate | +| 3 | string | nickname | +| 5 | string | picture | +| 6 | string | text | +| 9 | string | twitterHandle | + + + +### PublicPulseProfile~Data : [PublicPulseProfile](#PublicPulseProfile) \| [ObjectData](#PublicPulseProfile..ObjectData) \| [ArrayData](#PublicPulseProfile..ArrayData) +[PublicPulseProfile](#PublicPulseProfile) data either in WSv2 array or object format. + +**Kind**: inner typedef of [PublicPulseProfile](#PublicPulseProfile) + + +### PublicPulseProfile~ObjectData : object +[PublicPulseProfile](#PublicPulseProfile) data in plain object format. Suitable for passing +to [PublicPulseProfile](#PublicPulseProfile) to construct a model instance. + +**Kind**: inner typedef of [PublicPulseProfile](#PublicPulseProfile) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | string | pulse User ID | +| mtsCreate | number | creation timestamp | +| nickname | string | profile nickname | +| picture | string | profile picture | +| text | string | profile bio | +| twitterHandle | string | profile twitter handle | + + + +## PublicTrade ⇐ [Model](#Model) +Public Trade model, supporting both funding & ordinary trades + +**Kind**: global class +**Extends**: [Model](#Model) +**Todo** + +- [ ] Extract type defs (varying format) + + +* [PublicTrade](#PublicTrade) ⇐ [Model](#Model) + * [new PublicTrade(data)](#new_PublicTrade_new) + * _instance_ + * [.toString()](#PublicTrade+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#PublicTrade.unserialize) ⇒ object + * [.validate(data)](#PublicTrade.validate) ⇒ string + + + +### new PublicTrade(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | object \| Array | public trade data | + + + +### publicTrade.toString() ⇒ string +**Kind**: instance method of [PublicTrade](#PublicTrade) +**Returns**: string - str + + +### publicTrade.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [PublicTrade](#PublicTrade) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### publicTrade.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [PublicTrade](#PublicTrade) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### PublicTrade.unserialize(data) ⇒ object +**Kind**: static method of [PublicTrade](#PublicTrade) +**Returns**: object - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | data to convert to POJO | + + + +### PublicTrade.validate(data) ⇒ string +Validates a given public trade instance + +**Kind**: static method of [PublicTrade](#PublicTrade) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| [Array.<PublicTrade>](#PublicTrade) \| [PublicTrade](#PublicTrade) \| Array | models to validate | + + + +## PulseMessage ⇐ [Model](#Model) +Private PulseMessage model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [PulseMessage](#PulseMessage) ⇐ [Model](#Model) + * [new PulseMessage(data)](#new_PulseMessage_new) + * _instance_ + * [.serialize()](#PulseMessage+serialize) ⇒ Array + * [.toString()](#PulseMessage+toString) ⇒ string + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#PulseMessage.unserialize) ⇒ [ObjectData](#PulseMessage..ObjectData) + * [.validate(data)](#PulseMessage.validate) ⇒ string + * _inner_ + * [~ArrayData](#PulseMessage..ArrayData) : Array + * [~Data](#PulseMessage..Data) : [PulseMessage](#PulseMessage) \| [ObjectData](#PulseMessage..ObjectData) \| [ArrayData](#PulseMessage..ArrayData) + * [~ObjectData](#PulseMessage..ObjectData) : object + + + +### new PulseMessage(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PulseMessage..Data) \| [Array.<Data>](#PulseMessage..Data) | data | + + + +### pulseMessage.serialize() ⇒ Array +Return an array representation of this model + +**Kind**: instance method of [PulseMessage](#PulseMessage) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### pulseMessage.toString() ⇒ string +**Kind**: instance method of [PulseMessage](#PulseMessage) +**Returns**: string - str + + +### pulseMessage.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [PulseMessage](#PulseMessage) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### PulseMessage.unserialize(data) ⇒ [ObjectData](#PulseMessage..ObjectData) +**Kind**: static method of [PulseMessage](#PulseMessage) +**Returns**: [ObjectData](#PulseMessage..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PulseMessage..Data) \| [Array.<Data>](#PulseMessage..Data) | data to convert | + + + +### PulseMessage.validate(data) ⇒ string +Validates a given public pulse profile instance + +**Kind**: static method of [PulseMessage](#PulseMessage) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#PulseMessage..Data) \| [Array.<Data>](#PulseMessage..Data) | instance(s) to validate | + + + +### PulseMessage~ArrayData : Array +[PulseMessage](#PulseMessage) data in WSv2 array format. Suitable for passing to +[PulseMessage](#PulseMessage) to construct a model instance. + +**Kind**: inner typedef of [PulseMessage](#PulseMessage) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | id | +| 1 | number | mts | +| 3 | string | userID | +| 5 | string | title | +| 6 | string | content | +| 9 | number | isPin | +| 10 | number | isPublic | +| 12 | string | tags | +| 13 | string | attachments | +| 15 | number | likes | +| 16 | number | userLiked | + + + +### PulseMessage~Data : [PulseMessage](#PulseMessage) \| [ObjectData](#PulseMessage..ObjectData) \| [ArrayData](#PulseMessage..ArrayData) +[PulseMessage](#PulseMessage) data either in WSv2 array or object format. + +**Kind**: inner typedef of [PulseMessage](#PulseMessage) + + +### PulseMessage~ObjectData : object +[PulseMessage](#PulseMessage) data in plain object format. Suitable for passing to +[PulseMessage](#PulseMessage) to construct a model instance. + +**Kind**: inner typedef of [PulseMessage](#PulseMessage) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | string | pulse message ID | +| mts | number | millisecond timestamp | +| userID | string | pulse User ID | +| title | string | title of the pulse message | +| content | string | content of the pulse message | +| isPin | number | 1 if the message is pinned, 0 if it is not pinned | +| isPublic | number | 1 if the message is public, 0 if it is not public | +| tags | string | tags used in the message | +| attachments | string | attachments used in the message | +| likes | number | number of likes | +| userLiked | number | flag to show if the private user liked the pulse | + + + +## StatusMessagesDeriv ⇐ [Model](#Model) +Derivatives Status Message model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [StatusMessagesDeriv](#StatusMessagesDeriv) ⇐ [Model](#Model) + * [new StatusMessagesDeriv(data)](#new_StatusMessagesDeriv_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#StatusMessagesDeriv.unserialize) ⇒ [ObjectData](#StatusMessagesDeriv..ObjectData) + * [.validate(data)](#StatusMessagesDeriv.validate) ⇒ string + * _inner_ + * [~ArrayData](#StatusMessagesDeriv..ArrayData) : Array + * [~Data](#StatusMessagesDeriv..Data) : [StatusMessagesDeriv](#StatusMessagesDeriv) \| [ObjectData](#StatusMessagesDeriv..ObjectData) \| [ArrayData](#StatusMessagesDeriv..ArrayData) + * [~ObjectData](#StatusMessagesDeriv..ObjectData) : object + + + +### new StatusMessagesDeriv(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#StatusMessagesDeriv..Data) \| [Array.<Data>](#StatusMessagesDeriv..Data) | data | + + + +### statusMessagesDeriv.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### statusMessagesDeriv.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### StatusMessagesDeriv.unserialize(data) ⇒ [ObjectData](#StatusMessagesDeriv..ObjectData) +**Kind**: static method of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Returns**: [ObjectData](#StatusMessagesDeriv..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#StatusMessagesDeriv..Data) \| [Array.<Data>](#StatusMessagesDeriv..Data) | data to convert to POJO | + + + +### StatusMessagesDeriv.validate(data) ⇒ string +Validates a given public trade instance + +**Kind**: static method of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#StatusMessagesDeriv..Data) \| [Array.<Data>](#StatusMessagesDeriv..Data) | models to validate | + + + +### StatusMessagesDeriv~ArrayData : Array +[StatusMessagesDeriv](#StatusMessagesDeriv) data in WSv2 array format. Suitable for passing +to [StatusMessagesDeriv](#StatusMessagesDeriv) to construct a model instance. + +**Kind**: inner typedef of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | key | +| 1 | number | timestamp | +| 3 | number | price | +| 4 | number | priceSpot | +| 6 | number | fundBal | +| 9 | number | fundingAccrued | +| 10 | number | fundingStep | + + + +### StatusMessagesDeriv~Data : [StatusMessagesDeriv](#StatusMessagesDeriv) \| [ObjectData](#StatusMessagesDeriv..ObjectData) \| [ArrayData](#StatusMessagesDeriv..ArrayData) +[StatusMessagesDeriv](#StatusMessagesDeriv) data either in WSv2 array or object format. + +**Kind**: inner typedef of [StatusMessagesDeriv](#StatusMessagesDeriv) + + +### StatusMessagesDeriv~ObjectData : object +[StatusMessagesDeriv](#StatusMessagesDeriv) data in plain object format. Suitable for +passing to [StatusMessagesDeriv](#StatusMessagesDeriv) to construct a model instance. + +**Kind**: inner typedef of [StatusMessagesDeriv](#StatusMessagesDeriv) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| key | string | key | +| timestamp | number | timestamp | +| price | string | price | +| priceSpot | string | spot price | +| fundBal | string | funding balance | +| fundingAccrued | string | accrued funding | +| fundingStep | string | funding step | + + + +## Trade ⇐ [Model](#Model) +Private Trade model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Trade](#Trade) ⇐ [Model](#Model) + * [new Trade(data)](#new_Trade_new) + * _instance_ + * [.toString()](#Trade+toString) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Trade.unserialize) ⇒ [ObjectData](#Trade..ObjectData) + * [.validate(data)](#Trade.validate) ⇒ string + * _inner_ + * [~ArrayData](#Trade..ArrayData) : Array + * [~Data](#Trade..Data) : [Trade](#Trade) \| [ObjectData](#Trade..ObjectData) \| [ArrayData](#Trade..ArrayData) + * [~ObjectData](#Trade..ObjectData) : object + + + +### new Trade(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Trade..Data) \| [Array.<Data>](#Trade..Data) | data | + + + +### trade.toString() ⇒ string +**Kind**: instance method of [Trade](#Trade) +**Returns**: string - str + + +### trade.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Trade](#Trade) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### trade.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Trade](#Trade) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Trade.unserialize(data) ⇒ [ObjectData](#Trade..ObjectData) +**Kind**: static method of [Trade](#Trade) +**Returns**: [ObjectData](#Trade..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Trade..Data) \| [Array.<Data>](#Trade..Data) | data to convert to POJO | + + + +### Trade.validate(data) ⇒ string +Validates a given trade instance + +**Kind**: static method of [Trade](#Trade) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Trade..Data) \| [Array.<Data>](#Trade..Data) | instance(s) to validate | + + + +### Trade~ArrayData : Array +[Trade](#Trade) data in WSv2 array format. Suitable for passing to +[Trade](#Trade) to construct a model instance. + +**Kind**: inner typedef of [Trade](#Trade) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | symbol | +| 2 | number | mtsCreate | +| 3 | number | orderID | +| 4 | string | execAmount | +| 5 | string | execPrice | +| 6 | string | orderType | +| 7 | number | orderPrice | +| 8 | number | maker | +| 9 | number | fee | +| 10 | string | feeCurrency | + + + +### Trade~Data : [Trade](#Trade) \| [ObjectData](#Trade..ObjectData) \| [ArrayData](#Trade..ArrayData) +[Trade](#Trade) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Trade](#Trade) + + +### Trade~ObjectData : object +[Trade](#Trade) data in plain object format. Suitable for passing to +[Trade](#Trade) to construct a model instance. + +**Kind**: inner typedef of [Trade](#Trade) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| symbol | string | symbol | +| mtsCreate | number | creation timestamp | +| orderID | number | order ID | +| execAmount | string | executed amount | +| execPrice | string | execution price | +| orderType | string | order type | +| orderPrice | string | order price | +| maker | number \| boolean | maker flag | +| fee | string | fee amount | +| feeCurrency | string | fee currency | + + + +## TradingTickerHist ⇐ [Model](#Model) +Historical Trading Ticker model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [TradingTickerHist](#TradingTickerHist) ⇐ [Model](#Model) + * [new TradingTickerHist(data)](#new_TradingTickerHist_new) + * _instance_ + * [.quote()](#TradingTickerHist+quote) ⇒ string + * [.base()](#TradingTickerHist+base) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#TradingTickerHist.unserialize) ⇒ [ObjectData](#TradingTickerHist..ObjectData) + * [.validate(data)](#TradingTickerHist.validate) ⇒ string + * _inner_ + * [~ArrayData](#TradingTickerHist..ArrayData) : Array + * [~Data](#TradingTickerHist..Data) : [TradingTickerHist](#TradingTickerHist) \| [ObjectData](#TradingTickerHist..ObjectData) \| [ArrayData](#TradingTickerHist..ArrayData) + * [~ObjectData](#TradingTickerHist..ObjectData) : object + + + +### new TradingTickerHist(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTickerHist..Data) \| [Array.<Data>](#TradingTickerHist..Data) | data | + + + +### tradingTickerHist.quote() ⇒ string +Quote currency for the ticker + +**Kind**: instance method of [TradingTickerHist](#TradingTickerHist) +**Returns**: string - quoteCurrency + + +### tradingTickerHist.base() ⇒ string +Base currency for the ticker. + +**Kind**: instance method of [TradingTickerHist](#TradingTickerHist) +**Returns**: string - baseCurrency + + +### tradingTickerHist.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [TradingTickerHist](#TradingTickerHist) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### tradingTickerHist.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [TradingTickerHist](#TradingTickerHist) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### TradingTickerHist.unserialize(data) ⇒ [ObjectData](#TradingTickerHist..ObjectData) +**Kind**: static method of [TradingTickerHist](#TradingTickerHist) +**Returns**: [ObjectData](#TradingTickerHist..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTickerHist..Data) \| [Array.<Data>](#TradingTickerHist..Data) | data to convert to POJO | + + + +### TradingTickerHist.validate(data) ⇒ string +Validates a given historical trading ticker instance + +**Kind**: static method of [TradingTickerHist](#TradingTickerHist) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTickerHist..Data) \| [Array.<Data>](#TradingTickerHist..Data) | models to validate | + + + +### TradingTickerHist~ArrayData : Array +[TradingTickerHist](#TradingTickerHist) data in WSv2 array format. Suitable for passing to +[TradingTickerHist](#TradingTickerHist) to construct a model instance. + +**Kind**: inner typedef of [TradingTickerHist](#TradingTickerHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | symbol | +| 1 | number | bid | +| 3 | number | ask | +| 12 | number | mtsUpdate | + + + +### TradingTickerHist~Data : [TradingTickerHist](#TradingTickerHist) \| [ObjectData](#TradingTickerHist..ObjectData) \| [ArrayData](#TradingTickerHist..ArrayData) +[TradingTickerHist](#TradingTickerHist) data either in WSv2 array or object format. + +**Kind**: inner typedef of [TradingTickerHist](#TradingTickerHist) + + +### TradingTickerHist~ObjectData : object +[TradingTickerHist](#TradingTickerHist) data in plain object format. Suitable for passing +to [TradingTickerHist](#TradingTickerHist) to construct a model instance. + +**Kind**: inner typedef of [TradingTickerHist](#TradingTickerHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| symbol | string | symbol | +| bid | number | best bid | +| ask | number | best ask | +| mtsUpdate | number | timestamp | + + + +## TradingTicker ⇐ [Model](#Model) +Trading Ticker model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [TradingTicker](#TradingTicker) ⇐ [Model](#Model) + * [new TradingTicker(data)](#new_TradingTicker_new) + * _instance_ + * [.quote()](#TradingTicker+quote) ⇒ string + * [.base()](#TradingTicker+base) ⇒ string + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#TradingTicker.unserialize) ⇒ [ObjectData](#TradingTicker..ObjectData) + * [.validate(data)](#TradingTicker.validate) ⇒ string + * _inner_ + * [~ArrayData](#TradingTicker..ArrayData) : Array + * [~Data](#TradingTicker..Data) : [TradingTicker](#TradingTicker) \| [ObjectData](#TradingTicker..ObjectData) \| [ArrayData](#TradingTicker..ArrayData) + * [~ObjectData](#TradingTicker..ObjectData) : object + + + +### new TradingTicker(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTicker..Data) \| [Array.<Data>](#TradingTicker..Data) | data | + + + +### tradingTicker.quote() ⇒ string +Quote currency of the ticker + +**Kind**: instance method of [TradingTicker](#TradingTicker) +**Returns**: string - quoteCurrency + + +### tradingTicker.base() ⇒ string +Base currency of the ticker + +**Kind**: instance method of [TradingTicker](#TradingTicker) +**Returns**: string - baseCurrency + + +### tradingTicker.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [TradingTicker](#TradingTicker) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### tradingTicker.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [TradingTicker](#TradingTicker) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### TradingTicker.unserialize(data) ⇒ [ObjectData](#TradingTicker..ObjectData) +**Kind**: static method of [TradingTicker](#TradingTicker) +**Returns**: [ObjectData](#TradingTicker..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTicker..Data) \| [Array.<Data>](#TradingTicker..Data) | data to convert to POJO | + + + +### TradingTicker.validate(data) ⇒ string +Validates a given trading ticker instance + +**Kind**: static method of [TradingTicker](#TradingTicker) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#TradingTicker..Data) \| [Array.<Data>](#TradingTicker..Data) | instance(s) to validate | + + + +### TradingTicker~ArrayData : Array +[TradingTicker](#TradingTicker) data in WSv2 array format. Suitable for passing to +[TradingTicker](#TradingTicker) to construct a model instance. + +**Kind**: inner typedef of [TradingTicker](#TradingTicker) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | symbol | +| 1 | number | bid | +| 2 | number | bidSize | +| 3 | number | ask | +| 4 | number | askSize | +| 5 | number | dailyChange | +| 6 | number | dailyChangePerc | +| 7 | number | lastPrice | +| 8 | number | volume | +| 9 | number | high | +| 10 | number | low | + + + +### TradingTicker~Data : [TradingTicker](#TradingTicker) \| [ObjectData](#TradingTicker..ObjectData) \| [ArrayData](#TradingTicker..ArrayData) +[TradingTicker](#TradingTicker) data either in WSv2 array or object format. + +**Kind**: inner typedef of [TradingTicker](#TradingTicker) + + +### TradingTicker~ObjectData : object +[TradingTicker](#TradingTicker) data in plain object format. Suitable for passing to +[TradingTicker](#TradingTicker) to construct a model instance. + +**Kind**: inner typedef of [TradingTicker](#TradingTicker) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| symbol | string | symbol | +| bid | number | best bid | +| bidSize | number | total bid size | +| ask | number | best ask | +| askSize | number | total ask size | +| dailyChange | number | change in last 24h period | +| dailyChangePerc | number | change in last 24h period as percent | +| lastPrice | number | last price | +| volume | number | volume in last 24h period | +| high | number | highest price in last 24h period | +| low | number | lowest price in last 24h period | + + + +## UserInfo ⇐ [Model](#Model) +User Info model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [UserInfo](#UserInfo) ⇐ [Model](#Model) + * [new UserInfo(data)](#new_UserInfo_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#UserInfo.unserialize) ⇒ [ObjectData](#UserInfo..ObjectData) + * [.validate(data)](#UserInfo.validate) ⇒ string + * _inner_ + * [~ArrayData](#UserInfo..ArrayData) : Array + * [~Data](#UserInfo..Data) : [UserInfo](#UserInfo) \| [ObjectData](#UserInfo..ObjectData) \| [ArrayData](#UserInfo..ArrayData) + * [~ObjectData](#UserInfo..ObjectData) : object + + + +### new UserInfo(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#UserInfo..Data) \| [Array.<Data>](#UserInfo..Data) | data | + + + +### userInfo.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [UserInfo](#UserInfo) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### userInfo.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [UserInfo](#UserInfo) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### UserInfo.unserialize(data) ⇒ [ObjectData](#UserInfo..ObjectData) +**Kind**: static method of [UserInfo](#UserInfo) +**Returns**: [ObjectData](#UserInfo..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#UserInfo..Data) \| [Array.<Data>](#UserInfo..Data) | data to convert to POJO | + + + +### UserInfo.validate(data) ⇒ string +Validates a given historical trading ticker instance + +**Kind**: static method of [UserInfo](#UserInfo) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#UserInfo..Data) \| [Array.<Data>](#UserInfo..Data) | instance(s) to validate | + + + +### UserInfo~ArrayData : Array +[UserInfo](#UserInfo) data in WSv2 array format. Suitable for passing to +[UserInfo](#UserInfo) to construct a model instance. + +**Kind**: inner typedef of [UserInfo](#UserInfo) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | number | id | +| 1 | string | email | +| 2 | string | username | +| 7 | number | timezone | + + + +### UserInfo~Data : [UserInfo](#UserInfo) \| [ObjectData](#UserInfo..ObjectData) \| [ArrayData](#UserInfo..ArrayData) +[UserInfo](#UserInfo) data either in WSv2 array or object format. + +**Kind**: inner typedef of [UserInfo](#UserInfo) + + +### UserInfo~ObjectData : object +[UserInfo](#UserInfo) data in plain object format. Suitable for passing to +[UserInfo](#UserInfo) to construct a model instance. + +**Kind**: inner typedef of [UserInfo](#UserInfo) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | number | id | +| email | string | email | +| username | string | username | +| timezone | number | timezone as UTC offset | + + + +## WalletHist ⇐ [Model](#Model) +Historical Wallet Update model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [WalletHist](#WalletHist) ⇐ [Model](#Model) + * [new WalletHist(data)](#new_WalletHist_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#WalletHist.unserialize) ⇒ [ObjectData](#WalletHist..ObjectData) + * [.validate(data)](#WalletHist.validate) ⇒ string + * _inner_ + * [~ArrayData](#WalletHist..ArrayData) : Array + * [~Data](#WalletHist..Data) : [WalletHist](#WalletHist) \| [ObjectData](#WalletHist..ObjectData) \| [ArrayData](#WalletHist..ArrayData) + * [~ObjectData](#WalletHist..ObjectData) : object + + + +### new WalletHist(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#WalletHist..Data) \| [Array.<Data>](#WalletHist..Data) | data | + + + +### walletHist.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [WalletHist](#WalletHist) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### walletHist.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [WalletHist](#WalletHist) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### WalletHist.unserialize(data) ⇒ [ObjectData](#WalletHist..ObjectData) +**Kind**: static method of [WalletHist](#WalletHist) +**Returns**: [ObjectData](#WalletHist..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#WalletHist..Data) \| [Array.<Data>](#WalletHist..Data) | data to convert to POJO | + + + +### WalletHist.validate(data) ⇒ string +Validates a given historical wallet instance + +**Kind**: static method of [WalletHist](#WalletHist) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#WalletHist..Data) \| [Array.<Data>](#WalletHist..Data) | instance(s) to validate | + + + +### WalletHist~ArrayData : Array +[WalletHist](#WalletHist) data in WSv2 array format. Suitable for passing to +[WalletHist](#WalletHist) to construct a model instance. + +**Kind**: inner typedef of [WalletHist](#WalletHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | type | +| 1 | string | currency | +| 2 | number | balance | +| 3 | number | unsettledInterest | +| 4 | number | balanceAvailable | +| 6 | number | mtsUpdate | + + + +### WalletHist~Data : [WalletHist](#WalletHist) \| [ObjectData](#WalletHist..ObjectData) \| [ArrayData](#WalletHist..ArrayData) +[WalletHist](#WalletHist) data either in WSv2 array or object format. + +**Kind**: inner typedef of [WalletHist](#WalletHist) + + +### WalletHist~ObjectData : object +[WalletHist](#WalletHist) data in plain object format. Suitable for passing to +[WalletHist](#WalletHist) to construct a model instance. + +**Kind**: inner typedef of [WalletHist](#WalletHist) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| type | string | type (i.e. deposit) | +| currency | string | currency | +| balance | number | balance | +| unsettledInterest | number | unsettled interest | +| balanceAvailable | number | available balance | +| mtsUpdate | number | timestamp | + + + +## Wallet ⇐ [Model](#Model) +Wallet model + +**Kind**: global class +**Extends**: [Model](#Model) + +* [Wallet](#Wallet) ⇐ [Model](#Model) + * [new Wallet(data)](#new_Wallet_new) + * _instance_ + * [.serialize()](#Model+serialize) ⇒ Array + * [.toJS()](#Model+toJS) ⇒ object + * _static_ + * [.unserialize(data)](#Wallet.unserialize) ⇒ [ObjectData](#Wallet..ObjectData) + * [.validate(data)](#Wallet.validate) ⇒ string + * _inner_ + * [~ArrayData](#Wallet..ArrayData) : Array + * [~Data](#Wallet..Data) : [Wallet](#Wallet) \| [ObjectData](#Wallet..ObjectData) \| [ArrayData](#Wallet..ArrayData) + * [~ObjectData](#Wallet..ObjectData) : object + + + +### new Wallet(data) + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Wallet..Data) \| [Array.<Data>](#Wallet..Data) | data | + + + +### wallet.serialize() ⇒ Array +Converts this model to array-format and returns the result + +**Kind**: instance method of [Wallet](#Wallet) +**Overrides**: [serialize](#Model+serialize) +**Returns**: Array - arr + + +### wallet.toJS() ⇒ object +Converts this model to object-format and returns the result + +**Kind**: instance method of [Wallet](#Wallet) +**Overrides**: [toJS](#Model+toJS) +**Returns**: object - pojo + + +### Wallet.unserialize(data) ⇒ [ObjectData](#Wallet..ObjectData) +**Kind**: static method of [Wallet](#Wallet) +**Returns**: [ObjectData](#Wallet..ObjectData) - pojo + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Wallet..Data) \| [Array.<Data>](#Wallet..Data) | data to convert to POJO | + + + +### Wallet.validate(data) ⇒ string +Validates a given wallet instance + +**Kind**: static method of [Wallet](#Wallet) +**Returns**: string - error - null if instance is valid + +| Param | Type | Description | +| --- | --- | --- | +| data | [Data](#Wallet..Data) \| [Array.<Data>](#Wallet..Data) | instance(s) to validate | + + + +### Wallet~ArrayData : Array +[Wallet](#Wallet) data in WSv2 array format. Suitable for passing to +[Wallet](#Wallet) to construct a model instance. + +**Kind**: inner typedef of [Wallet](#Wallet) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| 0 | string | type | +| 1 | string | currency | +| 2 | number | balance | +| 3 | number | unsettledInterest | +| 4 | number | balanceAvailable | +| 5 | string | description | +| 6 | object | meta | + + + +### Wallet~Data : [Wallet](#Wallet) \| [ObjectData](#Wallet..ObjectData) \| [ArrayData](#Wallet..ArrayData) +[Wallet](#Wallet) data either in WSv2 array or object format. + +**Kind**: inner typedef of [Wallet](#Wallet) + + +### Wallet~ObjectData : object +[Wallet](#Wallet) data in plain object format. Suitable for passing to +[Wallet](#Wallet) to construct a model instance. + +**Kind**: inner typedef of [Wallet](#Wallet) +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| type | string | wallet type (i.e. deposit) | +| currency | string | wallet currency | +| balance | number | total balance | +| unsettledInterest | number | unsettled interest | +| balanceAvailable | number | available balance | + + + +## isCollection(data) ⇒ boolean +Checks if the provided data is a collection of models + +**Kind**: global function +**Returns**: boolean - isCollection + +| Param | Type | Description | +| --- | --- | --- | +| data | Array.<object> \| object \| Array.<Array> \| Array | packet to analyse | + diff --git a/docs/scripts/collapse.js b/docs/scripts/collapse.js deleted file mode 100644 index 327039f..0000000 --- a/docs/scripts/collapse.js +++ /dev/null @@ -1,20 +0,0 @@ -function hideAllButCurrent(){ - //by default all submenut items are hidden - //but we need to rehide them for search - document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) { - parent.style.display = "none"; - }); - - //only current page (if it exists) should be opened - var file = window.location.pathname.split("/").pop().replace(/\.html/, ''); - document.querySelectorAll("nav > ul > li > a").forEach(function(parent) { - var href = parent.attributes.href.value.replace(/\.html/, ''); - if (file === href) { - parent.parentNode.querySelectorAll("ul li").forEach(function(elem) { - elem.style.display = "block"; - }); - } - }); -} - -hideAllButCurrent(); \ No newline at end of file diff --git a/docs/scripts/linenumber.js b/docs/scripts/linenumber.js deleted file mode 100644 index 8d52f7e..0000000 --- a/docs/scripts/linenumber.js +++ /dev/null @@ -1,25 +0,0 @@ -/*global document */ -(function() { - var source = document.getElementsByClassName('prettyprint source linenums'); - var i = 0; - var lineNumber = 0; - var lineId; - var lines; - var totalLines; - var anchorHash; - - if (source && source[0]) { - anchorHash = document.location.hash.substring(1); - lines = source[0].getElementsByTagName('li'); - totalLines = lines.length; - - for (; i < totalLines; i++) { - lineNumber++; - lineId = 'line' + lineNumber; - lines[i].id = lineId; - if (lineId === anchorHash) { - lines[i].className += ' selected'; - } - } - } -})(); diff --git a/docs/scripts/nav.js b/docs/scripts/nav.js deleted file mode 100644 index 6dd8313..0000000 --- a/docs/scripts/nav.js +++ /dev/null @@ -1,12 +0,0 @@ -function scrollToNavItem() { - var path = window.location.href.split('/').pop().replace(/\.html/, ''); - document.querySelectorAll('nav a').forEach(function(link) { - var href = link.attributes.href.value.replace(/\.html/, ''); - if (path === href) { - link.scrollIntoView({block: 'center'}); - return; - } - }) - } - - scrollToNavItem(); diff --git a/docs/scripts/polyfill.js b/docs/scripts/polyfill.js deleted file mode 100644 index 44b4c92..0000000 --- a/docs/scripts/polyfill.js +++ /dev/null @@ -1,4 +0,0 @@ -//IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/ -if (typeof(NodeList.prototype.forEach)!==typeof(alert)){ - NodeList.prototype.forEach=Array.prototype.forEach; -} \ No newline at end of file diff --git a/docs/scripts/prettify/Apache-License-2.0.txt b/docs/scripts/prettify/Apache-License-2.0.txt deleted file mode 100644 index d645695..0000000 --- a/docs/scripts/prettify/Apache-License-2.0.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/docs/scripts/prettify/lang-css.js b/docs/scripts/prettify/lang-css.js deleted file mode 100644 index 041e1f5..0000000 --- a/docs/scripts/prettify/lang-css.js +++ /dev/null @@ -1,2 +0,0 @@ -PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", -/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/scripts/prettify/prettify.js b/docs/scripts/prettify/prettify.js deleted file mode 100644 index eef5ad7..0000000 --- a/docs/scripts/prettify/prettify.js +++ /dev/null @@ -1,28 +0,0 @@ -var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; -(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= -[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), -l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, -q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, -q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, -"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), -a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} -for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], -"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], -H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], -J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ -I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), -["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", -/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), -["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", -hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= -!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p ul > li:not(.level-hide)").forEach(function(elem) { - elem.style.display = "block"; - }); - - if (typeof hideAllButCurrent === "function"){ - //let's do what ever collapse wants to do - hideAllButCurrent(); - } else { - //menu by default should be opened - document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { - elem.style.display = "block"; - }); - } - } else { - //we are searching - document.documentElement.setAttribute(searchAttr, ''); - - //show all parents - document.querySelectorAll("nav > ul > li").forEach(function(elem) { - elem.style.display = "block"; - }); - //hide all results - document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { - elem.style.display = "none"; - }); - //show results matching filter - document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) { - if (!contains(elem.parentNode, search)) { - return; - } - elem.parentNode.style.display = "block"; - }); - //hide parents without children - document.querySelectorAll("nav > ul > li").forEach(function(parent) { - var countSearchA = 0; - parent.querySelectorAll("a").forEach(function(elem) { - if (contains(elem, search)) { - countSearchA++; - } - }); - - var countUl = 0; - var countUlVisible = 0; - parent.querySelectorAll("ul").forEach(function(ulP) { - // count all elements that match the search - if (contains(ulP, search)) { - countUl++; - } - - // count all visible elements - var children = ulP.children - for (i=0; i ul { - padding: 0 10px; -} - -nav > ul > li > a { - color: #606; - margin-top: 10px; -} - -nav ul ul a { - color: hsl(207, 1%, 60%); - border-left: 1px solid hsl(207, 10%, 86%); -} - -nav ul ul a, -nav ul ul a:active { - padding-left: 20px -} - -nav h2 { - font-size: 13px; - margin: 10px 0 0 0; - padding: 0; -} - -nav > h2 > a { - margin: 10px 0 -10px; - color: #606 !important; -} - -footer { - color: hsl(0, 0%, 28%); - margin-left: 250px; - display: block; - padding: 15px; - font-style: italic; - font-size: 90%; -} - -.ancestors { - color: #999 -} - -.ancestors a { - color: #999 !important; -} - -.clear { - clear: both -} - -.important { - font-weight: bold; - color: #950B02; -} - -.yes-def { - text-indent: -1000px -} - -.type-signature { - color: #CA79CA -} - -.type-signature:last-child { - color: #eee; -} - -.name, .signature { - font-family: Consolas, Monaco, 'Andale Mono', monospace -} - -.signature { - color: #fc83ff; -} - -.details { - margin-top: 6px; - border-left: 2px solid #DDD; - line-height: 20px; - font-size: 14px; -} - -.details dt { - width: auto; - float: left; - padding-left: 10px; -} - -.details dd { - margin-left: 70px; - margin-top: 6px; - margin-bottom: 6px; -} - -.details ul { - margin: 0 -} - -.details ul { - list-style-type: none -} - -.details pre.prettyprint { - margin: 0 -} - -.details .object-value { - padding-top: 0 -} - -.description { - margin-bottom: 1em; - margin-top: 1em; -} - -.code-caption { - font-style: italic; - font-size: 107%; - margin: 0; -} - -.prettyprint { - font-size: 14px; - overflow: auto; -} - -.prettyprint.source { - width: inherit; - line-height: 18px; - display: block; - background-color: #0d152a; - color: #aeaeae; -} - -.prettyprint code { - line-height: 18px; - display: block; - background-color: #0d152a; - color: #4D4E53; -} - -.prettyprint > code { - padding: 15px; -} - -.prettyprint .linenums code { - padding: 0 15px -} - -.prettyprint .linenums li:first-of-type code { - padding-top: 15px -} - -.prettyprint code span.line { - display: inline-block -} - -.prettyprint.linenums { - padding-left: 70px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.prettyprint.linenums ol { - padding-left: 0 -} - -.prettyprint.linenums li { - border-left: 3px #34446B solid; -} - -.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { - background-color: #34446B; -} - -.prettyprint.linenums li * { - -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - user-select: text; -} - -.prettyprint.linenums li code:empty:after { - content:""; - display:inline-block; - width:0px; -} - -table { - border-spacing: 0; - border: 1px solid #ddd; - border-collapse: collapse; - border-radius: 3px; - box-shadow: 0 1px 3px rgba(0,0,0,0.1); - width: 100%; - font-size: 14px; - margin: 1em 0; -} - -td, th { - margin: 0px; - text-align: left; - vertical-align: top; - padding: 10px; - display: table-cell; -} - -thead tr, thead tr { - background-color: #fff; - font-weight: bold; - border-bottom: 1px solid #ddd; -} - -.params .type { - white-space: nowrap; -} - -.params code { - white-space: pre; -} - -.params td, .params .name, .props .name, .name code { - color: #4D4E53; - font-family: Consolas, Monaco, 'Andale Mono', monospace; - font-size: 100%; -} - -.params td { - border-top: 1px solid #eee -} - -.params td.description > p:first-child, .props td.description > p:first-child { - margin-top: 0; - padding-top: 0; -} - -.params td.description > p:last-child, .props td.description > p:last-child { - margin-bottom: 0; - padding-bottom: 0; -} - -span.param-type, .params td .param-type, .param-type dd { - color: #606; - font-family: Consolas, Monaco, 'Andale Mono', monospace -} - -.param-type dt, .param-type dd { - display: inline-block -} - -.param-type { - margin: 14px 0; -} - -.disabled { - color: #454545 -} - -/* navicon button */ -.navicon-button { - display: none; - position: relative; - padding: 2.0625rem 1.5rem; - transition: 0.25s; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - opacity: .8; -} -.navicon-button .navicon:before, .navicon-button .navicon:after { - transition: 0.25s; -} -.navicon-button:hover { - transition: 0.5s; - opacity: 1; -} -.navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after { - transition: 0.25s; -} -.navicon-button:hover .navicon:before { - top: .825rem; -} -.navicon-button:hover .navicon:after { - top: -.825rem; -} - -/* navicon */ -.navicon { - position: relative; - width: 2.5em; - height: .3125rem; - background: #000; - transition: 0.3s; - border-radius: 2.5rem; -} -.navicon:before, .navicon:after { - display: block; - content: ""; - height: .3125rem; - width: 2.5rem; - background: #000; - position: absolute; - z-index: -1; - transition: 0.3s 0.25s; - border-radius: 1rem; -} -.navicon:before { - top: .625rem; -} -.navicon:after { - top: -.625rem; -} - -/* open */ -.nav-trigger:checked + label:not(.steps) .navicon:before, -.nav-trigger:checked + label:not(.steps) .navicon:after { - top: 0 !important; -} - -.nav-trigger:checked + label .navicon:before, -.nav-trigger:checked + label .navicon:after { - transition: 0.5s; -} - -/* Minus */ -.nav-trigger:checked + label { - -webkit-transform: scale(0.75); - transform: scale(0.75); -} - -/* × and + */ -.nav-trigger:checked + label.plus .navicon, -.nav-trigger:checked + label.x .navicon { - background: transparent; -} - -.nav-trigger:checked + label.plus .navicon:before, -.nav-trigger:checked + label.x .navicon:before { - -webkit-transform: rotate(-45deg); - transform: rotate(-45deg); - background: #FFF; -} - -.nav-trigger:checked + label.plus .navicon:after, -.nav-trigger:checked + label.x .navicon:after { - -webkit-transform: rotate(45deg); - transform: rotate(45deg); - background: #FFF; -} - -.nav-trigger:checked + label.plus { - -webkit-transform: scale(0.75) rotate(45deg); - transform: scale(0.75) rotate(45deg); -} - -.nav-trigger:checked ~ nav { - left: 0 !important; -} - -.nav-trigger:checked ~ .overlay { - display: block; -} - -.nav-trigger { - position: fixed; - top: 0; - clip: rect(0, 0, 0, 0); -} - -.overlay { - display: none; - position: fixed; - top: 0; - bottom: 0; - left: 0; - right: 0; - width: 100%; - height: 100%; - background: hsla(0, 0%, 0%, 0.5); - z-index: 1; -} - -/* nav level */ -.level-hide { - display: none; -} -html[data-search-mode] .level-hide { - display: block; -} - - -@media only screen and (max-width: 680px) { - body { - overflow-x: hidden; - } - - nav { - background: #FFF; - width: 250px; - height: 100%; - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: -250px; - z-index: 3; - padding: 0 10px; - transition: left 0.2s; - } - - .navicon-button { - display: inline-block; - position: fixed; - top: 1.5em; - right: 0; - z-index: 2; - } - - #main { - width: 100%; - } - - #main h1.page-title { - margin: 1em 0; - } - - #main section { - padding: 0; - } - - footer { - margin-left: 0; - } -} - -/** Add a '#' to static members */ -[data-type="member"] a::before { - content: '#'; - display: inline-block; - margin-left: -14px; - margin-right: 5px; -} - -#disqus_thread{ - margin-left: 30px; -} - -@font-face { - font-family: 'Montserrat'; - font-style: normal; - font-weight: 400; - src: url('../fonts/Montserrat/Montserrat-Regular.eot'); /* IE9 Compat Modes */ - src: url('../fonts/Montserrat/Montserrat-Regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('../fonts/Montserrat/Montserrat-Regular.woff2') format('woff2'), /* Super Modern Browsers */ - url('../fonts/Montserrat/Montserrat-Regular.woff') format('woff'), /* Pretty Modern Browsers */ - url('../fonts/Montserrat/Montserrat-Regular.ttf') format('truetype'); /* Safari, Android, iOS */ -} - -@font-face { - font-family: 'Montserrat'; - font-style: normal; - font-weight: 700; - src: url('../fonts/Montserrat/Montserrat-Bold.eot'); /* IE9 Compat Modes */ - src: url('../fonts/Montserrat/Montserrat-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('../fonts/Montserrat/Montserrat-Bold.woff2') format('woff2'), /* Super Modern Browsers */ - url('../fonts/Montserrat/Montserrat-Bold.woff') format('woff'), /* Pretty Modern Browsers */ - url('../fonts/Montserrat/Montserrat-Bold.ttf') format('truetype'); /* Safari, Android, iOS */ -} - -@font-face { - font-family: 'Source Sans Pro'; - src: url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot'); - src: url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2') format('woff2'), - url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff') format('woff'), - url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf') format('truetype'), - url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg#source_sans_proregular') format('svg'); - font-weight: 400; - font-style: normal; -} - -@font-face { - font-family: 'Source Sans Pro'; - src: url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot'); - src: url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2') format('woff2'), - url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff') format('woff'), - url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf') format('truetype'), - url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg#source_sans_prolight') format('svg'); - font-weight: 300; - font-style: normal; - -} \ No newline at end of file diff --git a/docs/styles/prettify.css b/docs/styles/prettify.css deleted file mode 100644 index d9521ec..0000000 --- a/docs/styles/prettify.css +++ /dev/null @@ -1,79 +0,0 @@ -.pln { - color: #ddd; -} - -/* string content */ -.str { - color: #61ce3c; -} - -/* a keyword */ -.kwd { - color: #fbde2d; -} - -/* a comment */ -.com { - color: #aeaeae; -} - -/* a type name */ -.typ { - color: #8da6ce; -} - -/* a literal value */ -.lit { - color: #fbde2d; -} - -/* punctuation */ -.pun { - color: #ddd; -} - -/* lisp open bracket */ -.opn { - color: #000000; -} - -/* lisp close bracket */ -.clo { - color: #000000; -} - -/* a markup tag name */ -.tag { - color: #8da6ce; -} - -/* a markup attribute name */ -.atn { - color: #fbde2d; -} - -/* a markup attribute value */ -.atv { - color: #ddd; -} - -/* a declaration */ -.dec { - color: #EF5050; -} - -/* a variable name */ -.var { - color: #c82829; -} - -/* a function name */ -.fun { - color: #4271ae; -} - -/* Specify class=linenums on a pre to get line numbering */ -ol.linenums { - margin-top: 0; - margin-bottom: 0; -} diff --git a/index.js b/index.js index 3541ac5..d1688a3 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,33 @@ 'use strict' +/** + * This module contains model classes for working with the data structures + * returned by the Bitfinex {@link external:bfx-api-node-rest|REST} & + * {@link external:bitfinex-api-node|WebSocket} APIs. The models can all be + * initialized with an array-format payload as returned by an API call, and can + * be unserialized back to the array format when needed. + * + * Some models, such as {@link Order} and {@link OrderBook} provide higher + * level methods which operate on the underlying data sets. + * + * All models provide `serialize()` and `unserialize()` methods, which convert + * to/from array-format payloads respectively. All model constructors can take + * either array-format payloads, or objects/other model instances. A helper + * `toJS()` method is also provided for converting models to plain JS objects + * (POJOs). + * + * @license MIT + * @module bfx-api-node-models + */ + +/** + * @external bitfinex-api-node + * @see https://github.com/bitfinexcom/bitfinex-api-node + */ + +/** + * @external bfx-api-node-rest + * @see https://github.com/bitfinexcom/bfx-api-node-rest + */ + module.exports = require('./lib') diff --git a/lib/alert.js b/lib/alert.js index ef7f936..07c802c 100644 --- a/lib/alert.js +++ b/lib/alert.js @@ -12,22 +12,21 @@ const fields = { /** * Price alert model + * + * @class + * @augments Model */ class Alert extends Model { /** - * @param {object|Array} data - alert data - * @param {string} data.key - alert key - * @param {string} data.type - alert type - * @param {string} data.symbol - configured symbol - * @param {string} data.price - configured price + * @param {Alert~Data|Alert~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Alert~Data|Alert~Data[]} data - data to convert to POJO + * @returns {Alert~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -36,9 +35,9 @@ class Alert extends Model { /** * Validates a given alert instance * - * TODO: validate type (get a list) + * @todo validate type (get a list) * - * @param {object[]|object|Alert[]|Alert|Array} data - instance to validate + * @param {Alert~Data|Alert~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/balance_info.js b/lib/balance_info.js index 44fa244..cc66add 100644 --- a/lib/balance_info.js +++ b/lib/balance_info.js @@ -8,20 +8,22 @@ const fields = { } /** - * Wallet balance information model + * Balance information model + * + * @class + * @augments Model */ class BalanceInfo extends Model { /** - * @param {object|Array} data - balance info data - * @param {number} data.amount - total balance - * @param {number} data.amountNet - available balance + * @param {BalanceInfo~Data|BalanceInfo~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO + * @param {BalanceInfo~Data|BalanceInfo~Data[]} data - data to convert to + * POJO * @returns {object} pojo */ static unserialize (data) { @@ -31,8 +33,8 @@ class BalanceInfo extends Model { /** * Validates a given balance info instance * - * @param {object[]|object|BalanceInfo[]|BalanceInfo|Array} data - instance - * to validate + * @param {BalanceInfo~Data|BalanceInfo~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/candle.js b/lib/candle.js index 1e80ebc..8f8fd10 100644 --- a/lib/candle.js +++ b/lib/candle.js @@ -14,24 +14,21 @@ const fields = { /** * OHLCV Candle model + * + * @class + * @augments Model */ class Candle extends Model { /** - * @param {object|Array} data - source payloud - * @param {number} data.mts - timestamp - * @param {number} data.open - open price - * @param {number} data.close - close price - * @param {number} data.high - highest price in the period - * @param {number} data.low - lowest price in the period - * @param {number} data.volume - total volume for the period + * @param {Candle~Data|Candle~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Candle~Data|Candle~Data[]} data - data to convert to POJO + * @returns {Candle~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -40,7 +37,7 @@ class Candle extends Model { /** * Validates a given Candle instance * - * @param {object[]|object|Candle[]|Candle|Array} data - instance to validate + * @param {Candle~Data|Candle~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/change_log.js b/lib/change_log.js index b9c8ddd..4336e9c 100644 --- a/lib/change_log.js +++ b/lib/change_log.js @@ -3,7 +3,6 @@ const stringValidator = require('./validators/string') const dateValidator = require('./validators/date') const Model = require('./model') - const fields = { mtsCreate: 0, log: 2, @@ -12,22 +11,21 @@ const fields = { } /** - * ChangeLog model + * Change log model + * + * @class + * @augments Model */ class ChangeLog extends Model { /** - * @param {object|Array} data - log data - * @param {number} data.mtsCreate - timestamp - * @param {string} data.log - log data - * @param {string} data.ip - ip - * @param {string} data.userAgent - user agent + * @param {ChangeLog~Data|ChangeLog~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO + * @param {ChangeLog~Data|ChangeLog~Data[]} data - data to convert to POJO * @returns {object} pojo */ static unserialize (data) { @@ -37,7 +35,7 @@ class ChangeLog extends Model { /** * Validates a given wallet instance * - * @param {object[]|object|ChangeLog[]|ChangeLog|Array} data - instance to validate + * @param {ChangeLog~Data|ChangeLog~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/currency.js b/lib/currency.js index 5b14ce2..5afcc14 100644 --- a/lib/currency.js +++ b/lib/currency.js @@ -4,7 +4,6 @@ const numberValidator = require('./validators/number') const stringValidator = require('./validators/string') const currencyValidator = require('./validators/currency') const Model = require('./model') - const fields = { id: 0, name: 1, @@ -15,23 +14,21 @@ const fields = { /** * Currency model + * + * @class + * @augments Model */ class Currency extends Model { /** - * @param {object|Array} data - currency data - * @param {string} data.id - id - * @param {string} data.name - currency name ('Ethereum') - * @param {string} data.pool - pool - * @param {string} data.exporer - explorer URL - * @param {string} data.symbol - symbol ('ETH') + * @param {Currency~Data|Currency~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Currency~Data|Currency~Data[]} data - data to convert to POJO + * @returns {Currency~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -40,7 +37,7 @@ class Currency extends Model { /** * Validates a given currency instance * - * @param {object[]|object|Currency[]|Currency|Array} data - instance to validate + * @param {Currency~Data|Currency~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_credit.js b/lib/funding_credit.js index a424ab7..8ffb294 100644 --- a/lib/funding_credit.js +++ b/lib/funding_credit.js @@ -34,45 +34,32 @@ const fields = { /** * Funding Credit model + * + * @class + * @augments Model */ class FundingCredit extends Model { /** - * @param {object|Array} data - funding credit data - * @param {number} data.id - id - * @param {string} data.symbol - symbol - * @param {number} data.side - side - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.mtsUpdate - last update timestamp - * @param {number} data.mtsOpening - open timestamp - * @param {number} data.mtsLastPayout - last payout timestamp - * @param {number} data.amount - remaining amount - * @param {number} data.flags - flags - * @param {number} data.status - current status - * @param {number} data.rate - rate - * @param {number} data.rateReal - rate - * @param {number} data.period - period - * @param {string} data.positionPair - position pair - * @param {number|boolean} data.notify - notify flag - * @param {number|boolean} data.hidden - hidden flag - * @param {number|boolean} data.renew - renew flag - * @param {number|boolean} data.noClose - no-close flag + * @param {FundingCredit~Data|FundingCredit~Data[]} data - data */ constructor (data = {}) { super({ data, fields, boolFields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingCredit~Data|FundingCredit~Data[]} data - data to convert to + * POJO + * @returns {FundingCredit~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields, boolFields }) } /** - * Validates a given fuding credit instance + * Validates a given funding credit instance * - * @param {object[]|object|FundingCredit[]|FundingCredit|Array} data - instance to validate + * @param {FundingCredit~Data|FundingCredit~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_info.js b/lib/funding_info.js index 450d9fd..5e81366 100644 --- a/lib/funding_info.js +++ b/lib/funding_info.js @@ -10,6 +10,11 @@ const Model = require('./model') /** * Account Funding Info model + * + * @todo Extract type defs (varying format) + * + * @class + * @augments Model */ class FundingInfo extends Model { /** @@ -69,11 +74,23 @@ class FundingInfo extends Model { /** * Validates a given funding info instance * - * @param {object[]|object|FundingInfo[]|FundingInfo|Array} data - instance to validate + * @param {object[]|object|FundingInfo[]|FundingInfo} data - data to validate * @returns {string} error - null if instance is valid */ static validate (data) { - const { symbol, yieldLoan, yieldLend, durationLoan, durationLend } = this + if (isCollection(data)) { + for (let i = 0; i < data.length; i += 1) { + const err = FundingInfo.validate(data[i]) + + if (err) { + return err + } + } + + return null + } + + const { symbol, yieldLoan, yieldLend, durationLoan, durationLend } = data return ( symbolValidator(symbol) || diff --git a/lib/funding_loan.js b/lib/funding_loan.js index 39a7758..ae1cd29 100644 --- a/lib/funding_loan.js +++ b/lib/funding_loan.js @@ -33,35 +33,22 @@ const fields = { /** * Funding Loan model + * + * @class + * @augments Model */ class FundingLoan extends Model { /** - * @param {object|Array} data - funding loan data - * @param {number} data.id - id - * @param {string} data.symbol - symbol - * @param {number} data.side - side - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.mtsUpdate - last update timestamp - * @param {number} data.mtsOpening - open timestamp - * @param {number} data.mtsLastPayout - last payout timestamp - * @param {number} data.amount - amount - * @param {number} data.flags - flags - * @param {number} data.status - status - * @param {number} data.rate - rate - * @param {number} data.rateReal - rate real - * @param {number} data.period - period flag - * @param {number|boolean} data.notify - notify flag - * @param {number|boolean} data.hidden - hidden flag - * @param {number|boolean} data.renew - renew flag - * @param {number|boolean} data.noClose - no-close flag + * @param {FundingLoan~Data|FundingLoan~Data[]} data - data */ constructor (data = {}) { super({ data, fields, boolFields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingLoan~Data|FundingLoan~Data[]} data - data to convert to + * POJO + * @returns {FundingLoan~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields, boolFields }) @@ -70,7 +57,8 @@ class FundingLoan extends Model { /** * Validates a given funding loan instance * - * @param {object[]|object|FundingLoan[]|FundingLoan|Array} data - instance to validate + * @param {FundingLoan~Data|FundingLoan~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_offer.js b/lib/funding_offer.js index 29654ad..e0a1092 100644 --- a/lib/funding_offer.js +++ b/lib/funding_offer.js @@ -35,25 +35,13 @@ const fields = { /** * Funding Offer model + * + * @class + * @augments Model */ class FundingOffer extends Model { /** - * @param {object|Array} data - funding offer data - * @param {number} data.id - id - * @param {string} data.symbol - symbol - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.mtsUpdate - last update timestamp - * @param {string} data.amount - remaining amount - * @param {string} data.amountOrig - original amount - * @param {string} data.type - funding offer type - * @param {number} data.flags - flags - * @param {string} data.status - current status - * @param {number} data.rate - rate - * @param {number} data.rateReal - rate real - * @param {number} data.period - period for the offer - * @param {number|boolean} data.notify - notify flag - * @param {number|boolean} data.hidden - hidden flag - * @param {number|boolean} data.renew - renew flag + * @param {FundingOffer~Data|FundingOffer~Data[]} data - data * @param {object} [apiInterface] - rest or websocket object capable of * submitting funding offers */ @@ -63,8 +51,9 @@ class FundingOffer extends Model { } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingOffer~Data|FundingOffer~Data[]} data - data to convert to + * POJO + * @returns {FundingOffer~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields, boolFields }) @@ -74,7 +63,7 @@ class FundingOffer extends Model { * Creates an order map that can be used in either the websocket `on` * command or a rest request body * - * @returns {object} on + * @returns {FundingOffer~SubmitPayload} on */ toNewOfferPacket () { return { @@ -90,7 +79,7 @@ class FundingOffer extends Model { /** * Submit the funding offer * - * @param {RESTv2} apiInterface - optional rest instance + * @param {bfx-api-node-rest.RESTv2} [apiInterface] - rest instance * @returns {Promise} p */ async submit (apiInterface = this._apiInterface) { @@ -107,7 +96,7 @@ class FundingOffer extends Model { /** * Cancel the funding offer * - * @param {RESTv2} apiInterface - optional rest instance + * @param {bfx-api-node-rest.RESTv2} [apiInterface] - rest instance * @returns {Promise} p */ async cancel (apiInterface = this._apiInterface) { @@ -124,7 +113,7 @@ class FundingOffer extends Model { /** * Close the funding offer * - * @param {RESTv2} apiInterface - optional rest instance + * @param {bfx-api-node-rest.RESTv2} [apiInterface] - rest instance * @returns {Promise} p */ async close (apiInterface = this._apiInterface) { @@ -169,7 +158,8 @@ class FundingOffer extends Model { /** * Validates a given funding offer instance * - * @param {object[]|object|FundingOffer[]|FundingOffer|Array} data - instance to validate + * @param {FundingOffer~Data|FundingOffer~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_ticker.js b/lib/funding_ticker.js index 1176183..43703a5 100644 --- a/lib/funding_ticker.js +++ b/lib/funding_ticker.js @@ -25,32 +25,22 @@ const fields = { /** * Funding Ticker model + * + * @class + * @augments Model */ class FundingTicker extends Model { /** - * @param {object|Array} data - funding ticker data - * @param {string} data.symbol - symbol - * @param {number|boolean} data.frr - current FRR - * @param {number} data.bid - best bid - * @param {number} data.bidSize - total bid amount - * @param {number} data.bidPeriod - bid period - * @param {number} data.ask - best ask - * @param {number} data.askSize - total ask amount - * @param {number} data.askPeriod - ask period - * @param {number} data.dailyChange - net 24h period change - * @param {number} data.dailyChangePerc - net 24h period change as percent - * @param {number} data.lastPrice - last price - * @param {number} data.volume - total volume in last 24h period - * @param {number} data.high - highest rate in last 24h period - * @param {number} data.low - lowest rate in last 24h period + * @param {FundingTicker~Data|FundingTicker~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingTicker~Data|FundingTicker~Data[]} data - data to convert to + * POJO + * @returns {FundingTicker~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -77,7 +67,8 @@ class FundingTicker extends Model { /** * Validates a given funding ticker instance * - * @param {object[]|object|FundingTicker[]|FundingTicker|Array} data - instance to validate + * @param {FundingTicker~Data|FundingTicker~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_ticker_hist.js b/lib/funding_ticker_hist.js index 086b616..58a7eb2 100644 --- a/lib/funding_ticker_hist.js +++ b/lib/funding_ticker_hist.js @@ -15,23 +15,22 @@ const fields = { /** * Historical Funding Ticker model + * + * @class + * @augments Model */ class FundingTickerHist extends Model { /** - * @param {object|Array} data - historical funding ticker data - * @param {string} data.symbol - symbol - * @param {number} data.bid - bid - * @param {number} data.bidPeriod - bid period - * @param {number} data.ask - ask - * @param {number} data.mtsUpdate - timestamp + * @param {FundingTickerHist~Data|FundingTickerHist~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingTickerHist~Data|FundingTickerHist~Data[]} data - data to + * convert to POJO + * @returns {FundingTickerHist~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -58,7 +57,8 @@ class FundingTickerHist extends Model { /** * Validates a given historical funding ticker instance. * - * @param {object[]|object|FundingTickerHist[]|FundingTickerHist|Array} data - instance to validate + * @param {FundingTickerHist~Data|FundingTickerHist~Data[]} data - models + * to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/funding_trade.js b/lib/funding_trade.js index d51b7e3..0c38521 100644 --- a/lib/funding_trade.js +++ b/lib/funding_trade.js @@ -23,26 +23,22 @@ const fields = { /** * Funding Trade model + * + * @class + * @augments Model */ class FundingTrade extends Model { /** - * @param {object|Array} data - funding trade data - * @param {number} data.id - id - * @param {string} data.symbol - symbol - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.offerID - taken offer ID - * @param {number} data.amount - amount - * @param {number} data.rate - rate - * @param {number} data.period - period - * @param {number|boolean} data.maker - maker flag + * @param {FundingTrade~Data|FundingTrade~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {FundingTrade~Data|FundingTrade~Data[]} data - data to convert to + * POJO + * @returns {FundingTrade~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -72,7 +68,8 @@ class FundingTrade extends Model { /** * Validates a given funding trade instance * - * @param {object[]|object|FundingTrade[]|FundingTrade|Array} data - instance to validate + * @param {FundingTrade~Data|FundingTrade~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/ledger_entry.js b/lib/ledger_entry.js index 9554830..dd1b5cc 100644 --- a/lib/ledger_entry.js +++ b/lib/ledger_entry.js @@ -22,16 +22,13 @@ const fields = { /** * Ledger Entry model; wallet field is automatically populated if a description * is provided. + * + * @class + * @augments Model */ class LedgerEntry extends Model { /** - * @param {object|Array} data - ledger entry data - * @param {number} data.id - id - * @param {string} data.currency - currency - * @param {number} data.mts - transaction timestamp - * @param {number} data.amount - transaction amount - * @param {number} data.balance - balance at time of transaction - * @param {string} data.description - transaction description + * @param {LedgerEntry~Data|LedgerEntry~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) @@ -45,8 +42,9 @@ class LedgerEntry extends Model { } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {LedgerEntry~Data|LedgerEntry~Data[]} data - data to convert to + * POJO + * @returns {LedgerEntry~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -55,7 +53,8 @@ class LedgerEntry extends Model { /** * Validates a given ledger entry instance * - * @param {object[]|object|LedgerEntry[]|LedgerEntry|Array} data - instance to validate + * @param {LedgerEntry~Data|LedgerEntry~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/liquidations.js b/lib/liquidations.js index b496960..6b29cce 100644 --- a/lib/liquidations.js +++ b/lib/liquidations.js @@ -21,25 +21,22 @@ const fields = { /** * Liquidation Info model + * + * @class + * @augments Model */ class Liquidations extends Model { /** - * @param {object|Array} data - liquidation data - * @param {number} data.posId - position ID - * @param {number} data.mtsUpdated - timestamp - * @param {string} data.symbol - symbol - * @param {number} data.amount - amount - * @param {number} data.basePrice - base price - * @param {number|boolean} data.isMatch - matched flag - * @param {number|boolean} data.isMarketSold - sold flag + * @param {Liquidations~Data|Liquidations~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Liquidations~Data|Liquidations~Data[]} data - data to convert to + * POJO + * @returns {Liquidations~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -65,7 +62,8 @@ class Liquidations extends Model { /** * Validates a given liquidation instance * - * @param {object[]|object|Liquidations[]|Liquidations|Array} data - instance to validate + * @param {Liquidations~Data|Liquidations~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/login.js b/lib/login.js index 5847a04..f3da6b6 100644 --- a/lib/login.js +++ b/lib/login.js @@ -13,22 +13,21 @@ const fields = { /** * Login event model + * + * @class + * @augments Model */ class Login extends Model { /** - * @param {object|Array} data - login event data - * @param {number} data.id - id - * @param {number} data.time - timestamp - * @param {string} data.ip - client IP address - * @param {object} data.extraData - metadata + * @param {Login~Data|Login~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Login~Data|Login~Data[]} data - data to convert to POJO + * @returns {Login~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -37,7 +36,7 @@ class Login extends Model { /** * Validates a given login instance * - * @param {object[]|object|Login[]|Login|Array} data - instance to validate + * @param {Login~Data|Login~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/margin_info.js b/lib/margin_info.js index bcc2b76..47d5d22 100644 --- a/lib/margin_info.js +++ b/lib/margin_info.js @@ -11,6 +11,11 @@ const Model = require('./model') /** * Margin Info model + * + * @todo Extract type defs (varying format) + * + * @class + * @augments Model */ class MarginInfo extends Model { /** @@ -102,11 +107,12 @@ class MarginInfo extends Model { /** * Validates a given margin info instance * - * @param {object[]|object|MarginInfo[]|MarginInfo|Array} data - instance to validate + * @param {object[]|object|MarginInfo[]|MarginInfo|Array} data - instance(s) + * to validate * @returns {string} error - null if instance is valid */ static validate (data) { - const { type, symbol, tradableBalance, grossBalance, buy, sell } = this + const { type, symbol, tradableBalance, grossBalance, buy, sell } = data return ( stringValidator(type) || diff --git a/lib/model.js b/lib/model.js index f61962a..198ff6f 100644 --- a/lib/model.js +++ b/lib/model.js @@ -1,8 +1,6 @@ 'use strict' const { EventEmitter } = require('events') -const isCollection = require('./util/is_collection') -const assignFromCollectionOrInstance = require('./util/assign_from_collection_or_instance') const _isArray = require('lodash/isArray') const _isObject = require('lodash/isObject') const _isString = require('lodash/isString') @@ -10,15 +8,21 @@ const _includes = require('lodash/includes') const _isError = require('lodash/isError') const _isFunction = require('lodash/isFunction') +const isCollection = require('./util/is_collection') +const assignFromCollectionOrInstance = require('./util/assign_from_collection_or_instance') + /** * Base model class, providing format-conversion methods + * + * @class + * @augments events.EventEmitter */ class Model extends EventEmitter { /** * @param {object} params - model parameters * @param {object[]|object|Array} [params.data] - model data - * @param {object} [params.fields] - field definitions, { [index]: key } - * @param {string[]} [params.boolFields] - array of boolean field keys, default empty + * @param {object} [params.fields={}] - field definitions, { [index]: key } + * @param {string[]} [params.boolFields=[]] - array of boolean field keys */ constructor ({ data, fields = {}, boolFields = [] } = {}) { super() @@ -75,7 +79,7 @@ class Model extends EventEmitter { * @param {object} args - arguments * @param {object[]|object|Array} args.data - can also be a model instance * @param {object} args.fields - field definitions, { [index]: key } - * @param {string[]} [args.boolFields] - array of boolean field keys, default empty + * @param {string[]} [args.boolFields=[]] - array of boolean field keys * @returns {object} pojo */ static unserialize ({ data, fields, boolFields = [] }) { @@ -117,7 +121,7 @@ class Model extends EventEmitter { * @param {object[]|object|Array} args.data - model or collection to validate * @param {object} args.fields - map of fields to array indexes * @param {object} args.validators - map of field names to validation funcs - * @param {string[]} [args.boolFields] - array of boolean field keys, default empty + * @param {string[]} [args.boolFields=[]] - array of boolean field keys * @returns {Error|null} error - null if instance is valid */ static validate ({ data, fields, boolFields = [], validators }) { diff --git a/lib/movement.js b/lib/movement.js index 4d71726..73ade7b 100644 --- a/lib/movement.js +++ b/lib/movement.js @@ -21,27 +21,20 @@ const fields = { /** * Currency Movement model + * + * @class + * @augments Model */ class Movement extends Model { /** - * @param {object|Array} data - movement data - * @param {number} data.id - id - * @param {string} data.currency - currency - * @param {string} data.currencyName - currency name - * @param {number} data.mtsStarted - movement start timestamp - * @param {number} data.mtsUpdated - last update timestamp - * @param {string} data.status - status - * @param {number} data.amount - moved amount - * @param {number} data.fees - paid fees - * @param {string} data.destinationAddress - destination address - * @param {number} data.transactionId - transaction ID + * @param {Movement~Data|Movement~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO + * @param {Movement~Data|Movement~Data[]} data - data to convert to POJO * @returns {object} pojo */ static unserialize (data) { @@ -51,7 +44,7 @@ class Movement extends Model { /** * Validates a given movement instance * - * @param {object[]|object|Movement[]|Movement|Array} data - instance to validate + * @param {Movement~Data|Movement~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/notification.js b/lib/notification.js index 0abfc6e..369ccc0 100644 --- a/lib/notification.js +++ b/lib/notification.js @@ -15,26 +15,23 @@ const fields = { } /** - * Notification model + * Notification model. Broadcast notification body schema may be found at + * {@link Notification~BroadcastPayload}. + * + * @class + * @augments Model */ class Notification extends Model { /** - * @param {object|Array} data - notification data - * @param {number} data.mts - timestamp - * @param {string} data.type - type (i.e. 'ucm-*' for broadcasts) - * @param {number} data.messageID - message ID - * @param {object} data.notifyInfo - metadata, set by client for broadcasts - * @param {number} data.code - code - * @param {string} data.status - status (i.e. 'error') - * @param {string} data.text - notification text to display to user + * @param {Notification~Data|Notification~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Notification~Data|Notification~Data[]} data - data to convert to POJO + * @returns {Notification~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -43,7 +40,8 @@ class Notification extends Model { /** * Validates a given notification instance * - * @param {object[]|object|Notification[]|Notification|Array} data - instance to validate + * @param {Notification~Data|Notification~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/order.js b/lib/order.js index a3f30d6..ef785b2 100644 --- a/lib/order.js +++ b/lib/order.js @@ -69,32 +69,28 @@ let lastCID = Date.now() /** * High level order model; provides methods for execution & can stay updated via * a WSv2 connection or used to execute as a rest payload + * + * @class + * @augments Model + * @example + * const debug = require('debug')('bfx:api:models:examples:order') + * const { Order } = require('../') + * const o = new Order({ + * type: Order.type.EXCHANGE_LIMIT, + * symbol: 'tBTCUSD', + * amount: 0.05, + * price: 10000, + * hidden: true + * }) + * + * debug('generated ws2 compatible new order packet:') + * debug(JSON.stringify(o.toNewOrderPacket(), null, 2)) */ class Order extends Model { /** - * @param {object|Array} data - order data - * @param {number} data.id - ID - * @param {number} data.gid - group ID - * @param {number} data.cid - client ID - * @param {string} data.symbol - symbol - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.mtsUpdate - last update timestamp - * @param {string} data.amount - remaining order amount - * @param {string} data.amountOrig - original/initial order amount - * @param {string} data.type - order type (i.e. 'EXCHANGE LIMIT') - * @param {string} data.typePrev - previous order type, if any - * @param {number} [data.mtsTIF] - TIF timestamp, if set - * @param {number} data.flags - order flags - * @param {string} data.status - current order status - * @param {string} data.price - order price - * @param {string} data.priceAvg - average execution price - * @param {string} [data.priceTrailing] - trailing distance for TRAILING STOP orders - * @param {string} [data.priceAuxLimit] - stop price for STOP LIMIT and OCO orders - * @param {number|boolean} [data.notify] - notify flag - * @param {number} [data.placedId] - placed ID - * @param {string} [data.affiliateCode] - affiliate code - * @param {number} [data.lev] - leverage - * @param {object} [apiInterface] - saved for a later call to registerListeners() + * @param {Order~Data} [data={}] - order data + * @param {object} [apiInterface] - saved for a later call to + * `registerListeners()`` */ constructor (data = {}, apiInterface) { super({ data, fields, boolFields }) @@ -123,8 +119,8 @@ class Order extends Model { } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Order~Data|Order~Data[]} data - data to convert to POJO + * @returns {Order~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields, boolFields }) @@ -133,7 +129,7 @@ class Order extends Model { /** * Returns a string representation of the order * - * TODO: add verbose option to log all order information (TIF, etc) + * @todo add verbose option to log all order information (TIF, etc) * * @returns {string} str */ @@ -309,9 +305,6 @@ class Order extends Model { * Rejects with an error if an attempt is made to apply a delta to a missing * amount. * - * @param {object} changes - changeset to apply to this order - * @param {WSv2|RESTv2} [apiInterface] - optional ws or rest, defaults to internal instance - * @returns {Promise} p - resolves on ws2 confirmation or rest response * @example * const ws = new WSv2({ ... }) * @@ -325,6 +318,14 @@ class Order extends Model { * await o.update({ delta: '18.0' }) // update amount with delta * * console.log(o.toString())) // inspect order + * + * @param {object} changes - changeset to apply to this order + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - optional ws or rest, defaults to internal instance + * + * @returns {Promise} p - resolves on ws2 confirmation or rest response */ async update (changes = {}, apiInterface = this._apiInterface) { if (!apiInterface) { @@ -373,7 +374,7 @@ class Order extends Model { * Returns a POJO that can be used as a preview order in Honey Framework * algorithmic orders. * - * @returns {object} preview + * @returns {Order~Preview} preview */ toPreview () { const prev = { @@ -386,16 +387,18 @@ class Order extends Model { notify: this.notify, flags: this.flags } + if (!Number.isNaN(+this.lev)) { prev.lev = +this.lev } + return prev } /** * Registers for updates/persistence on the specified ws2 instance. * - * @param {object} apiInterface - optional, defaults to internal ws + * @param {object} [apiInterface] - optional, defaults to internal ws */ registerListeners (apiInterface = this._apiInterface) { if (!apiInterface || apiInterface.constructor.name !== 'WSv2') return @@ -420,7 +423,10 @@ class Order extends Model { * Removes update listeners from the specified ws2 instance. * Will fail if rest interface is provided. * - * @param {WSv2|RESTv2} apiInterface - optional ws defaults to internal ws + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - optional ws defaults to internal ws */ removeListeners (apiInterface = this._apiInterface) { if (apiInterface) { @@ -441,7 +447,11 @@ class Order extends Model { /** * Submit the order * - * @param {WSv2|Rest2} apiInterface - optional ws or rest, defaults to internal ws + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - defaults to internal ws + * * @returns {Promise} p */ async submit (apiInterface = this._apiInterface) { @@ -457,7 +467,11 @@ class Order extends Model { /** * Cancel the order if open * - * @param {WSv2|Rest2} apiInterface - optional ws or rest, defaults to internal ws + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - defaults to internal ws + * * @returns {Promise} p */ async cancel (apiInterface = this._apiInterface) { @@ -470,7 +484,11 @@ class Order extends Model { /** * Equivalent to calling cancel() followed by submit() * - * @param {WSv2|RESTv2} apiInterface - optional ws or rest, defaults to internal ws + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - defaults to internal ws + * * @returns {Promise} p */ async recreate (apiInterface = this._apiInterface) { @@ -487,8 +505,9 @@ class Order extends Model { /** * Updates order information from the provided order. * + * @throws {Error} fails if the order ID/CID/GID do not match + * * @param {Order} order - order to update from - * @throws Error if the order ID/CID/GID do not match */ updateFrom (order = {}) { const { id, gid, cid } = order @@ -521,8 +540,8 @@ class Order extends Model { /** * Resets the last amount, so getLastFillAmount() returns 0 * - * @see Order~getLastFillAmount - * @see Order~isPartiallyFilled + * @see {@link Order~getLastFillAmount} + * @see {@link Order~isPartiallyFilled} */ resetFilledAmount () { this._lastAmount = this.amount @@ -559,7 +578,7 @@ class Order extends Model { * Indicates if the order is partially filled, based on the original and * current amounts. * - * @see Order~resetFilledAmount + * @see modules:bfx-api-node-models.Order~resetFilledAmount * * @returns {boolean} isPartiallyFilled */ @@ -569,8 +588,9 @@ class Order extends Model { } /** - * @param {Array} order - incoming order * @private + * + * @param {Order~ArrayData} order - incoming order */ _onWSOrderUpdate (order) { Object.assign(this, Order.unserialize(order)) @@ -579,8 +599,9 @@ class Order extends Model { } /** - * @param {Array} order - incoming order * @private + * + * @param {Order~ArrayData} order - incoming order */ _onWSOrderClose (order) { Object.assign(this, Order.unserialize(order)) @@ -590,8 +611,9 @@ class Order extends Model { } /** - * @param {Array} order - incoming order * @private + * + * @param {Order~ArrayData} order - incoming order */ _onWSOrderNew (order) { Object.assign(this, Order.unserialize(order)) @@ -603,7 +625,7 @@ class Order extends Model { /** * Creates an order map that can be passed to the `on` command. * - * @returns {object} o + * @returns {Order~SubmitPayload} o * @example * const ws = new WSv2({ apiKey: '...', apiSecret: '...' }) * await ws.open() @@ -664,7 +686,7 @@ class Order extends Model { /** * Get the base currency for an order in WSv2 array format. * - * @param {Array} arr - order in ws2 array format + * @param {Order~ArrayData} arr - order in ws2 array format * @returns {string} currency - base currency from symbol */ static getBaseCurrency (arr = []) { @@ -674,7 +696,7 @@ class Order extends Model { /** * Get the quote currency for an order in WSv2 array format. * - * @param {Array} arr - order in ws2 array format + * @param {Order~ArrayData} arr - order in ws2 array format * @returns {string} currency - quote currency from symbol */ static getQuoteCurrency (arr = []) { @@ -684,7 +706,7 @@ class Order extends Model { /** * Validates a given order instance * - * @param {object[]|object|Order[]|Order|Array} data - instance to validate + * @param {Order~Data|Order~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { @@ -730,13 +752,48 @@ types.forEach((t) => { Order.type[t.split(' ').join('_')] = t }) +/** + * Valid order flag values + * + * @enum {number} + * @constant + * @readonly + */ Order.flags = { - OCO: 2 ** 14, // 16384 - POSTONLY: 2 ** 12, // 4096 - HIDDEN: 2 ** 6, // 64 - NO_VR: 2 ** 19, // 524288 - POS_CLOSE: 2 ** 9, // 512 - REDUCE_ONLY: 2 ** 10 // 1024 + /** + * Order cancels order (16384). Requires `priceAuxLimit` and `cidOCO` to be + * set, resolved to `price_oco_stop` and `cid_oco` on the generated `on` + * packet. + */ + OCO: 2 ** 14, + + /** + * Post-only (4096) orders are cancelled if they would execute immediately + */ + POSTONLY: 2 ** 12, + + /** + * Hidden (64) orders are inserted into the book, not visible to other + * traders, and always pay the **taker** fee. + */ + HIDDEN: 2 ** 6, + + /** + * Excludes variable rate (524288) funding + */ + NO_VR: 2 ** 19, + + /** + * Position-close (512) orders are cancelled if they would not close an + * open position. + */ + POS_CLOSE: 2 ** 9, + + /** + * Reduce-only (1024) orders are cancelled if they would open or increase + * the size of an existing position. + */ + REDUCE_ONLY: 2 ** 10 } module.exports = Order diff --git a/lib/order_book.js b/lib/order_book.js index bb85f69..b8f385c 100644 --- a/lib/order_book.js +++ b/lib/order_book.js @@ -8,12 +8,15 @@ const { preparePrice } = require('bfx-api-node-util') /** * High level OB model to automatically integrate WS updates & maintain sort + * + * @class + * @augments events.EventEmitter */ class OrderBook extends EventEmitter { /** * Initializes the order book with an existing snapshot (array form) * - * @param {Array[]|OrderBook} snap - order book snapshot + * @param {OrderBook~Data} snap - snapshot * @param {boolean} [raw] - true for raw 'R0' order books */ constructor (snap = [], raw = false) { @@ -124,7 +127,8 @@ class OrderBook extends EventEmitter { /** * Like checksum(), but for raw array-format order books * - * @param {Array[]} arr - assumed sorted, [topBid, bid, ..., topAsk, ask, ...] + * @param {OrderBook~ArrayData} arr - assumed sorted, `[topBid, bid, ..., + * topAsk, ask, ...]` * @param {boolean} [raw] - true for raw 'R0' order books * @returns {number} cs */ @@ -182,6 +186,11 @@ class OrderBook extends EventEmitter { return CRC.str(data.join(':')) } + /** + * Sets bids/asks to those in the provided snapshot + * + * @param {OrderBook~ArrayData} snapshot - snapshot + */ updateFromSnapshot (snapshot) { this.bids = [] this.asks = [] @@ -414,8 +423,8 @@ class OrderBook extends EventEmitter { /** * Modifies an array-format OB in place with an update entry. Maintains sort * - * @param {number[][]} ob - array-format order book - * @param {number[]} entry - price level to update with + * @param {OrderBook~ArrayData} ob - array-format order book + * @param {OrderBook~ArrayPriceLevel} entry - price level to update with * @param {boolean} [raw] - true for raw 'R0' order books * @returns {boolean} success - false if entry doesn't match OB */ @@ -485,6 +494,13 @@ class OrderBook extends EventEmitter { return true } + /** + * Finds the mid price of the provided array-format OB + * + * @param {OrderBook~ArrayData} ob - orderbook + * @param {boolean} [raw] - true for `raw` books + * @returns {number} midPrice - null if book is empty + */ static arrayOBMidPrice (ob = [], raw = false) { if (ob.length === 0) return null @@ -511,7 +527,8 @@ class OrderBook extends EventEmitter { * Converts an array order book entry or snapshot to an object, with 'price', * 'count', and 'amount' keys on entries * - * @param {number[]|number[][]} arr - array format order book + * @param {OrderBook~ArrayData|OrderBook~ArrayPriceLevel} arr - array format + * order book * @param {boolean} [raw] - true for raw 'R0' order books * @returns {object} ob - either a map w/ bids & asks, or single entry object */ diff --git a/lib/position.js b/lib/position.js index 460c7da..f589c88 100644 --- a/lib/position.js +++ b/lib/position.js @@ -37,29 +37,18 @@ const fields = { /** * Position model + * + * @class + * @augments Model */ class Position extends Model { /** - * @param {object|Array} data - position data - * @param {number} data.id - id - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.mtsUpdate - last update timestamp - * @param {string} data.symbol - symbol - * @param {string} data.status - status - * @param {string} data.type - type - * @param {string} data.amount - amount - * @param {string} data.basePrice - base price - * @param {string} data.marginFunding - margin funding - * @param {string} data.marginFundingType - margin funding type - * @param {string} data.pl - profit/loss - * @param {string} data.plPerc - profit/loss as percentage - * @param {string} data.liquidationPrice - liquidation price - * @param {number} data.leverage - leverage - * @param {number} data.collateral - collateral - * @param {number} data.collateralMin - minimum collateral to maintain position - * @param {object} data.meta - metadata - * @param {WSv2|RESTv2} [apiInterface] - rest or websocket object thats - * capable of submitting position changes + * @param {Position~Data|Position~Data[]} data - data + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - rest or websocket object that's capable of submitting + * position changes */ constructor (data = {}, apiInterface) { super({ data, fields }) @@ -67,8 +56,8 @@ class Position extends Model { } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Position~Data|Position~Data[]} data - data to convert to POJO + * @returns {Position~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -77,7 +66,7 @@ class Position extends Model { /** * Claim the position * - * @param {RESTv2} [apiInterface] - defaults to internal interface + * @param {bfx-api-node-rest.RESTv2} [apiInterface] - api * @returns {Promise} p */ async claim (apiInterface = this._apiInterface) { @@ -94,7 +83,7 @@ class Position extends Model { /** * Close the position * - * @param {RESTv2} [apiInterface] - defaults to internal interface + * @param {bfx-api-node-rest.RESTv2} [apiInterface] - api * @returns {Promise} p */ async close (apiInterface = this._apiInterface) { @@ -110,7 +99,11 @@ class Position extends Model { /** * Generate an order that can be used to close the position. * - * @param {WSv2|RESTv2} [apiInterface] - defaults to internal interface + * @param {( + * bitfinex-api-node.WSv2| + * bfx-api-node-rest.RESTv2 + * )} [apiInterface] - provided to returned `Order` instance + * * @returns {Promise} p */ orderToClose (apiInterface = this._apiInterface) { @@ -158,7 +151,7 @@ class Position extends Model { /** * Validates a given position instance * - * @param {object[]|object|Position[]|Position|Array} data - instance to validate + * @param {Position~Data|Position~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/public_pulse_profile.js b/lib/public_pulse_profile.js index c386979..09d57f6 100644 --- a/lib/public_pulse_profile.js +++ b/lib/public_pulse_profile.js @@ -20,24 +20,22 @@ const fields = { /** * Public PulseProfile model + * + * @class + * @augments Model */ class PublicPulseProfile extends Model { /** - * @param {object|Array} data - public pulse profile data - * @param {string} data.id - pulse User ID - * @param {number} data.mtsCreate - creation timestamp - * @param {string} data.nickname - profile nickname - * @param {string} data.picture - profile picture - * @param {string} data.text - profile bio - * @param {string} data.twitterHandle - profile twitter handle + * @param {PublicPulseProfile~Data|PublicPulseProfile~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {PublicPulseProfile~Data|PublicPulseProfile~Data[]} data - data to + * convert to POJO + * @returns {PublicPulseProfile~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -64,7 +62,8 @@ class PublicPulseProfile extends Model { /** * Validates a given public pulse profile instance * - * @param {object[]|object|PublicPulseProfile[]|PublicPulseProfile|Array} data - instance to validate + * @param {PublicPulseProfile~Data|PublicPulseProfile~Data[]} data - models + * to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/public_trade.js b/lib/public_trade.js index e1a3706..d9e854e 100644 --- a/lib/public_trade.js +++ b/lib/public_trade.js @@ -28,6 +28,11 @@ const FUNDING_FIELDS = { /** * Public Trade model, supporting both funding & ordinary trades + * + * @todo Extract type defs (varying format) + * + * @class + * @augments Model */ class PublicTrade extends Model { /** @@ -79,7 +84,8 @@ class PublicTrade extends Model { /** * Validates a given public trade instance * - * @param {object[]|object|PublicTrade[]|PublicTrade|Array} data - instance to validate + * @param {object[]|object|PublicTrade[]|PublicTrade|Array} data - models to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/pulse_message.js b/lib/pulse_message.js index caa02d4..bff813c 100644 --- a/lib/pulse_message.js +++ b/lib/pulse_message.js @@ -33,29 +33,21 @@ const fields = { /** * Private PulseMessage model + * + * @class + * @augments Model */ class PulseMessage extends Model { /** - * @param {object|Array} data - pulse message data - * @param {string} data.id - pulse message ID - * @param {number} data.mts - millisecond timestamp - * @param {string} data.userID - pulse User ID - * @param {string} data.title - title of the pulse message - * @param {string} data.content - content of the pulse message - * @param {number} data.isPin - 1 if the message is pinned, 0 if it is not pinned - * @param {number} data.isPublic - 1 if the message is public, 0 if it is not public - * @param {string} data.tags - tags used in the message - * @param {string} data.attachments - attachments used in the message - * @param {number} data.likes - number of likes - * @param {number} data.userLiked - flag to show if the private user liked the pulse + * @param {PulseMessage~Data|PulseMessage~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {PulseMessage~Data|PulseMessage~Data[]} data - data to convert + * @returns {PulseMessage~ObjectData} pojo */ static unserialize (data) { const pojo = super.unserialize({ data, fields }) @@ -88,7 +80,8 @@ class PulseMessage extends Model { */ toString () { const { - id, mts, userID, title, content, isPin, isPublic, tags, attachments, likes, userLiked + id, mts, userID, title, content, isPin, isPublic, tags, attachments, + likes, userLiked } = this return _compact(_flatten([ @@ -109,7 +102,8 @@ class PulseMessage extends Model { /** * Validates a given public pulse profile instance * - * @param {object[]|object|PulseMessage[]|PulseMessage|Array} data - instance to validate + * @param {PulseMessage~Data|PulseMessage~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/status_messages_deriv.js b/lib/status_messages_deriv.js index d7655c8..6e81c6e 100644 --- a/lib/status_messages_deriv.js +++ b/lib/status_messages_deriv.js @@ -14,27 +14,26 @@ const fields = { fundingStep: 10 } +require('./types/status_messages_deriv/data') + /** * Derivatives Status Message model + * + * @class + * @augments Model */ class StatusMessagesDeriv extends Model { /** - * @param {object|Array} data - derivatives status message data - * @param {string} data.key - key - * @param {number} data.timestamp - timestamp - * @param {string} data.price - price - * @param {string} data.priceSpot - spot price - * @param {string} data.fundBal - funding balance - * @param {string} data.fundingAccrued - accrued funding - * @param {string} data.fundingStep - funding step + * @param {StatusMessagesDeriv~Data|StatusMessagesDeriv~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {StatusMessagesDeriv~Data|StatusMessagesDeriv~Data[]} data - data + * to convert to POJO + * @returns {StatusMessagesDeriv~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -43,7 +42,8 @@ class StatusMessagesDeriv extends Model { /** * Validates a given public trade instance * - * @param {object[]|object|PublicTrade[]|PublicTrade|Array} data - instance to validate + * @param {StatusMessagesDeriv~Data|StatusMessagesDeriv~Data[]} data - models + * to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/trade.js b/lib/trade.js index cf087af..089f63b 100644 --- a/lib/trade.js +++ b/lib/trade.js @@ -33,29 +33,21 @@ const fields = { /** * Private Trade model + * + * @class + * @augments Model */ class Trade extends Model { /** - * @param {object|Array} data - trade data - * @param {number} data.id - id - * @param {string} data.symbol - symbol - * @param {number} data.mtsCreate - creation timestamp - * @param {number} data.orderID - order ID - * @param {string} data.execAmount - executed amount - * @param {string} data.execPrice - execution price - * @param {string} data.orderType - order type - * @param {string} data.orderPrice - order price - * @param {number|boolean} data.maker - maker flag - * @param {string} data.fee - fee amount - * @param {string} data.feeCurrency - fee currency + * @param {Trade~Data|Trade~Data[]} data - data */ constructor (data = {}) { super({ data, fields, boolFields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Trade~Data|Trade~Data[]} data - data to convert to POJO + * @returns {Trade~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields, boolFields }) @@ -82,7 +74,7 @@ class Trade extends Model { /** * Validates a given trade instance * - * @param {object[]|object|PublicTrade[]|PublicTrade|Array} data - instance to validate + * @param {Trade~Data|Trade~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/trading_ticker.js b/lib/trading_ticker.js index d1a0497..f5d9957 100644 --- a/lib/trading_ticker.js +++ b/lib/trading_ticker.js @@ -21,29 +21,22 @@ const fields = { /** * Trading Ticker model + * + * @class + * @augments Model */ class TradingTicker extends Model { /** - * @param {object|Array} data - trading ticker data - * @param {string} data.symbol - symbol - * @param {number} data.bid - best bid - * @param {number} data.bidSize - total bid size - * @param {number} data.ask - best ask - * @param {number} data.askSize - total ask size - * @param {number} data.dailyChange - change in last 24h period - * @param {number} data.dailyChangePerc - change in last 24h period as percent - * @param {number} data.lastPrice - last price - * @param {number} data.volume - volume in last 24h period - * @param {number} data.high - highest price in last 24h period - * @param {number} data.low - lowest price in last 24h period + * @param {TradingTicker~Data|TradingTicker~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {TradingTicker~Data|TradingTicker~Data[]} data - data to convert to + * POJO + * @returns {TradingTicker~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -70,7 +63,8 @@ class TradingTicker extends Model { /** * Validates a given trading ticker instance * - * @param {object[]|object|PublicTrade[]|PublicTrade|Array} data - instance to validate + * @param {TradingTicker~Data|TradingTicker~Data[]} data - instance(s) to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/trading_ticker_hist.js b/lib/trading_ticker_hist.js index d2cc83b..0d2eeab 100644 --- a/lib/trading_ticker_hist.js +++ b/lib/trading_ticker_hist.js @@ -11,24 +11,26 @@ const fields = { mtsUpdate: 12 } +require('./types/trading_ticker_hist/data') + /** * Historical Trading Ticker model + * + * @class + * @augments Model */ class TradingTickerHist extends Model { /** - * @param {object|Array} data - historical trading ticker data - * @param {string} data.symbol - symbol - * @param {string} data.bid - best bid - * @param {string} data.ask - best ask - * @param {number} data.mtsUpdate - timestamp + * @param {TradingTickerHist~Data|TradingTickerHist~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {TradingTickerHist~Data|TradingTickerHist~Data[]} data - data to + * convert to POJO + * @returns {TradingTickerHist~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -55,7 +57,8 @@ class TradingTickerHist extends Model { /** * Validates a given historical trading ticker instance * - * @param {object[]|object|TradingTickerHist[]|TradingTickerHist|Array} data - instance to validate + * @param {TradingTickerHist~Data|TradingTickerHist~Data[]} data - models to + * validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/types/alert/array_data.js b/lib/types/alert/array_data.js new file mode 100644 index 0000000..74a6e3f --- /dev/null +++ b/lib/types/alert/array_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link Alert} data in WSv2 array format. Suitable for passing to + * {@link Alert} to construct a model instance. + * + * @typedef {Array} Alert~ArrayData + * @property {string} 0 - key + * @property {string} 1 - type + * @property {string} 2 - symbol + * @property {string} 3 - price + */ diff --git a/lib/types/alert/data.js b/lib/types/alert/data.js new file mode 100644 index 0000000..fcefc09 --- /dev/null +++ b/lib/types/alert/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Alert} data either in WSv2 array or object format. + * + * @typedef {Alert|Alert~ObjectData|Alert~ArrayData} Alert~Data + */ diff --git a/lib/types/alert/object_data.js b/lib/types/alert/object_data.js new file mode 100644 index 0000000..4af0786 --- /dev/null +++ b/lib/types/alert/object_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link Alert} data in plain object format. Suitable for passing to + * {@link Alert} to construct a model instance. + * + * @typedef {object} Alert~ObjectData + * @property {string} key - alert key + * @property {string} type - alert type + * @property {string} symbol - configured symbol + * @property {string} price - configured price + */ diff --git a/lib/types/balance_info/array_data.js b/lib/types/balance_info/array_data.js new file mode 100644 index 0000000..cb8e9b9 --- /dev/null +++ b/lib/types/balance_info/array_data.js @@ -0,0 +1,10 @@ +'use strict' + +/** + * {@link BalanceInfo} data in WSv2 array format. Suitable for passing to + * {@link BalanceInfo} to construct a model instance. + * + * @typedef {Array} BalanceInfo~ArrayData + * @property {number} 0 - amount + * @property {number} 1 - amountNet + */ diff --git a/lib/types/balance_info/data.js b/lib/types/balance_info/data.js new file mode 100644 index 0000000..42ba620 --- /dev/null +++ b/lib/types/balance_info/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * Balance info data either in WSv2 array or object format. + * + * @typedef {( + * BalanceInfo|BalanceInfo~ObjectData|BalanceInfo~ArrayData + * )} BalanceInfo~Data + */ diff --git a/lib/types/balance_info/object_data.js b/lib/types/balance_info/object_data.js new file mode 100644 index 0000000..5237173 --- /dev/null +++ b/lib/types/balance_info/object_data.js @@ -0,0 +1,10 @@ +'use strict' + +/** + * {@link BalanceInfo} data in plain object format. Suitable for passing to + * {@link BalanceInfo} to construct a model instance. + * + * @typedef {object} BalanceInfo~ObjectData + * @property {number} amount - total balance + * @property {number} amountNet - net balance + */ diff --git a/lib/types/candle/array_data.js b/lib/types/candle/array_data.js new file mode 100644 index 0000000..f7e29b4 --- /dev/null +++ b/lib/types/candle/array_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link Candle} data in WSv2 array format. Suitable for passing to + * {@link Candle} to construct a model instance. + * + * @typedef {Array} Candle~ArrayData + * @property {number} 0 - mts + * @property {number} 1 - open + * @property {number} 2 - close + * @property {number} 3 - high + * @property {number} 4 - low + * @property {number} 5 - volume + */ diff --git a/lib/types/candle/data.js b/lib/types/candle/data.js new file mode 100644 index 0000000..7f72d83 --- /dev/null +++ b/lib/types/candle/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * Candle data either in WSv2 array or object format. + * + * @typedef {Candle|Candle~ObjectData|Candle~ArrayData} Candle~Data + */ diff --git a/lib/types/candle/object_data.js b/lib/types/candle/object_data.js new file mode 100644 index 0000000..a137479 --- /dev/null +++ b/lib/types/candle/object_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link Candle} data in plain object format. Suitable for passing to + * {@link Candle} to construct a model instance. + * + * @typedef {object} Candle~ObjectData + * @property {number} mts - timestamp + * @property {number} open - open price + * @property {number} close - close price + * @property {number} high - highest price in period + * @property {number} low - lowest price in period + * @property {number} volume - total volume in period + */ diff --git a/lib/types/change_log/array_data.js b/lib/types/change_log/array_data.js new file mode 100644 index 0000000..05871cb --- /dev/null +++ b/lib/types/change_log/array_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link ChangeLog} data in WSv2 array format. Suitable for passing to + * {@link ChangeLog} to construct a model instance. + * + * @typedef {Array} ChangeLog~ArrayData + * @property {number} 0 - mtsCreate + * @property {string} 2 - log + * @property {string} 5 - ip + * @property {string} 6 - userAgent + */ diff --git a/lib/types/change_log/data.js b/lib/types/change_log/data.js new file mode 100644 index 0000000..f58af22 --- /dev/null +++ b/lib/types/change_log/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * Change log data either in WSv2 array or object format. + * + * @typedef {ChangeLog|ChangeLog~ObjectData|ChangeLog~ArrayData} ChangeLog~Data + */ diff --git a/lib/types/change_log/object_data.js b/lib/types/change_log/object_data.js new file mode 100644 index 0000000..be4497a --- /dev/null +++ b/lib/types/change_log/object_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link ChangeLog} data in plain object format. Suitable for passing to + * {@link ChangeLog} to construct a model instance. + * + * @typedef {object} ChangeLog~ObjectData + * @property {number} mtsCreate - timestamp + * @property {string} log - log data + * @property {string} ip - ip + * @property {string} userAgent - user agent + */ diff --git a/lib/types/currency/array_data.js b/lib/types/currency/array_data.js new file mode 100644 index 0000000..876364e --- /dev/null +++ b/lib/types/currency/array_data.js @@ -0,0 +1,13 @@ +'use strict' + +/** + * {@link Currency} data in WSv2 array format. Suitable for passing to + * {@link Currency} to construct a model instance. + * + * @typedef {Array} Currency~ArrayData + * @property {string} 0 - id + * @property {string} 1 - name + * @property {string} 2 - pool + * @property {string} 3 - explorer + * @property {string} 4 - symbol + */ diff --git a/lib/types/currency/data.js b/lib/types/currency/data.js new file mode 100644 index 0000000..06709f7 --- /dev/null +++ b/lib/types/currency/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * Currency data either in WSv2 array or object format. + * + * @typedef {Currency|Currency~ObjectData|Currency~ArrayData} Currency~Data + */ diff --git a/lib/types/currency/object_data.js b/lib/types/currency/object_data.js new file mode 100644 index 0000000..f333d9e --- /dev/null +++ b/lib/types/currency/object_data.js @@ -0,0 +1,13 @@ +'use strict' + +/** + * {@link Currency} data in plain object format. Suitable for passing to + * {@link Currency} to construct a model instance. + * + * @typedef {object} Currency~ObjectData + * @property {string} id - id + * @property {string} name - currency name ('Ethereum') + * @property {string} pool - pool + * @property {string} exporer - explorer URL + * @property {string} symbol - symbol ('ETH') + */ diff --git a/lib/types/funding_credit/array_data.js b/lib/types/funding_credit/array_data.js new file mode 100644 index 0000000..f01325c --- /dev/null +++ b/lib/types/funding_credit/array_data.js @@ -0,0 +1,26 @@ +'use strict' + +/** + * {@link FundingCredit} data in WSv2 array format. Suitable for passing to a + * {@link FundingCredit} instance. + * + * @typedef {Array} FundingCredit~ArrayData + * @property {number} 0 - id + * @property {string} 1 - symbol + * @property {number} 2 - side + * @property {number} 3 - mtsCreate + * @property {number} 4 - mtsUpdate + * @property {number} 13 - mtsOpening + * @property {number} 14 - mtsLastPayout + * @property {number} 5 - amount + * @property {number} 6 - flags + * @property {number} 7 - status + * @property {number} 11 - rate + * @property {number} 19 - rateReal + * @property {number} 12 - period + * @property {string} 21 - positionPair + * @property {number} 15 - notify + * @property {number} 16 - hidden + * @property {number} 18 - renew + * @property {number} 20 - noClose + */ diff --git a/lib/types/funding_credit/data.js b/lib/types/funding_credit/data.js new file mode 100644 index 0000000..7b3eb1a --- /dev/null +++ b/lib/types/funding_credit/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingCredit} data either in WSv2 array or object format. + * + * @typedef {( + * FundingCredit|FundingCredit~ObjectData|FundingCredit~ArrayData + * )} FundingCredit~Data + */ diff --git a/lib/types/funding_credit/object_data.js b/lib/types/funding_credit/object_data.js new file mode 100644 index 0000000..fa23696 --- /dev/null +++ b/lib/types/funding_credit/object_data.js @@ -0,0 +1,26 @@ +'use strict' + +/** + * {@link FundingCredit} data in plain object format. Suitable for passing to + * {@link FundingCredit} to construct a model instance. + * + * @typedef {object} FundingCredit~ObjectData + * @property {number} id - id + * @property {string} symbol - symbol + * @property {number} side - side + * @property {number} mtsCreate - creation timestamp + * @property {number} mtsUpdate - last update timestamp + * @property {number} mtsOpening - open timestamp + * @property {number} mtsLastPayout - last payout timestamp + * @property {number} amount - remaining amount + * @property {number} flags - flags + * @property {number} status - current status + * @property {number} rate - rate + * @property {number} rateReal - rate + * @property {number} period - period + * @property {string} positionPair - position pair + * @property {number|boolean} notify - notify flag + * @property {number|boolean} hidden - hidden flag + * @property {number|boolean} renew - renew flag + * @property {number|boolean} noClose - no-close flag + */ diff --git a/lib/types/funding_loan/array_data.js b/lib/types/funding_loan/array_data.js new file mode 100644 index 0000000..cafd545 --- /dev/null +++ b/lib/types/funding_loan/array_data.js @@ -0,0 +1,26 @@ +'use strict' + +/** + * {@link FundingLoan} data in WSv2 array format. Suitable for passing to + * {@link FundingLoan} to construct a model instance. + * + * @typedef {Array} FundingLoan~ArrayData + * @property {number} 0 - id + * @property {string} 1 - symbol + * @property {number} 2 - side + * @property {number} 3 - mtsCreate + * @property {number} 4 - mtsUpdate + * @property {number} 13 - mtsOpening + * @property {number} 14 - mtsLastPayout + * @property {number} 5 - amount + * @property {number} 6 - flags + * @property {number} 7 - status + * @property {string} 8 - type + * @property {number} 11 - rate + * @property {number} 19 - rateReal + * @property {number} 12 - period + * @property {number} 15 - notify + * @property {number} 16 - hidden + * @property {number} 18 - renew + * @property {number} 20 - noClose + */ diff --git a/lib/types/funding_loan/data.js b/lib/types/funding_loan/data.js new file mode 100644 index 0000000..3ec0cd2 --- /dev/null +++ b/lib/types/funding_loan/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingLoan} data either in WSv2 array or object format. + * + * @typedef {( + * FundingLoan|FundingLoan~ObjectData|FundingLoan~ArrayData + * )} FundingLoan~Data + */ diff --git a/lib/types/funding_loan/object_data.js b/lib/types/funding_loan/object_data.js new file mode 100644 index 0000000..e12f191 --- /dev/null +++ b/lib/types/funding_loan/object_data.js @@ -0,0 +1,25 @@ +'use strict' + +/** + * {@link FundingLoan} data in plain object format. Suitable for passing to + * {@link FundingLoan} to construct a model instance. + * + * @typedef {object} FundingLoan~ObjectData + * @property {number} id - id + * @property {string} symbol - symbol + * @property {number} side - side + * @property {number} mtsCreate - creation timestamp + * @property {number} mtsUpdate - last update timestamp + * @property {number} mtsOpening - open timestamp + * @property {number} mtsLastPayout - last payout timestamp + * @property {number} amount - amount + * @property {number} flags - flags + * @property {number} status - status + * @property {number} rate - rate + * @property {number} rateReal - rate real + * @property {number} period - period flag + * @property {number|boolean} notify - notify flag + * @property {number|boolean} hidden - hidden flag + * @property {number|boolean} renew - renew flag + * @property {number|boolean} noClose - no-close flag + */ diff --git a/lib/types/funding_offer/array_data.js b/lib/types/funding_offer/array_data.js new file mode 100644 index 0000000..a3bbe32 --- /dev/null +++ b/lib/types/funding_offer/array_data.js @@ -0,0 +1,23 @@ +'use strict' + +/** + * {@link FundingOffer} data in WSv2 array format. Suitable for passing to + * {@link FundingOffer} to construct a model instance. + * + * @typedef {Array} FundingOffer~ArrayData + * @property {number} 0 - id + * @property {string} 1 - symbol + * @property {number} 2 - mtsCreate + * @property {number} 3 - mtsUpdate + * @property {number} 4 - amount + * @property {number} 5 - amountOrig + * @property {string} 6 - type + * @property {number} 9 - flags + * @property {string} 10 - status + * @property {number} 14 - rate + * @property {number} 15 - period + * @property {number} 16 - notify + * @property {number} 17 - hidden + * @property {number} 19 - renew + * @property {number} 20 - rateReal + */ diff --git a/lib/types/funding_offer/data.js b/lib/types/funding_offer/data.js new file mode 100644 index 0000000..30e4ec1 --- /dev/null +++ b/lib/types/funding_offer/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingOffer} data either in WSv2 array or object format. + * + * @typedef {( + * FundingOffer|FundingOffer~ObjectData|FundingOffer~ArrayData + * )} FundingOffer~Data + */ diff --git a/lib/types/funding_offer/object_data.js b/lib/types/funding_offer/object_data.js new file mode 100644 index 0000000..bed38fd --- /dev/null +++ b/lib/types/funding_offer/object_data.js @@ -0,0 +1,23 @@ +'use strict' + +/** + * {@link FundingOffer} data in plain object format. Suitable for passing to + * {@link FundingOffer} to construct a model instance. + * + * @typedef {object} FundingOffer~ObjectData + * @property {number} id - id + * @property {string} symbol - symbol + * @property {number} mtsCreate - creation timestamp + * @property {number} mtsUpdate - last update timestamp + * @property {string} amount - remaining amount + * @property {string} amountOrig - original amount + * @property {string} type - funding offer type + * @property {number} flags - flags + * @property {string} status - current status + * @property {number} rate - rate + * @property {number} rateReal - rate real + * @property {number} period - period for the offer + * @property {number|boolean} notify - notify flag + * @property {number|boolean} hidden - hidden flag + * @property {number|boolean} renew - renew flag + */ diff --git a/lib/types/funding_offer/submit_payload.js b/lib/types/funding_offer/submit_payload.js new file mode 100644 index 0000000..84486b8 --- /dev/null +++ b/lib/types/funding_offer/submit_payload.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * A set of parameters describing an atomic {@link FundingOffer} that can be + * sent via the WSv2 API. + * + * @typedef {object} FundingOffer~SubmitPayload + * @property {string} type - type + * @property {string} symbol - symbol + * @property {string} amount - amount + * @property {string} rate - rate + * @property {number} period - period + * @property {number} flags - flags + */ diff --git a/lib/types/funding_ticker/array_data.js b/lib/types/funding_ticker/array_data.js new file mode 100644 index 0000000..f9f235e --- /dev/null +++ b/lib/types/funding_ticker/array_data.js @@ -0,0 +1,22 @@ +'use strict' + +/** + * {@link FundingTicker} data in WSv2 array format. Suitable for passing to + * {@link FundingTicker} instance. + * + * @typedef {Array} FundingTicker~ArrayData + * @property {string} 0 - symbol + * @property {number} 1 - frr + * @property {number} 2 - bid + * @property {number} 3 - bidSize + * @property {number} 4 - bidPeriod + * @property {number} 5 - ask + * @property {number} 6 - askSize + * @property {number} 7 - askPeriod + * @property {number} 8 - dailyChange + * @property {number} 9 - dailyChangePerc + * @property {number} 10 - lastPrice + * @property {number} 11 - volume + * @property {number} 12 - high + * @property {number} 13 - low + */ diff --git a/lib/types/funding_ticker/data.js b/lib/types/funding_ticker/data.js new file mode 100644 index 0000000..7913af5 --- /dev/null +++ b/lib/types/funding_ticker/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingTicker} data either in WSv2 array or object format. + * + * @typedef {( + * FundingTicker|FundingTicker~ObjectData|FundingTicker~ArrayData + * )} FundingTicker~Data + */ diff --git a/lib/types/funding_ticker/object_data.js b/lib/types/funding_ticker/object_data.js new file mode 100644 index 0000000..329a261 --- /dev/null +++ b/lib/types/funding_ticker/object_data.js @@ -0,0 +1,22 @@ +'use strict' + +/** + * {@link FundingTicker} data in plain object format. Suitable for passing to + * {@link FundingTicker} to construct a model instance. + * + * @typedef {object} FundingTicker~ObjectData + * @property {string} symbol - symbol + * @property {number|boolean} frr - current FRR + * @property {number} bid - best bid + * @property {number} bidSize - total bid amount + * @property {number} bidPeriod - bid period + * @property {number} ask - best ask + * @property {number} askSize - total ask amount + * @property {number} askPeriod - ask period + * @property {number} dailyChange - net 24h period change + * @property {number} dailyChangePerc - net 24h period change as percent + * @property {number} lastPrice - last price + * @property {number} volume - total volume in last 24h period + * @property {number} high - highest rate in last 24h period + * @property {number} low - lowest rate in last 24h period + */ diff --git a/lib/types/funding_ticker_hist/array_data.js b/lib/types/funding_ticker_hist/array_data.js new file mode 100644 index 0000000..f7ba708 --- /dev/null +++ b/lib/types/funding_ticker_hist/array_data.js @@ -0,0 +1,13 @@ +'use strict' + +/** + * {@link FundingTickerHist} data in WSv2 array format. Suitable for passing to + * {@link FundingTickerHist} to construct a model instance. + * + * @typedef {Array} FundingTickerHist~ArrayData + * @property {string} 0 - symbol + * @property {number} 2 - bid + * @property {number} 4 - bidPeriod + * @property {number} 5 - ask + * @property {number} 15 - mtsUpdate + */ diff --git a/lib/types/funding_ticker_hist/data.js b/lib/types/funding_ticker_hist/data.js new file mode 100644 index 0000000..67475ae --- /dev/null +++ b/lib/types/funding_ticker_hist/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingTickerHist} data either in WSv2 array or object format. + * + * @typedef {( + * FundingTickerHist|FundingTickerHist~ObjectData|FundingTickerHist~ArrayData + * )} FundingTickerHist~Data + */ diff --git a/lib/types/funding_ticker_hist/object_data.js b/lib/types/funding_ticker_hist/object_data.js new file mode 100644 index 0000000..40e28ac --- /dev/null +++ b/lib/types/funding_ticker_hist/object_data.js @@ -0,0 +1,13 @@ +'use strict' + +/** + * {@link FundingTickerHist} data in plain object format. Suitable for passing + * to {@link FundingTickerHist} to construct a model instance. + * + * @typedef {object} FundingTickerHist~ObjectData + * @property {string} symbol - symbol + * @property {number} bid - bid + * @property {number} bidPeriod - bid period + * @property {number} ask - ask + * @property {number} mtsUpdate - timestamp + */ diff --git a/lib/types/funding_trade/array_data.js b/lib/types/funding_trade/array_data.js new file mode 100644 index 0000000..b2aa7fc --- /dev/null +++ b/lib/types/funding_trade/array_data.js @@ -0,0 +1,16 @@ +'use strict' + +/** + * {@link FundingTrade} data in WSv2 array format. Suitable for passing to + * {@link FundingTrade} to construct a model instance. + * + * @typedef {Array} FundingTrade~ArrayData + * @property {number} 0 - id + * @property {string} 1 - symbol + * @property {number} 2 - mtsCreate + * @property {number} 3 - offerID + * @property {number} 4 - amount + * @property {number} 5 - rate + * @property {number} 6 - period + * @property {number} 7 - maker + */ diff --git a/lib/types/funding_trade/data.js b/lib/types/funding_trade/data.js new file mode 100644 index 0000000..f46bc9d --- /dev/null +++ b/lib/types/funding_trade/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link FundingTrade} data either in WSv2 array or object format. + * + * @typedef {( + * FundingTrade|FundingTrade~ObjectData|FundingTrade~ArrayData + * )} FundingTrade~Data + */ diff --git a/lib/types/funding_trade/object_data.js b/lib/types/funding_trade/object_data.js new file mode 100644 index 0000000..ef7b297 --- /dev/null +++ b/lib/types/funding_trade/object_data.js @@ -0,0 +1,16 @@ +'use strict' + +/** + * {@link FundingTrade} data in plain object format. Suitable for passing to + * {@link FundingTrade} to construct a model instance. + * + * @typedef {object} FundingTrade~ObjectData + * @property {number} id - id + * @property {string} symbol - symbol + * @property {number} mtsCreate - creation timestamp + * @property {number} offerID - taken offer ID + * @property {number} amount - amount + * @property {number} rate - rate + * @property {number} period - period + * @property {number|boolean} maker - maker flag + */ diff --git a/lib/types/ledger_entry/array_data.js b/lib/types/ledger_entry/array_data.js new file mode 100644 index 0000000..b112965 --- /dev/null +++ b/lib/types/ledger_entry/array_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link LedgerEntry} data in WSv2 array format. Suitable for passing to + * {@link LedgerEntry} to construct a model instance. + * + * @typedef {Array} LedgerEntry~ArrayData + * @property {number} 0 - id + * @property {string} 1 - currency + * @property {number} 3 - mts + * @property {number} 5 - amount + * @property {number} 6 - balance + * @property {string} 8 - description + */ diff --git a/lib/types/ledger_entry/data.js b/lib/types/ledger_entry/data.js new file mode 100644 index 0000000..ae263a4 --- /dev/null +++ b/lib/types/ledger_entry/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link LedgerEntry} data either in WSv2 array or object format. + * + * @typedef {( + * LedgerEntry|LedgerEntry~ObjectData|LedgerEntry~ArrayData + * )} LedgerEntry~Data + */ diff --git a/lib/types/ledger_entry/object_data.js b/lib/types/ledger_entry/object_data.js new file mode 100644 index 0000000..530af7d --- /dev/null +++ b/lib/types/ledger_entry/object_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link LedgerEntry} data in plain object format. Suitable for passing to + * {@link LedgerEntry} to construct a model instance. + * + * @typedef {object} LedgerEntry~ObjectData + * @property {number} id - id + * @property {string} currency - currency + * @property {number} mts - transaction timestamp + * @property {number} amount - transaction amount + * @property {number} balance - balance at time of transaction + * @property {string} description - transaction description + */ diff --git a/lib/types/liquidations/array_data.js b/lib/types/liquidations/array_data.js new file mode 100644 index 0000000..c7da999 --- /dev/null +++ b/lib/types/liquidations/array_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link Liquidations} data in WSv2 array format. Suitable for passing to + * {@link Liquidations} to construct a model instance. + * + * @typedef {Array} Liquidations~ArrayData + * @property {number} 1 - posId + * @property {number} 2 - mtsUpdated + * @property {string} 4 - symbol + * @property {number} 5 - amount + * @property {number} 6 - basePrice + * @property {number} 8 - isMatch + * @property {number} 9 - isMarketSold + */ diff --git a/lib/types/liquidations/data.js b/lib/types/liquidations/data.js new file mode 100644 index 0000000..43c45e4 --- /dev/null +++ b/lib/types/liquidations/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link Liquidations} data either in WSv2 array or object format. + * + * @typedef {( + * Liquidations|Liquidations~ObjectData|Liquidations~ArrayData + * )} Liquidations~Data + */ diff --git a/lib/types/liquidations/object_data.js b/lib/types/liquidations/object_data.js new file mode 100644 index 0000000..05c47f5 --- /dev/null +++ b/lib/types/liquidations/object_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link Liquidations} data in plain object format. Suitable for passing to + * {@link Liquidations} to construct a model instance. + * + * @typedef {object} Liquidations~ObjectData + * @property {number} posId - position ID + * @property {number} mtsUpdated - timestamp + * @property {string} symbol - symbol + * @property {number} amount - amount + * @property {number} basePrice - base price + * @property {number|boolean} isMatch - matched flag + * @property {number|boolean} isMarketSold - sold flag + */ diff --git a/lib/types/login/array_data.js b/lib/types/login/array_data.js new file mode 100644 index 0000000..5045a94 --- /dev/null +++ b/lib/types/login/array_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link Login} data in WSv2 array format. Suitable for passing to + * {@link Login} to construct a model instance. + * + * @typedef {Array} Login~ArrayData + * @property {number} 0 - id + * @property {number} 2 - time + * @property {string} 4 - ip + * @property {object} 7 - extraData + */ diff --git a/lib/types/login/data.js b/lib/types/login/data.js new file mode 100644 index 0000000..3fd0768 --- /dev/null +++ b/lib/types/login/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Login} data either in WSv2 array or object format. + * + * @typedef {Login|Login~ObjectData|Login~ArrayData} Login~Data + */ diff --git a/lib/types/login/object_data.js b/lib/types/login/object_data.js new file mode 100644 index 0000000..e4a1557 --- /dev/null +++ b/lib/types/login/object_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link Login} data in plain object format. Suitable for passing to + * {@link Login} to construct a model instance. + * + * @typedef {object} Login~ObjectData + * @property {number} id - id + * @property {number} time - timestamp + * @property {string} ip - client IP address + * @property {object} extraData - metadata + */ diff --git a/lib/types/movement/array_data.js b/lib/types/movement/array_data.js new file mode 100644 index 0000000..6a67534 --- /dev/null +++ b/lib/types/movement/array_data.js @@ -0,0 +1,18 @@ +'use strict' + +/** + * {@link Movement} data in WSv2 array format. Suitable for passing to + * {@link Movement} to construct a model instance. + * + * @typedef {Array} Movement~ArrayData + * @property {number} 0 - id + * @property {string} 1 - currency + * @property {string} 2 - currencyName + * @property {number} 5 - mtsStarted + * @property {number} 6 - mtsUpdated + * @property {string} 9 - status + * @property {number} 12 - amount + * @property {number} 13 - fees + * @property {string} 16 - destinationAddress + * @property {number} 20 - transactionId + */ diff --git a/lib/types/movement/data.js b/lib/types/movement/data.js new file mode 100644 index 0000000..328fdde --- /dev/null +++ b/lib/types/movement/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Movement} data either in WSv2 array or object format. + * + * @typedef {Movement|Movement~ObjectData|Movement~ArrayData} Movement~Data + */ diff --git a/lib/types/movement/object_data.js b/lib/types/movement/object_data.js new file mode 100644 index 0000000..8b291e4 --- /dev/null +++ b/lib/types/movement/object_data.js @@ -0,0 +1,18 @@ +'use strict' + +/** + * {@link Movement} data in plain object format. Suitable for passing to + * {@link Movement} to construct a model instance. + * + * @typedef {object} Movement~ObjectData + * @property {number} id - id + * @property {string} currency - currency + * @property {string} currencyName - currency name + * @property {number} mtsStarted - movement start timestamp + * @property {number} mtsUpdated - last update timestamp + * @property {string} status - status + * @property {number} amount - moved amount + * @property {number} fees - paid fees + * @property {string} destinationAddress - destination address + * @property {number} transactionId - transaction ID + */ diff --git a/lib/types/notification/array_data.js b/lib/types/notification/array_data.js new file mode 100644 index 0000000..3cc221e --- /dev/null +++ b/lib/types/notification/array_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link Notification} data in WSv2 array format. Suitable for passing to + * {@link Notification} to construct a model instance. + * + * @typedef {Array} Notification~ArrayData + * @property {number} 0 - mts + * @property {string} 1 - type + * @property {number} 2 - messageID + * @property {object} 4 - notifyInfo + * @property {number} 5 - code + * @property {string} 6 - status + * @property {string} 7 - text + */ diff --git a/lib/types/notification/broadcast_payload.js b/lib/types/notification/broadcast_payload.js new file mode 100644 index 0000000..0460687 --- /dev/null +++ b/lib/types/notification/broadcast_payload.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * Body of a broadcast (`ucm-*`) {@link Notification}} which may be sent via + * the WSv2 API. + * + * @typedef {object} Notification~BroadcastPayload + * @property {string} [message] - message to display + * @property {string} [type] - notification type, must be prefixed with 'ucm-*' + * for broadcasts + * @property {string} [level] - 'info', 'error', or 'success' + * @property {string} [image] - link to an image to be shown + * @property {string} [link] - URL the notification should forward too + * @property {string} [sound] - URL of sound to play + */ diff --git a/lib/types/notification/data.js b/lib/types/notification/data.js new file mode 100644 index 0000000..2006193 --- /dev/null +++ b/lib/types/notification/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link Notification} data either in WSv2 array or object format. + * + * @typedef {( + * Notification|Notification~ObjectData|Notification~ArrayData + * )} Notification~Data + */ diff --git a/lib/types/notification/object_data.js b/lib/types/notification/object_data.js new file mode 100644 index 0000000..61a1284 --- /dev/null +++ b/lib/types/notification/object_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link Notification} data in plain object format. Suitable for passing to + * {@link Notification} to construct a model instance. + * + * @typedef {object} Notification~ObjectData + * @property {number} mts - timestamp + * @property {string} type - type (i.e. 'ucm-*' for broadcasts) + * @property {number} messageID - message ID + * @property {object} notifyInfo - metadata, set by client for broadcasts + * @property {number} code - code + * @property {string} status - status (i.e. 'error') + * @property {string} text - notification text to display to user + */ diff --git a/lib/types/order/array_data.js b/lib/types/order/array_data.js new file mode 100644 index 0000000..e6b72eb --- /dev/null +++ b/lib/types/order/array_data.js @@ -0,0 +1,30 @@ +'use strict' + +/** + * {@link Order} data in WSv2 array format. Suitable for passing to + * {@link Order} to construct a model instance. + * + * @typedef {Array} Order~ArrayData + * @property {number} 0 - id + * @property {number} 1 - gid + * @property {number} 2 - cid + * @property {string} 3 - symbol + * @property {number} 4 - mtsCreate + * @property {number} 5 - mtsUpdate + * @property {number} 6 - amount + * @property {number} 7 - amountOrig + * @property {Order~Type} 8 - type + * @property {Order~Type} 9 - typePrev + * @property {number} 10 - mtsTIF + * @property {number} 12 - flags + * @property {string} 13 - status + * @property {number} 16 - price + * @property {number} 17 - priceAvg + * @property {number} 18 - priceTrailing + * @property {number} 19 - priceAuxLimit + * @property {number} 23 - notify + * @property {number} 24 - hidden + * @property {number} 25 - placedId + * @property {string} 28 - routing + * @property {object} 31 - meta + */ diff --git a/lib/types/order/data.js b/lib/types/order/data.js new file mode 100644 index 0000000..f10ccc6 --- /dev/null +++ b/lib/types/order/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Order} data either in WSv2 array or object format. + * + * @typedef {Order|Order~ObjectData|Order~ArrayData} Order~Data + */ diff --git a/lib/types/order/object_data.js b/lib/types/order/object_data.js new file mode 100644 index 0000000..bdc2f52 --- /dev/null +++ b/lib/types/order/object_data.js @@ -0,0 +1,29 @@ +'use strict' + +/** + * {@link Order} data in plain object format. Suitable for passing to + * {@link Order} to construct a model instance. + * + * @typedef {object} Order~ObjectData + * @property {number} id - ID + * @property {number} [gid] - group ID + * @property {number} [cid] - client ID + * @property {string} symbol - symbol + * @property {number} [mtsCreate] - creation timestamp + * @property {number} [mtsUpdate] - last update timestamp + * @property {string} amount - remaining order amount + * @property {string} [amountOrig] - original/initial order amount + * @property {Order~Type} [type] - order type + * @property {Order~Type} [typePrev] - previous type + * @property {number} [mtsTIF] - TIF timestamp, if set + * @property {number} [flags] - order flags + * @property {string} [status] - current order status + * @property {string} price - order price + * @property {string} [priceAvg] - average execution price + * @property {string} [priceTrailing] - trailing distance for TRAILING STOP orders + * @property {string} [priceAuxLimit] - stop price for STOP LIMIT and OCO orders + * @property {number|boolean} [notify] - notify flag + * @property {number} [placedId] - placed ID + * @property {string} [affiliateCode] - affiliate code + * @property {number} [lev] - leverage + */ diff --git a/lib/types/order/preview.js b/lib/types/order/preview.js new file mode 100644 index 0000000..5a6b81d --- /dev/null +++ b/lib/types/order/preview.js @@ -0,0 +1,16 @@ +'use strict' + +/** + * Preview of an {@link Order} for display in an UI, prior to submission + * + * @typedef {object} Order~Preview + * @property {number} gid - group id + * @property {number} cid - client ID + * @property {string} symbol - symbol + * @property {number} amount - amount + * @property {Order~Type} type - type + * @property {number} [price] - price, optional for `MARKET` orders + * @property {number} notify - notify flag + * @property {number} flags - flags + * @property {number} [lev] - leverage + */ diff --git a/lib/types/order/submit_payload.js b/lib/types/order/submit_payload.js new file mode 100644 index 0000000..11ffc88 --- /dev/null +++ b/lib/types/order/submit_payload.js @@ -0,0 +1,24 @@ +'use strict' + +/** + * A set of parameters describing an atomic order that can be sent via the WSv2 + * API to submit it. + * + * @typedef {object} Order~SubmitPayload + * @property {number} [gid] - group ID + * @property {number} [cid] - client ID + * @property {string} symbol - symbol + * @property {Order~Type} type - type + * @property {number} amount - amount + * @property {number} [price] - optional for `MARKET` orders + * @property {number} [price_trailing] - required for `TRAILING STOP` orders + * @property {number} [price_aux_limit] - required for `STOP LIMIT` and `OCO` + * orders + * @property {number} [price_oco_stop] - required for `OCO` orders + * @property {number} [cid_oco] - required for `OCO` orders + * @property {number} [lev] - leverage + * @property {number} [flags=0] - flags + * @property {object} [meta={}] - metadata + * @property {string} [meta.aff_code] - affiliate code + * @property {number} [tif] - time in force + */ diff --git a/lib/types/order/types.js b/lib/types/order/types.js new file mode 100644 index 0000000..60a33ef --- /dev/null +++ b/lib/types/order/types.js @@ -0,0 +1,20 @@ +'use strict' + +/** + * Valid atomic order types, see the {@link Order} model. + * + * @typedef {( + * 'MARKET'| + * 'EXCHANGE MARKET'| + * 'LIMIT'| + * 'EXCHANGE LIMIT'| + * 'STOP'| + * 'EXCHANGE STOP'| + * 'TRAILING STOP'| + * 'EXCHANGE TRAILING STOP'| + * 'FOK'| + * 'EXCHANGE FOK'| + * 'STOP LIMIT'| + * 'EXCHANGE STOP LIMIT' + * )} Order~Type + */ diff --git a/lib/types/order_book/aggregated_funding_price_level.js b/lib/types/order_book/aggregated_funding_price_level.js new file mode 100644 index 0000000..94b3c2d --- /dev/null +++ b/lib/types/order_book/aggregated_funding_price_level.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * An aggregate (non-raw) {@link OrderBook} **funding** ticker price level in + * object format. + * + * @typedef {object} OrderBook~AggregatedFundingPriceLevel + * @property {number} rate - rate + * @property {number} period - period + * @property {number} amount - amount + * @property {number} count - count + */ diff --git a/lib/types/order_book/aggregated_price_level.js b/lib/types/order_book/aggregated_price_level.js new file mode 100644 index 0000000..990f4e8 --- /dev/null +++ b/lib/types/order_book/aggregated_price_level.js @@ -0,0 +1,10 @@ +'use strict' + +/** + * An aggregate (non-raw) {@link OrderBook} price level in object format. + * + * @typedef {object} OrderBook~AggregatedPriceLevel + * @property {number} price - price + * @property {number} amount - amount + * @property {number} count - count + */ diff --git a/lib/types/order_book/array_data.js b/lib/types/order_book/array_data.js new file mode 100644 index 0000000..c541835 --- /dev/null +++ b/lib/types/order_book/array_data.js @@ -0,0 +1,8 @@ +'use strict' + +/** + * {@link OrderBook} data in WSv2 array format. Suitable for passing to + * {@link OrderBook} to construct a model instance. + * + * @typedef {OrderBook~ArrayPriceLevel[]} OrderBook~ArrayData + */ diff --git a/lib/types/order_book/array_price_level.js b/lib/types/order_book/array_price_level.js new file mode 100644 index 0000000..b0e0117 --- /dev/null +++ b/lib/types/order_book/array_price_level.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * A single price level for an {@link OrderBook} model, in WSv2 array format. + * + * @typedef {number[]} OrderBook~ArrayPriceLevel + */ diff --git a/lib/types/order_book/data.js b/lib/types/order_book/data.js new file mode 100644 index 0000000..9b028db --- /dev/null +++ b/lib/types/order_book/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link OrderBook} data either in WSv2 array or object format. + * + * @typedef {OrderBook|OrderBook~ObjectData|OrderBook~ArrayData} OrderBook~Data + */ diff --git a/lib/types/order_book/object_data.js b/lib/types/order_book/object_data.js new file mode 100644 index 0000000..1b62c95 --- /dev/null +++ b/lib/types/order_book/object_data.js @@ -0,0 +1,8 @@ +'use strict' + +/** + * {@link OrderBook} data as an array of price levels in object format. + * Suitable for passing to {@link OrderBook} to construct a model instance. + * + * @typedef {OrderBook~ObjectPriceLevel[]} OrderBook~ObjectData + */ diff --git a/lib/types/order_book/object_price_level.js b/lib/types/order_book/object_price_level.js new file mode 100644 index 0000000..5168925 --- /dev/null +++ b/lib/types/order_book/object_price_level.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * A single price level for an {@link OrderBook} model, in object format. + * Contents vary depending between raw & standard order books, and between + * trading & funding tickers. + * + * @typedef {( + * OrderBook~AggregatedFundingPriceLevel| + * OrderBook~AggregatedPriceLevel| + * OrderBook~RawFundingPriceLevel| + * OrderBook~RawPriceLevel + * )} OrderBook~ObjectPriceLevel + */ diff --git a/lib/types/order_book/raw_funding_price_level.js b/lib/types/order_book/raw_funding_price_level.js new file mode 100644 index 0000000..04b339d --- /dev/null +++ b/lib/types/order_book/raw_funding_price_level.js @@ -0,0 +1,11 @@ +'use strict' + +/** + * A raw {@link OrderBook} **funding** price level in object format. + * + * @typedef {object} OrderBook~RawFundingPriceLevel + * @property {number} rate - rate + * @property {number} period - period + * @property {number} amount - amount + * @property {number} orderID - order ID + */ diff --git a/lib/types/order_book/raw_price_level.js b/lib/types/order_book/raw_price_level.js new file mode 100644 index 0000000..1831bb1 --- /dev/null +++ b/lib/types/order_book/raw_price_level.js @@ -0,0 +1,10 @@ +'use strict' + +/** + * A raw {@link OrderBook} price level in object format. + * + * @typedef {object} OrderBook~RawPriceLevel + * @property {number} price - price + * @property {number} amount - amount + * @property {number} orderID - order ID + */ diff --git a/lib/types/position/array_data.js b/lib/types/position/array_data.js new file mode 100644 index 0000000..c249bde --- /dev/null +++ b/lib/types/position/array_data.js @@ -0,0 +1,25 @@ +'use strict' + +/** + * {@link Position} data in WSv2 array format. Suitable for passing to + * {@link Position} to construct a model instance. + * + * @typedef {Array} Position~ArrayData + * @property {string} 0 - symbol + * @property {string} 1 - status + * @property {number} 2 - amount + * @property {string} 3 - basePrice + * @property {string} 4 - marginFunding + * @property {string} 5 - marginFundingType + * @property {string} 6 - pl + * @property {string} 7 - plPerc + * @property {string} 8 - liquidationPrice + * @property {number} 9 - leverage + * @property {number} 11 - id + * @property {number} 12 - mtsCreate + * @property {number} 13 - mtsUpdate + * @property {string} 15 - type + * @property {number} 17 - collateral + * @property {number} 18 - collateralMin + * @property {object} 19 - meta + */ diff --git a/lib/types/position/data.js b/lib/types/position/data.js new file mode 100644 index 0000000..30a277c --- /dev/null +++ b/lib/types/position/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Position} data either in WSv2 array or object format. + * + * @typedef {Position|Position~ObjectData|Position~ArrayData} Position~Data + */ diff --git a/lib/types/position/object_data.js b/lib/types/position/object_data.js new file mode 100644 index 0000000..4ec1819 --- /dev/null +++ b/lib/types/position/object_data.js @@ -0,0 +1,25 @@ +'use strict' + +/** + * {@link Position} data in plain object format. Suitable for passing to + * {@link Position} to construct a model instance. + * + * @typedef {object} Position~ObjectData + * @property {number} id - id + * @property {number} mtsCreate - creation timestamp + * @property {number} mtsUpdate - last update timestamp + * @property {string} symbol - symbol + * @property {string} status - status + * @property {string} type - type + * @property {string} amount - amount + * @property {string} basePrice - base price + * @property {string} marginFunding - margin funding + * @property {string} marginFundingType - margin funding type + * @property {string} pl - profit/loss + * @property {string} plPerc - profit/loss as percentage + * @property {string} liquidationPrice - liquidation price + * @property {number} leverage - leverage + * @property {number} collateral - collateral + * @property {number} collateralMin - minimum collateral to maintain position + * @property {object} meta - metadata + */ diff --git a/lib/types/public_pulse_profile/array_data.js b/lib/types/public_pulse_profile/array_data.js new file mode 100644 index 0000000..3c49155 --- /dev/null +++ b/lib/types/public_pulse_profile/array_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link PublicPulseProfile} data in WSv2 array format. Suitable for passing + * to {@link PublicPulseProfile} instance. + * + * @typedef {Array} PublicPulseProfile~ArrayData + * @property {string} 0 - id + * @property {number} 1 - mtsCreate + * @property {string} 3 - nickname + * @property {string} 5 - picture + * @property {string} 6 - text + * @property {string} 9 - twitterHandle + */ diff --git a/lib/types/public_pulse_profile/data.js b/lib/types/public_pulse_profile/data.js new file mode 100644 index 0000000..89db3d6 --- /dev/null +++ b/lib/types/public_pulse_profile/data.js @@ -0,0 +1,11 @@ +'use strict' + +/** + * {@link PublicPulseProfile} data either in WSv2 array or object format. + * + * @typedef { + * PublicPulseProfile| + * PublicPulseProfile~ObjectData| + * PublicPulseProfile~ArrayData + * } PublicPulseProfile~Data + */ diff --git a/lib/types/public_pulse_profile/object_data.js b/lib/types/public_pulse_profile/object_data.js new file mode 100644 index 0000000..ab08ce2 --- /dev/null +++ b/lib/types/public_pulse_profile/object_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link PublicPulseProfile} data in plain object format. Suitable for passing + * to {@link PublicPulseProfile} to construct a model instance. + * + * @typedef {object} PublicPulseProfile~ObjectData + * @property {string} id - pulse User ID + * @property {number} mtsCreate - creation timestamp + * @property {string} nickname - profile nickname + * @property {string} picture - profile picture + * @property {string} text - profile bio + * @property {string} twitterHandle - profile twitter handle + */ diff --git a/lib/types/pulse_message/array_data.js b/lib/types/pulse_message/array_data.js new file mode 100644 index 0000000..5f1a329 --- /dev/null +++ b/lib/types/pulse_message/array_data.js @@ -0,0 +1,19 @@ +'use strict' + +/** + * {@link PulseMessage} data in WSv2 array format. Suitable for passing to + * {@link PulseMessage} to construct a model instance. + * + * @typedef {Array} PulseMessage~ArrayData + * @property {string} 0 - id + * @property {number} 1 - mts + * @property {string} 3 - userID + * @property {string} 5 - title + * @property {string} 6 - content + * @property {number} 9 - isPin + * @property {number} 10 - isPublic + * @property {string} 12 - tags + * @property {string} 13 - attachments + * @property {number} 15 - likes + * @property {number} 16 - userLiked + */ diff --git a/lib/types/pulse_message/data.js b/lib/types/pulse_message/data.js new file mode 100644 index 0000000..c068851 --- /dev/null +++ b/lib/types/pulse_message/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link PulseMessage} data either in WSv2 array or object format. + * + * @typedef {( + * PulseMessage|PulseMessage~ObjectData|PulseMessage~ArrayData + * )} PulseMessage~Data + */ diff --git a/lib/types/pulse_message/object_data.js b/lib/types/pulse_message/object_data.js new file mode 100644 index 0000000..dcf490a --- /dev/null +++ b/lib/types/pulse_message/object_data.js @@ -0,0 +1,21 @@ +'use strict' + +/** + * {@link PulseMessage} data in plain object format. Suitable for passing to + * {@link PulseMessage} to construct a model instance. + * + * @typedef {object} PulseMessage~ObjectData + * @property {string} id - pulse message ID + * @property {number} mts - millisecond timestamp + * @property {string} userID - pulse User ID + * @property {string} title - title of the pulse message + * @property {string} content - content of the pulse message + * @property {number} isPin - 1 if the message is pinned, 0 if it is not pinned + * @property {number} isPublic - 1 if the message is public, 0 if it is not + * public + * @property {string} tags - tags used in the message + * @property {string} attachments - attachments used in the message + * @property {number} likes - number of likes + * @property {number} userLiked - flag to show if the private user liked the + * pulse + */ diff --git a/lib/types/status_messages_deriv/array_data.js b/lib/types/status_messages_deriv/array_data.js new file mode 100644 index 0000000..8a2d452 --- /dev/null +++ b/lib/types/status_messages_deriv/array_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link StatusMessagesDeriv} data in WSv2 array format. Suitable for passing + * to {@link StatusMessagesDeriv} to construct a model instance. + * + * @typedef {Array} StatusMessagesDeriv~ArrayData + * @property {string} 0 - key + * @property {number} 1 - timestamp + * @property {number} 3 - price + * @property {number} 4 - priceSpot + * @property {number} 6 - fundBal + * @property {number} 9 - fundingAccrued + * @property {number} 10 - fundingStep + */ diff --git a/lib/types/status_messages_deriv/data.js b/lib/types/status_messages_deriv/data.js new file mode 100644 index 0000000..d1b4004 --- /dev/null +++ b/lib/types/status_messages_deriv/data.js @@ -0,0 +1,11 @@ +'use strict' + +/** + * {@link StatusMessagesDeriv} data either in WSv2 array or object format. + * + * @typedef {( + * StatusMessagesDeriv| + * StatusMessagesDeriv~ObjectData| + * StatusMessagesDeriv~ArrayData + * )} StatusMessagesDeriv~Data + */ diff --git a/lib/types/status_messages_deriv/object_data.js b/lib/types/status_messages_deriv/object_data.js new file mode 100644 index 0000000..8d5c173 --- /dev/null +++ b/lib/types/status_messages_deriv/object_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link StatusMessagesDeriv} data in plain object format. Suitable for + * passing to {@link StatusMessagesDeriv} to construct a model instance. + * + * @typedef {object} StatusMessagesDeriv~ObjectData + * @property {string} key - key + * @property {number} timestamp - timestamp + * @property {string} price - price + * @property {string} priceSpot - spot price + * @property {string} fundBal - funding balance + * @property {string} fundingAccrued - accrued funding + * @property {string} fundingStep - funding step + */ diff --git a/lib/types/trade/array_data.js b/lib/types/trade/array_data.js new file mode 100644 index 0000000..8296705 --- /dev/null +++ b/lib/types/trade/array_data.js @@ -0,0 +1,19 @@ +'use strict' + +/** + * {@link Trade} data in WSv2 array format. Suitable for passing to + * {@link Trade} to construct a model instance. + * + * @typedef {Array} Trade~ArrayData + * @property {number} 0 - id + * @property {string} 1 - symbol + * @property {number} 2 - mtsCreate + * @property {number} 3 - orderID + * @property {string} 4 - execAmount + * @property {string} 5 - execPrice + * @property {string} 6 - orderType + * @property {number} 7 - orderPrice + * @property {number} 8 - maker + * @property {number} 9 - fee + * @property {string} 10 - feeCurrency + */ diff --git a/lib/types/trade/data.js b/lib/types/trade/data.js new file mode 100644 index 0000000..8fcceee --- /dev/null +++ b/lib/types/trade/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Trade} data either in WSv2 array or object format. + * + * @typedef {Trade|Trade~ObjectData|Trade~ArrayData} Trade~Data + */ diff --git a/lib/types/trade/object_data.js b/lib/types/trade/object_data.js new file mode 100644 index 0000000..2aeca65 --- /dev/null +++ b/lib/types/trade/object_data.js @@ -0,0 +1,19 @@ +'use strict' + +/** + * {@link Trade} data in plain object format. Suitable for passing to + * {@link Trade} to construct a model instance. + * + * @typedef {object} Trade~ObjectData + * @property {number} id - id + * @property {string} symbol - symbol + * @property {number} mtsCreate - creation timestamp + * @property {number} orderID - order ID + * @property {string} execAmount - executed amount + * @property {string} execPrice - execution price + * @property {string} orderType - order type + * @property {string} orderPrice - order price + * @property {number|boolean} maker - maker flag + * @property {string} fee - fee amount + * @property {string} feeCurrency - fee currency + */ diff --git a/lib/types/trading_ticker/array_data.js b/lib/types/trading_ticker/array_data.js new file mode 100644 index 0000000..9ead329 --- /dev/null +++ b/lib/types/trading_ticker/array_data.js @@ -0,0 +1,19 @@ +'use strict' + +/** + * {@link TradingTicker} data in WSv2 array format. Suitable for passing to + * {@link TradingTicker} to construct a model instance. + * + * @typedef {Array} TradingTicker~ArrayData + * @property {string} 0 - symbol + * @property {number} 1 - bid + * @property {number} 2 - bidSize + * @property {number} 3 - ask + * @property {number} 4 - askSize + * @property {number} 5 - dailyChange + * @property {number} 6 - dailyChangePerc + * @property {number} 7 - lastPrice + * @property {number} 8 - volume + * @property {number} 9 - high + * @property {number} 10 - low + */ diff --git a/lib/types/trading_ticker/data.js b/lib/types/trading_ticker/data.js new file mode 100644 index 0000000..04359fa --- /dev/null +++ b/lib/types/trading_ticker/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link TradingTicker} data either in WSv2 array or object format. + * + * @typedef {( + * TradingTicker|TradingTicker~ObjectData|TradingTicker~ArrayData + * )} TradingTicker~Data + */ diff --git a/lib/types/trading_ticker/object_data.js b/lib/types/trading_ticker/object_data.js new file mode 100644 index 0000000..dd57c43 --- /dev/null +++ b/lib/types/trading_ticker/object_data.js @@ -0,0 +1,19 @@ +'use strict' + +/** + * {@link TradingTicker} data in plain object format. Suitable for passing to + * {@link TradingTicker} to construct a model instance. + * + * @typedef {object} TradingTicker~ObjectData + * @property {string} symbol - symbol + * @property {number} bid - best bid + * @property {number} bidSize - total bid size + * @property {number} ask - best ask + * @property {number} askSize - total ask size + * @property {number} dailyChange - change in last 24h period + * @property {number} dailyChangePerc - change in last 24h period as percent + * @property {number} lastPrice - last price + * @property {number} volume - volume in last 24h period + * @property {number} high - highest price in last 24h period + * @property {number} low - lowest price in last 24h period + */ diff --git a/lib/types/trading_ticker_hist/array_data.js b/lib/types/trading_ticker_hist/array_data.js new file mode 100644 index 0000000..0a129c8 --- /dev/null +++ b/lib/types/trading_ticker_hist/array_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link TradingTickerHist} data in WSv2 array format. Suitable for passing to + * {@link TradingTickerHist} to construct a model instance. + * + * @typedef {Array} TradingTickerHist~ArrayData + * @property {string} 0 - symbol + * @property {number} 1 - bid + * @property {number} 3 - ask + * @property {number} 12 - mtsUpdate + */ diff --git a/lib/types/trading_ticker_hist/data.js b/lib/types/trading_ticker_hist/data.js new file mode 100644 index 0000000..143adc3 --- /dev/null +++ b/lib/types/trading_ticker_hist/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link TradingTickerHist} data either in WSv2 array or object format. + * + * @typedef {( + * TradingTickerHist|TradingTickerHist~ObjectData|TradingTickerHist~ArrayData + * )} TradingTickerHist~Data + */ diff --git a/lib/types/trading_ticker_hist/object_data.js b/lib/types/trading_ticker_hist/object_data.js new file mode 100644 index 0000000..fc90f0d --- /dev/null +++ b/lib/types/trading_ticker_hist/object_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link TradingTickerHist} data in plain object format. Suitable for passing + * to {@link TradingTickerHist} to construct a model instance. + * + * @typedef {object} TradingTickerHist~ObjectData + * @property {string} symbol - symbol + * @property {number} bid - best bid + * @property {number} ask - best ask + * @property {number} mtsUpdate - timestamp + */ diff --git a/lib/types/user_info/array_data.js b/lib/types/user_info/array_data.js new file mode 100644 index 0000000..907773e --- /dev/null +++ b/lib/types/user_info/array_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link UserInfo} data in WSv2 array format. Suitable for passing to + * {@link UserInfo} to construct a model instance. + * + * @typedef {Array} UserInfo~ArrayData + * @property {number} 0 - id + * @property {string} 1 - email + * @property {string} 2 - username + * @property {number} 7 - timezone + */ diff --git a/lib/types/user_info/data.js b/lib/types/user_info/data.js new file mode 100644 index 0000000..336fb88 --- /dev/null +++ b/lib/types/user_info/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link UserInfo} data either in WSv2 array or object format. + * + * @typedef {UserInfo|UserInfo~ObjectData|UserInfo~ArrayData} UserInfo~Data + */ diff --git a/lib/types/user_info/object_data.js b/lib/types/user_info/object_data.js new file mode 100644 index 0000000..5d5a24c --- /dev/null +++ b/lib/types/user_info/object_data.js @@ -0,0 +1,12 @@ +'use strict' + +/** + * {@link UserInfo} data in plain object format. Suitable for passing to + * {@link UserInfo} to construct a model instance. + * + * @typedef {object} UserInfo~ObjectData + * @property {number} id - id + * @property {string} email - email + * @property {string} username - username + * @property {number} timezone - timezone as UTC offset + */ diff --git a/lib/types/wallet/array_data.js b/lib/types/wallet/array_data.js new file mode 100644 index 0000000..b5df161 --- /dev/null +++ b/lib/types/wallet/array_data.js @@ -0,0 +1,15 @@ +'use strict' + +/** + * {@link Wallet} data in WSv2 array format. Suitable for passing to + * {@link Wallet} to construct a model instance. + * + * @typedef {Array} Wallet~ArrayData + * @property {string} 0 - type + * @property {string} 1 - currency + * @property {number} 2 - balance + * @property {number} 3 - unsettledInterest + * @property {number} 4 - balanceAvailable + * @property {string} 5 - description + * @property {object} 6 - meta + */ diff --git a/lib/types/wallet/data.js b/lib/types/wallet/data.js new file mode 100644 index 0000000..f6057ec --- /dev/null +++ b/lib/types/wallet/data.js @@ -0,0 +1,7 @@ +'use strict' + +/** + * {@link Wallet} data either in WSv2 array or object format. + * + * @typedef {Wallet|Wallet~ObjectData|Wallet~ArrayData} Wallet~Data + */ diff --git a/lib/types/wallet/object_data.js b/lib/types/wallet/object_data.js new file mode 100644 index 0000000..ab67e06 --- /dev/null +++ b/lib/types/wallet/object_data.js @@ -0,0 +1,13 @@ +'use strict' + +/** + * {@link Wallet} data in plain object format. Suitable for passing to + * {@link Wallet} to construct a model instance. + * + * @typedef {object} Wallet~ObjectData + * @property {string} type - wallet type (i.e. deposit) + * @property {string} currency - wallet currency + * @property {number} balance - total balance + * @property {number} unsettledInterest - unsettled interest + * @property {number} balanceAvailable - available balance + */ diff --git a/lib/types/wallet_hist/array_data.js b/lib/types/wallet_hist/array_data.js new file mode 100644 index 0000000..a40be77 --- /dev/null +++ b/lib/types/wallet_hist/array_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link WalletHist} data in WSv2 array format. Suitable for passing to + * {@link WalletHist} to construct a model instance. + * + * @typedef {Array} WalletHist~ArrayData + * @property {string} 0 - type + * @property {string} 1 - currency + * @property {number} 2 - balance + * @property {number} 3 - unsettledInterest + * @property {number} 4 - balanceAvailable + * @property {number} 6 - mtsUpdate + */ diff --git a/lib/types/wallet_hist/data.js b/lib/types/wallet_hist/data.js new file mode 100644 index 0000000..e287d35 --- /dev/null +++ b/lib/types/wallet_hist/data.js @@ -0,0 +1,9 @@ +'use strict' + +/** + * {@link WalletHist} data either in WSv2 array or object format. + * + * @typedef {( + * WalletHist|WalletHist~ObjectData|WalletHist~ArrayData + * )} WalletHist~Data + */ diff --git a/lib/types/wallet_hist/object_data.js b/lib/types/wallet_hist/object_data.js new file mode 100644 index 0000000..5586b1a --- /dev/null +++ b/lib/types/wallet_hist/object_data.js @@ -0,0 +1,14 @@ +'use strict' + +/** + * {@link WalletHist} data in plain object format. Suitable for passing to + * {@link WalletHist} to construct a model instance. + * + * @typedef {object} WalletHist~ObjectData + * @property {string} type - type (i.e. deposit) + * @property {string} currency - currency + * @property {number} balance - balance + * @property {number} unsettledInterest - unsettled interest + * @property {number} balanceAvailable - available balance + * @property {number} mtsUpdate - timestamp + */ diff --git a/lib/user_info.js b/lib/user_info.js index a9f5c3b..16b6982 100644 --- a/lib/user_info.js +++ b/lib/user_info.js @@ -12,22 +12,21 @@ const fields = { /** * User Info model + * + * @class + * @augments Model */ class UserInfo extends Model { /** - * @param {object|Array} data - user info data - * @param {number} data.id - id - * @param {string} data.email - email - * @param {string} data.username - username - * @param {number} data.timezone - timezone as UTC offset + * @param {UserInfo~Data|UserInfo~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {UserInfo~Data|UserInfo~Data[]} data - data to convert to POJO + * @returns {UserInfo~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -36,7 +35,7 @@ class UserInfo extends Model { /** * Validates a given historical trading ticker instance * - * @param {object[]|object|TradingTickerHist[]|TradingTickerHist|Array} data - instance to validate + * @param {UserInfo~Data|UserInfo~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/util/assign_from_collection_or_instance.js b/lib/util/assign_from_collection_or_instance.js index f7f8331..1840aa8 100644 --- a/lib/util/assign_from_collection_or_instance.js +++ b/lib/util/assign_from_collection_or_instance.js @@ -8,13 +8,13 @@ const _isObject = require('lodash/isObject') * object/array format packets and arrays of them. If given an array of * packets, the destination model will become iterable. * + * @private + * * @param {object} args - arguments * @param {object[]|object|Array[]|Array} args.data - data - * @param {object} [args.fields] - index map in the form { [fieldName]: index } - * @param {Array} [args.boolFields] - array of boolean field names * @param {object} args.target - model class */ -const assignFromCollectionOrInstance = ({ data, fields, boolFields, target }) => { +const assignFromCollectionOrInstance = ({ data, target }) => { // Use/assign passed in data if (!_isArray(data) && _isObject(data)) { Object.assign(target, data) diff --git a/lib/util/is_collection.js b/lib/util/is_collection.js index 4bc5e54..df4d98b 100644 --- a/lib/util/is_collection.js +++ b/lib/util/is_collection.js @@ -9,6 +9,8 @@ const _isObject = require('lodash/isObject') * @param {object[]|object|Array[]|Array} data - packet to analyse * @returns {boolean} isCollection */ -module.exports = (data) => ( +const isCollection = (data) => ( _isArray(data) && (_isArray(data[0]) || _isObject(data[0])) ) + +module.exports = isCollection diff --git a/lib/validators/amount.js b/lib/validators/amount.js index 930236d..963a329 100644 --- a/lib/validators/amount.js +++ b/lib/validators/amount.js @@ -5,7 +5,7 @@ const numberValidator = require('./number') /** * Validates an amount * - * @param {*} v - value + * @param {number} v - value * @returns {string} error - null if valid */ module.exports = (v) => numberValidator(v) diff --git a/lib/validators/bool.js b/lib/validators/bool.js index 55d534b..91a6001 100644 --- a/lib/validators/bool.js +++ b/lib/validators/bool.js @@ -5,7 +5,7 @@ const _isBoolean = require('lodash/isBoolean') /** * Validates a bool * - * @param {*} v - value + * @param {boolean} v - value * @returns {string} error - null if valid */ module.exports = (v) => (!_isBoolean(v) diff --git a/lib/validators/currency.js b/lib/validators/currency.js index 7b6162e..c298776 100644 --- a/lib/validators/currency.js +++ b/lib/validators/currency.js @@ -1,13 +1,15 @@ 'use strict' +const _values = require('lodash/values') const _includes = require('lodash/includes') const { CURRENCIES } = require('bfx-hf-util') -const VALID_CURRENCIES = Object.values(CURRENCIES) + +const VALID_CURRENCIES = _values(CURRENCIES) /** * Validates a currency * - * @param {*} v - value + * @param {string} v - value * @returns {string} error - null if valid */ module.exports = (v) => (!_includes(VALID_CURRENCIES, v) diff --git a/lib/validators/date.js b/lib/validators/date.js index f5c60f3..c2b5e1c 100644 --- a/lib/validators/date.js +++ b/lib/validators/date.js @@ -5,7 +5,7 @@ const _isFinite = require('lodash/isFinite') /** * Validates a date * - * @param {*} v - value + * @param {Date|number} v - value * @returns {string} error - null if valid */ module.exports = (v) => (!_isFinite(+v) || +v < 0 diff --git a/lib/validators/number.js b/lib/validators/number.js index 30070ea..9a2ffe4 100644 --- a/lib/validators/number.js +++ b/lib/validators/number.js @@ -5,7 +5,7 @@ const _isFinite = require('lodash/isFinite') /** * Validates a number * - * @param {*} v - value + * @param {number} v - value * @returns {string} error - null if valid */ module.exports = (v) => (!_isFinite(v) diff --git a/lib/validators/price.js b/lib/validators/price.js index de7a163..b9009e5 100644 --- a/lib/validators/price.js +++ b/lib/validators/price.js @@ -5,7 +5,7 @@ const numberValidator = require('./number') /** * Validates a price * - * @param {*} v - value + * @param {number} v - value * @returns {string} error - null if valid */ module.exports = (v) => (numberValidator(v) || v < 0 diff --git a/lib/validators/string.js b/lib/validators/string.js index 306ff3b..c9e114b 100644 --- a/lib/validators/string.js +++ b/lib/validators/string.js @@ -6,8 +6,8 @@ const _isString = require('lodash/isString') /** * Validates a string * - * @param {*} v - value - * @param {string[]} validOptions - optional + * @param {string} v - value + * @param {string[]} [validOptions] - array of valid values * @returns {string} error - null if valid */ module.exports = (v, validOptions) => ( diff --git a/lib/validators/symbol.js b/lib/validators/symbol.js index ea6d953..8620685 100644 --- a/lib/validators/symbol.js +++ b/lib/validators/symbol.js @@ -1,13 +1,14 @@ 'use strict' +const _values = require('lodash/values') const _includes = require('lodash/includes') const { SYMBOLS } = require('bfx-hf-util') -const VALID_SYMBOLS = Object.values(SYMBOLS) +const VALID_SYMBOLS = _values(SYMBOLS) /** * Validates a symbol * - * @param {*} v - value + * @param {string} v - value * @returns {string} error - null if valid */ module.exports = (v) => (!_includes(VALID_SYMBOLS, v) diff --git a/lib/wallet.js b/lib/wallet.js index 5358864..1904257 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -19,23 +19,21 @@ const fields = { /** * Wallet model + * + * @class + * @augments Model */ class Wallet extends Model { /** - * @param {object|Array} data - wallet data - * @param {string} data.type - wallet type (i.e. deposit) - * @param {string} data.currency - wallet currency - * @param {number} data.balance - total balance - * @param {number} data.unsettledInterest - unsettled interest - * @param {number} data.balanceAvailable - available balance + * @param {Wallet~Data|Wallet~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {Wallet~Data|Wallet~Data[]} data - data to convert to POJO + * @returns {Wallet~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -44,7 +42,7 @@ class Wallet extends Model { /** * Validates a given wallet instance * - * @param {object[]|object|Wallet[]|Wallet|Array} data - instance to validate + * @param {Wallet~Data|Wallet~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/lib/wallet_hist.js b/lib/wallet_hist.js index 0aa1983..1f8f657 100644 --- a/lib/wallet_hist.js +++ b/lib/wallet_hist.js @@ -19,24 +19,21 @@ const fields = { /** * Historical Wallet Update model + * + * @class + * @augments Model */ class WalletHist extends Model { /** - * @param {object|Array} data - historical wallet update data - * @param {string} data.type - type (i.e. deposit) - * @param {string} data.currency - currency - * @param {number} data.balance - balance - * @param {number} data.unsettledInterest - unsettled interest - * @param {number} data.balanceAvailable - available balance - * @param {number} data.mtsUpdate - timestamp + * @param {WalletHist~Data|WalletHist~Data[]} data - data */ constructor (data = {}) { super({ data, fields }) } /** - * @param {object[]|object|Array[]|Array} data - data to convert to POJO - * @returns {object} pojo + * @param {WalletHist~Data|WalletHist~Data[]} data - data to convert to POJO + * @returns {WalletHist~ObjectData} pojo */ static unserialize (data) { return super.unserialize({ data, fields }) @@ -45,7 +42,7 @@ class WalletHist extends Model { /** * Validates a given historical wallet instance * - * @param {object[]|object|WalletHist[]|WalletHist|Array} data - instance to validate + * @param {WalletHist~Data|WalletHist~Data[]} data - instance(s) to validate * @returns {string} error - null if instance is valid */ static validate (data) { diff --git a/package.json b/package.json index 076bcea..42db8ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-api-node-models", - "version": "1.2.9", + "version": "1.2.10", "description": "Object models for usage with the Bitfinex node API", "engines": { "node": ">=8.3.0" @@ -12,11 +12,11 @@ } }, "scripts": { - "lint": "eslint lib/ examples/ test/ index.js", + "lint": "./node_modules/.bin/eslint lib/ examples/ test/ index.js", "test": "npm run lint && npm run unit", "unit": "NODE_ENV=test nyc --check-coverage --lines 90 --branches 60 --functions 90 --statements 90 --reporter=lcov --reporter=html mocha -b --recursive", "build": "babel ./index.js -d ./dist && babel ./lib -d ./dist/lib && copy package.json dist", - "docs": "rm -rf docs && node_modules/.bin/jsdoc --configure .jsdoc.json --verbose" + "docs": "rm -rf docs/*.md && ./node_modules/.bin/jsdoc2md -f index.js 'lib/**/*.js' > docs/reference.md" }, "repository": { "type": "git", @@ -40,27 +40,25 @@ }, "homepage": "http://bitfinexcom.github.io/bfx-api-node-models/", "devDependencies": { - "babel-cli": "^6.26.0", - "babel-eslint": "^10.1.0", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-plugin-transform-regenerator": "^6.26.0", + "@babel/cli": "^7.10.1", + "@babel/plugin-proposal-object-rest-spread": "^7.10.1", + "@babel/plugin-transform-regenerator": "^7.10.1", + "@babel/preset-env": "^7.10.2", "bfx-api-node-rest": "^3.0.3", "chai": "^4.2.0", - "docdash": "^1.2.0", - "eslint": "^6.8.0", + "eslint": "^7.2.0", "eslint-config-standard": "^14.1.0", "eslint-plugin-import": "^2.20.1", - "eslint-plugin-jsdoc": "^22.0.0", - "eslint-plugin-lodash": "^6.0.0", - "eslint-plugin-mocha": "^6.3.0", + "eslint-plugin-jsdoc": "^27.0.4", + "eslint-plugin-lodash": "^7.1.0", + "eslint-plugin-mocha": "^7.0.1", "eslint-plugin-node": "^11.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "husky": "^4.2.3", - "jsdoc-to-markdown": "^5.0.3", + "jsdoc-to-markdown": "^6.0.1", "mocha": "^7.1.0", - "nyc": "^15.0.0", - "standard": "^14.1.0" + "nyc": "^15.0.0" }, "dependencies": { "bfx-api-node-util": "^1.0.8",