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

bfx-api-node-models

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bfx-api-node-models - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

docs/.keep

14

lib/alert.js

@@ -14,3 +14,13 @@ 'use strict'

/**
* Price alert model
*/
class Alert extends Model {
/**
* @param {Object|Array} data
* @param {string} data.key
* @param {string} data.type
* @param {string} data.symbol
* @param {string} data.price
*/
constructor (data = {}) {

@@ -20,2 +30,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -22,0 +36,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -12,3 +12,11 @@ 'use strict'

/**
* Wallet balance information model
*/
class BalanceInfo extends Model {
/**
* @param {Object|Array} data
* @param {number} data.amount
* @param {number} data.amountNet
*/
constructor (data = {}) {

@@ -18,2 +26,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -20,0 +32,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -16,3 +16,15 @@ 'use strict'

/**
* OHLCV Candle model
*/
class Candle extends Model {
/**
* @param {Object|Array} data
* @param {number} data.mts
* @param {number} data.open
* @param {number} data.close
* @param {number} data.high
* @param {number} data.low
* @param {number} data.volume
*/
constructor (data = {}) {

@@ -22,2 +34,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -24,0 +40,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -15,3 +15,14 @@ 'use strict'

/**
* Currency model
*/
class Currency extends Model {
/**
* @param {Object|Array} data
* @param {string} data.id
* @param {string} data.name
* @param {string} data.pool
* @param {string} data.exporer
* @param {string} data.symbol
*/
constructor (data = {}) {

@@ -21,2 +32,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -23,0 +38,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -28,3 +28,27 @@ 'use strict'

/**
* Funding Credit model
*/
class FundingCredit extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.symbol
* @param {number} data.side
* @param {number} data.mtsCreate
* @param {number} data.mtsUpdate
* @param {number} data.mtsOpening
* @param {number} data.mtsLastPayout
* @param {number} data.amount
* @param {number} data.flags
* @param {number} data.status
* @param {number} data.rate
* @param {number} data.rateReal
* @param {number} data.period
* @param {string} data.positionPair
* @param {number|boolean} data.notify
* @param {number|boolean} data.hidden
* @param {number|boolean} data.renew
* @param {number|boolean} data.noClose
*/
constructor (data = {}) {

@@ -34,2 +58,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -36,0 +64,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

16

lib/funding_info.js

@@ -5,7 +5,11 @@ 'use strict'

/**
* Account Funding Info model
*/
class FundingInfo extends Model {
constructor (data = {}) {
super(data)
}
/**
* Return an array representation of this model
*
* @return {Array} arr
*/
serialize () {

@@ -26,2 +30,6 @@ const { symbol, yieldLoan, yieldLend, durationLoan, durationLend } = this

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -28,0 +36,0 @@ const [, symbol, data = []] = arr

@@ -27,3 +27,26 @@ 'use strict'

/**
* Funding Loan model
*/
class FundingLoan extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.symbol
* @param {number} data.side
* @param {number} data.mtsCreate
* @param {number} data.mtsUpdate
* @param {number} data.mtsOpening
* @param {number} data.mtsLastPayout
* @param {number} data.amount
* @param {number} data.flags
* @param {number} data.status
* @param {number} data.rate
* @param {number} data.rateReal
* @param {number} data.period
* @param {number|boolean} data.notify
* @param {number|boolean} data.hidden
* @param {number|boolean} data.renew
* @param {number|boolean} data.noClose
*/
constructor (data = {}) {

@@ -33,2 +56,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -35,0 +62,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -26,7 +26,25 @@ 'use strict'

/**
* Funding Offer model
*/
class FundingOffer extends Model {
/**
* @param {Object|Array} data - either a map of order fields or a raw array
* @param {Object} _apiInterface - optional, rest or websocket object capable of submitting funding offers
*/
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.symbol
* @param {number} data.mtsCreate
* @param {number} data.mtsUpdate
* @param {string} data.amount
* @param {string} data.amountOrig
* @param {string} data.type
* @param {number} data.flags
* @param {string} data.status
* @param {number} data.rate
* @param {number} data.rateReal
* @param {number} data.period
* @param {number|boolean} data.notify
* @param {number|boolean} data.hidden
* @param {number|boolean} data.renew
* @param {Object?} apiInterface - rest or websocket object capable of submitting funding offers
*/
constructor (data = {}, apiInterface) {

@@ -37,2 +55,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -63,3 +85,3 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

*/
submit (apiInterface = this._apiInterface ) {
submit (apiInterface = this._apiInterface) {
if (!apiInterface) return Promise.reject(new Error('no API interface provided'))

@@ -77,3 +99,3 @@

*/
cancel (apiInterface = this._apiInterface ) {
cancel (apiInterface = this._apiInterface) {
if (!apiInterface) return Promise.reject(new Error('no API interface provided'))

@@ -91,3 +113,3 @@

*/
close (apiInterface = this._apiInterface ) {
close (apiInterface = this._apiInterface) {
if (!apiInterface) return Promise.reject(new Error('no API interface provided'))

@@ -94,0 +116,0 @@

@@ -15,3 +15,14 @@ 'use strict'

/**
* Historical Funding Ticker model
*/
class FundingTickerHist extends Model {
/**
* @param {Object|Array} data
* @param {string} data.symbol
* @param {number} data.bid
* @param {number} data.bidPeriod
* @param {number} data.ask
* @param {number} data.mtsUpdate
*/
constructor (data = {}) {

@@ -21,2 +32,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -26,2 +41,5 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @return {string} quoteCurrency
*/
quote () {

@@ -31,2 +49,5 @@ return this.symbol.substring(4)

/**
* @return {string} baseCurrency
*/
base () {

@@ -33,0 +54,0 @@ return this.symbol.substring(1, 4)

@@ -24,3 +24,23 @@ 'use strict'

/**
* Funding Ticker model
*/
class FundingTicker extends Model {
/**
* @param {Object|Array} data
* @param {string} data.symbol
* @param {number|boolean} data.frr
* @param {number} data.bid
* @param {number} data.bidSize
* @param {number} data.bidPeriod
* @param {number} data.ask
* @param {number} data.askSize
* @param {number} data.askPeriod
* @param {number} data.dailyChange
* @param {number} data.dailyChangePerc
* @param {number} data.lastPrice
* @param {number} data.volume
* @param {number} data.high
* @param {number} data.low
*/
constructor (data = {}) {

@@ -30,2 +50,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -35,2 +59,5 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @return {string} quoteCurrency
*/
quote () {

@@ -40,2 +67,5 @@ return this.symbol.substring(4)

/**
* @return {string} baseCurrency
*/
base () {

@@ -42,0 +72,0 @@ return this.symbol.substring(1, 4)

@@ -18,3 +18,17 @@ 'use strict'

/**
* Funding Trade model
*/
class FundingTrade extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.symbol
* @param {number} data.mtsCreate
* @param {number} data.offerID
* @param {number} data.amount
* @param {number} data.rate
* @param {number} data.period
* @param {number|boolean} data.maker
*/
constructor (data = {}) {

@@ -24,2 +38,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -26,0 +44,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -20,3 +20,16 @@ 'use strict'

/**
* Ledger Entry model; wallet field is automatically populated if a description
* is provided.
*/
class LedgerEntry extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.currency
* @param {number} data.mts
* @param {number} data.amount
* @param {number} data.balance
* @param {string} data.description
*/
constructor (data = {}) {

@@ -33,2 +46,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -35,0 +52,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -17,3 +17,16 @@ 'use strict'

/**
* Liquidation Info model
*/
class Liquidations extends Model {
/**
* @param {Object|Array} data
* @param {number} data.posId
* @param {number} data.mtsUpdated
* @param {string} data.symbol
* @param {number} data.amount
* @param {number} data.basePrice
* @param {number|boolean} data.isMatch
* @param {number|boolean} data.isMarketSold
*/
constructor (data = {}) {

@@ -23,2 +36,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -25,0 +42,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -5,7 +5,11 @@ 'use strict'

/**
* Margin Info model
*/
class MarginInfo extends Model {
constructor (data = {}) {
super(data)
}
/**
* Return an array representation of this model
*
* @return {Array} arr
*/
serialize () {

@@ -42,2 +46,6 @@ const { type } = this

/**
* @param {Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -44,0 +52,0 @@ const [type] = arr

@@ -7,3 +7,12 @@ 'use strict'

/**
* Base model class, providing format-conversion methods
*/
class Model extends EventEmitter {
/**
* @param {Object?} data - model data
* @param {Object?} fields - field definitions, { [index]: key }
* @param {Array?} boolFields - array of boolean field keys
* @param {Array?} fieldKeys - array of all field keys
*/
constructor (data = {}, fields = {}, boolFields = [], fieldKeys = []) {

@@ -47,2 +56,7 @@ super()

/**
* Converts this model to array-format and returns the result
*
* @return {Array} arr
*/
serialize () {

@@ -66,2 +80,4 @@ const arr = []

/**
* Converts this model to object-format and returns the result
*
* @return {Object} pojo

@@ -77,2 +93,12 @@ */

/**
* Generic method for converting either an array, object, or model instance to
* a POJO.
*
* @param {Object|Array} data - can also be a model instance
* @param {Object} fields - field definitions, { [index]: key }
* @param {Array} boolFields - array of boolean field keys
* @param {Array} fieldKeys - array of all field keys
* @return {Object} pojo
*/
static unserialize (data, fields, boolFields, fieldKeys) {

@@ -79,0 +105,0 @@ if (_isArray(data) && (_isArray(data[0]) || _isObject(data[0]))) {

@@ -20,3 +20,19 @@ 'use strict'

/**
* Currency Movement model
*/
class Movement extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.currency
* @param {string} data.currencyName
* @param {number} data.mtsStarted
* @param {number} data.mtsUpdated
* @param {string} data.status
* @param {number} data.amount
* @param {number} data.fees
* @param {string} data.destinationAddress
* @param {number} data.transactionId
*/
constructor (data = {}) {

@@ -26,2 +42,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -28,0 +48,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -9,3 +9,2 @@ 'use strict'

messageID: 2,
// null: 3,
notifyInfo: 4,

@@ -19,3 +18,16 @@ code: 5,

/**
* Notification model
*/
class Notification extends Model {
/**
* @param {Object|Array} data
* @param {number} data.mts
* @param {string} data.type
* @param {number} data.messageID
* @param {Object} data.notifyInfo
* @param {number} data.code
* @param {string} data.status
* @param {string} data.text
*/
constructor (data = {}) {

@@ -25,2 +37,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -27,0 +43,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -186,2 +186,8 @@ 'use strict'

/**
* Resets the internal bid/ask arrays and re-populates them with the provided
* snapshot.
*
* @param {Array[]} snapshot
*/
updateFromSnapshot (snapshot) {

@@ -403,2 +409,5 @@ this.bids = []

/**
* @return {Array[]} - arr
*/
serialize () {

@@ -490,2 +499,8 @@ return (this.asks || []).concat(this.bids || [])

/**
* Resolves the mid-price of an array-format OB
*
* @param {Array[]} ob
* @param {boolean?} raw - default false
*/
static arrayOBMidPrice (ob = [], raw = false) {

@@ -492,0 +507,0 @@ if (ob.length === 0) return null

@@ -42,4 +42,23 @@ 'use strict'

/**
* @param {Object|Array} data - either a map of order fields or a raw array
* @param {Object} apiInterface - optional, saved for a later call to registerListeners()
* @param {Object|Array} data
* @param {number} data.id
* @param {number} data.gid
* @param {number} data.cid
* @param {string} data.symbol
* @param {number} data.mtsCreate
* @param {number} data.mtsUpdate
* @param {string} data.amount
* @param {string} data.amountOrig
* @param {string} data.type
* @param {string} data.typePrev
* @param {number} data.mtsTIF
* @param {number} data.flags
* @param {string} data.status
* @param {string} data.price
* @param {string} data.priceAvg
* @param {string} data.priceTrailing
* @param {string} data.priceAuxLimit
* @param {number|boolean} data.notify
* @param {number} data.placedId
* @param {Object?} apiInterface - saved for a later call to registerListeners()
*/

@@ -68,2 +87,6 @@ constructor (data = {}, apiInterface) {

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -70,0 +93,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -16,3 +16,2 @@ 'use strict'

leverage: 9,
placeholder: 10,
id: 11,

@@ -29,6 +28,27 @@ mtsCreate: 12,

/**
* Position model
*/
class Position extends Model {
/**
* @param {Object} data - either a map of order fields or a raw array
* @param {WSv2|Rest2} apiInterface - optional, rest or websocket object thats capable of submitting position changes
* @param {Object|Array} data
* @param {number} data.id
* @param {number} data.mtsCreate
* @param {number} data.mtsUpdate
* @param {number} data.id
* @param {string} data.symbol
* @param {string} data.status
* @param {string} data.type
* @param {string} data.amount
* @param {string} data.basePrice
* @param {string} data.marginFunding
* @param {string} data.marginFundingType
* @param {string} data.pl
* @param {string} data.plPerc
* @param {string} data.liquidationPrice
* @param {number} data.leverage
* @param {number} data.collateral
* @param {number} data.collateralMin
* @param {Object} data.meta
* @param {WSv2|Rest2} apiInterface - optional, rest or websocket object thats capable of submitting position changes
*/

@@ -40,2 +60,6 @@ constructor (data = {}, apiInterface) {

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -42,0 +66,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -25,3 +25,9 @@ 'use strict'

/**
* Public Trade model, supporting both funding & ordinary trades
*/
class PublicTrade extends Model {
/**
* @param {Object|Array} data
*/
constructor (data = {}) {

@@ -45,2 +51,6 @@ if (_isArray(data)) {

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -47,0 +57,0 @@ if ((_isArray(arr[0]) && arr[0].length === 5) || (arr.length === 5)) {

@@ -17,3 +17,16 @@ 'use strict'

/**
* Derivatives Status Message model
*/
class StatusMessagesDeriv extends Model {
/**
* @param {Object|Array} data
* @param {string} data.key
* @param {number} data.timestamp
* @param {string} data.price
* @param {string} data.priceSpot
* @param {string} data.fundBal
* @param {string} data.fundingAccrued
* @param {string} data.fundingStep
*/
constructor (data = {}) {

@@ -23,2 +36,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -25,0 +42,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -21,3 +21,20 @@ 'use strict'

/**
* Private Trade model
*/
class Trade extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.symbol
* @param {number} data.mtsCreate
* @param {number} data.orderID
* @param {string} data.execAmount
* @param {string} data.execPrice
* @param {string} data.orderType
* @param {string} data.orderPrice
* @param {number|boolean} data.maker
* @param {string} data.fee
* @param {string} data.feeCurrency
*/
constructor (data = {}) {

@@ -27,2 +44,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -29,0 +50,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -14,3 +14,13 @@ 'use strict'

/**
* Historical Trading Ticker model
*/
class TradingTickerHist extends Model {
/**
* @param {Object|Array} data
* @param {string} data.symbol
* @param {string} data.bid
* @param {string} data.ask
* @param {number} data.mtsUpdate
*/
constructor (data = {}) {

@@ -20,2 +30,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -25,2 +39,5 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @return {string} quoteCurrency
*/
quote () {

@@ -30,2 +47,5 @@ return this.symbol.substring(4)

/**
* @return {string} baseCurrency
*/
base () {

@@ -32,0 +52,0 @@ return this.symbol.substring(1, 4)

@@ -21,3 +21,20 @@ 'use strict'

/**
* Trading Ticker model
*/
class TradingTicker extends Model {
/**
* @param {Object|Array} data
* @param {string} data.symbol
* @param {number} data.bid
* @param {number} data.bidSize
* @param {number} data.ask
* @param {number} data.askSize
* @param {number} data.dailyChange
* @param {number} data.dailyChangePerc
* @param {number} data.lastPrice
* @param {number} data.volume
* @param {number} data.high
* @param {number} data.low
*/
constructor (data = {}) {

@@ -27,2 +44,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -32,2 +53,5 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @return {string} quoteCurrency
*/
quote () {

@@ -37,2 +61,5 @@ return this.symbol.substring(4)

/**
* @return {string} baseCurrency
*/
base () {

@@ -39,0 +66,0 @@ return this.symbol.substring(1, 4)

@@ -14,3 +14,13 @@ 'use strict'

/**
* User Info model
*/
class UserInfo extends Model {
/**
* @param {Object|Array} data
* @param {number} data.id
* @param {string} data.email
* @param {string} data.username
* @param {number} data.timezone
*/
constructor (data = {}) {

@@ -20,2 +30,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -22,0 +36,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -11,3 +11,2 @@ 'use strict'

balanceAvailable: 4,
placeHolder: 5,
mtsUpdate: 6

@@ -18,3 +17,15 @@ }

/**
* Historical Wallet Update model
*/
class WalletHist extends Model {
/**
* @param {Object|Array} data
* @param {string} data.type
* @param {string} data.currency
* @param {number} data.balance
* @param {number} data.unsettledInterest
* @param {number} data.balanceAvailable
* @param {number} data.mtsUpdate
*/
constructor (data = {}) {

@@ -24,2 +35,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -26,0 +41,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

@@ -15,3 +15,14 @@ 'use strict'

/**
* Wallet model
*/
class Wallet extends Model {
/**
* @param {Object|Array} data
* @param {string} data.type
* @param {string} data.currency
* @param {number} data.balance
* @param {number} data.unsettledInterest
* @param {number} data.balanceAvailable
*/
constructor (data = {}) {

@@ -21,2 +32,6 @@ super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)

/**
* @param {Object|Array} arr
* @return {Object} pojo
*/
static unserialize (arr) {

@@ -23,0 +38,0 @@ return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)

{
"name": "bfx-api-node-models",
"version": "1.1.0",
"version": "1.1.1",
"description": "Object models for usage with the Bitfinex node API",

@@ -13,3 +13,5 @@ "engines": {

"unit": "NODE_ENV=test mocha -b --recursive",
"build": "babel -q ./index.js -d ./dist && babel -q ./lib -d ./dist/lib && copy package.json dist"
"build": "babel -q ./index.js -d ./dist && babel -q ./lib -d ./dist/lib && copy package.json dist",
"docs": "npm run model_docs",
"model_docs": "node_modules/jsdoc-to-markdown/bin/cli.js lib/*.js > docs/model_docs.md"
},

@@ -41,2 +43,3 @@ "repository": {

"chai": "^4.2.0",
"jsdoc-to-markdown": "^5.0.1",
"mocha": "^6.2.0",

@@ -46,3 +49,3 @@ "standard": "^14.1.0"

"dependencies": {
"bfx-api-node-util": "git+http://github.com/bitfinexcom/bfx-api-node-util.git#semver:^1.0.2",
"bfx-api-node-util": "^1.0.2",
"bluebird": "^3.5.5",

@@ -49,0 +52,0 @@ "crc-32": "^1.2.0",

@@ -1,2 +0,2 @@

# Bitfinex Node API Data Models
# Bitfinex Data Models for Node.JS

@@ -9,3 +9,10 @@ [![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-models.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-models)

### Models
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:
* Alert

@@ -40,6 +47,31 @@ * BalanceInfo

### Data Manipulation
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).
### Installation
### Order
```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())
```
### Docs
[Refer to `docs/model_docs.md`](/docs/model_docs.md) for JSDoc-generated API documentation covering each model class.
### 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.

@@ -86,3 +118,2 @@

### OrderBook
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)`.

@@ -111,2 +142,10 @@

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

@@ -13,3 +13,3 @@ /* eslint-env mocha */

'marginFundingType', 'pl', 'plPerc', 'liquidationPrice', 'leverage',
'placeholder', 'id', 'mtsCreate', 'mtsUpdate', null, 'type', null,
null, 'id', 'mtsCreate', 'mtsUpdate', null, 'type', null,
'collateral', 'collateralMin', 'meta'

@@ -16,0 +16,0 @@ ]

@@ -11,5 +11,5 @@ /* eslint-env mocha */

orderedFields: [
'type', 'currency', 'balance', 'unsettledInterest', 'balanceAvailable', 'placeHolder', 'mtsUpdate'
'type', 'currency', 'balance', 'unsettledInterest', 'balanceAvailable', null, 'mtsUpdate'
]
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc