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.0.5 to 1.0.6

lib/funding_ticker_hist.js

62

lib/funding_ticker.js
'use strict'
const _isArray = require('lodash/isArray')
const Model = require('./model')
const BOOL_FIELDS = []
const FIELDS = {
symbol: 0,
frr: 1,
bid: 2,
bidSize: 3,
bidPeriod: 4,
ask: 5,
askSize: 6,
askPeriod: 7,
dailyChange: 8,
dailyChangePerc: 9,
lastPrice: 10,
volume: 11,
high: 12,
low: 13
}
const FIELD_KEYS = Object.keys(FIELDS)
class FundingTicker extends Model {
constructor (data = {}) {
super(data)
super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)
}
serialize () {
const {
frr, bid, bidPeriod, bidSize, ask, askPeriod, askSize,
dailyChange, dailyChangePerc, lastPrice, volume, high, low
} = this
static unserialize (arr) {
return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)
}
return [
frr, bid, bidPeriod, bidSize, ask, askPeriod, askSize, dailyChange,
dailyChangePerc, lastPrice, volume, high, low
]
quote () {
return this.symbol.substring(4)
}
static unserialize (arr) {
const [ data ] = arr
const [
frr, bid, bidPeriod, bidSize, ask, askPeriod, askSize, dailyChange,
dailyChangePerc, lastPrice, volume, high, low
] = _isArray(data)
? data
: [...arr].splice(0)
return {
frr,
bid,
bidPeriod,
bidSize,
ask,
askPeriod,
askSize,
dailyChange,
dailyChangePerc,
lastPrice,
volume,
high,
low
}
base () {
return this.symbol.substring(1, 4)
}

@@ -48,0 +40,0 @@ }

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

Position: require('./position'),
PositionHist: require('./position_hist'),
Trade: require('./trade'),
Wallet: require('./wallet'),
WalletHist: require('./wallet_hist'),
Alert: require('./alert'),
TradingTicker: require('./trading_ticker'),
TradingTickerHist: require('./trading_ticker_hist'),
FundingTicker: require('./funding_ticker'),
FundingTickerHist: require('./funding_ticker_hist'),
PublicTrade: require('./public_trade'),

@@ -22,0 +26,0 @@ Candle: require('./candle'),

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

const spl = this.description.split('wallet')
this.wallet = (spl && spl[1]) ? spl[1].trim() : null
this.wallet = (spl && spl.length > 1) ? spl[spl.length - 1].trim() : null
}

@@ -24,0 +24,0 @@

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

const CRC = require('crc-32')
const _isEmpty = require('lodash/isEmpty')

@@ -190,2 +191,6 @@ const { preparePrice } = require('bfx-api-node-util')

if (_isEmpty(snapshot)) {
return
}
for (let i = 0; i < snapshot.length; i++) {

@@ -192,0 +197,0 @@ if (snapshot[i].length === 4) {

'use strict'
const _isArray = require('lodash/isArray')
const Model = require('./model')
const BOOL_FIELDS = []
const FIELDS = {
symbol: 0,
bid: 1,
bidSize: 2,
ask: 3,
askSize: 4,
dailyChange: 5,
dailyChangePerc: 6,
lastPrice: 7,
volume: 8,
high: 9,
low: 10
}
const FIELD_KEYS = Object.keys(FIELDS)
class TradingTicker extends Model {
constructor (data = {}) {
super(data)
super(data, FIELDS, BOOL_FIELDS, FIELD_KEYS)
}
serialize () {
const {
bid, bidSize, ask, askSize, dailyChange, dailyChangePerc,
lastPrice, volume, high, low
} = this
return [
bid, bidSize, ask, askSize, dailyChange, dailyChangePerc, lastPrice,
volume, high, low
]
}
static unserialize (arr) {
const [ data ] = arr
const [
bid, bidSize, ask, askSize, dailyChange, dailyChangePerc, lastPrice,
volume, high, low
] = _isArray(data)
? data
: [...arr].splice(0)
return {
bid,
bidSize,
ask,
askSize,
dailyChange,
dailyChangePerc,
lastPrice,
volume,
high,
low
}
return super.unserialize(arr, FIELDS, BOOL_FIELDS, FIELD_KEYS)
}

@@ -45,0 +29,0 @@

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

@@ -24,2 +24,3 @@ "engines": {

"contributors": [
"Ezequiel Wernicke <ezequiel.wernicke@bitfinex.com> (https://www.bitfinex.com)",
"Josh Rossi <josh@bitfinex.com> (https://www.bitfinex.com)",

@@ -26,0 +27,0 @@ "Cris Mihalache <cris.m@bitfinex.com> (https://www.bitfinex.com)",

@@ -9,9 +9,10 @@ /* eslint-env mocha */

const DATA = [
'fUSD',
0.00009351,
0.00009526,
1365265.8039803,
30,
1365265.8039803,
0.00009042,
1920909.19369824,
2,
1920909.19369824,
-0.00001159,

@@ -28,3 +29,3 @@ -0.1136,

const ticker = new FundingTicker(DATA)
assert.equal(ticker.symbol, 'fUSD')
assert.equal(ticker.frr, 0.00009351)

@@ -54,3 +55,3 @@ assert.equal(ticker.bid, 0.00009526)

const obj = FundingTicker.unserialize(DATA)
assert.equal(obj.symbol, 'fUSD')
assert.equal(obj.frr, 0.00009351)

@@ -76,16 +77,17 @@ assert.equal(obj.bid, 0.00009526)

assert.equal(obj.frr, arr[0])
assert.equal(obj.bid, arr[1])
assert.equal(obj.bidPeriod, arr[2])
assert.equal(obj.symbol, arr[0])
assert.equal(obj.frr, arr[1])
assert.equal(obj.bid, arr[2])
assert.equal(obj.bidSize, arr[3])
assert.equal(obj.ask, arr[4])
assert.equal(obj.askPeriod, arr[5])
assert.equal(obj.bidPeriod, arr[4])
assert.equal(obj.ask, arr[5])
assert.equal(obj.askSize, arr[6])
assert.equal(obj.dailyChange, arr[7])
assert.equal(obj.dailyChangePerc, arr[8])
assert.equal(obj.lastPrice, arr[9])
assert.equal(obj.volume, arr[10])
assert.equal(obj.high, arr[11])
assert.equal(obj.low, arr[12])
assert.equal(obj.askPeriod, arr[7])
assert.equal(obj.dailyChange, arr[8])
assert.equal(obj.dailyChangePerc, arr[9])
assert.equal(obj.lastPrice, arr[10])
assert.equal(obj.volume, arr[11])
assert.equal(obj.high, arr[12])
assert.equal(obj.low, arr[13])
})
})

@@ -9,2 +9,3 @@ /* eslint-env mocha */

const DATA = [
'tBTCUSD',
228.56,

@@ -26,2 +27,3 @@ 430.1902224,

assert.equal(ticker.symbol, 'tBTCUSD')
assert.equal(ticker.bid, 228.56)

@@ -49,2 +51,3 @@ assert.equal(ticker.bidSize, 430.1902224)

assert.equal(obj.symbol, 'tBTCUSD')
assert.equal(obj.bid, 228.56)

@@ -67,13 +70,14 @@ assert.equal(obj.bidSize, 430.1902224)

assert.equal(obj.bid, arr[0])
assert.equal(obj.bidSize, arr[1])
assert.equal(obj.ask, arr[2])
assert.equal(obj.askSize, arr[3])
assert.equal(obj.dailyChange, arr[4])
assert.equal(obj.dailyChangePerc, arr[5])
assert.equal(obj.lastPrice, arr[6])
assert.equal(obj.volume, arr[7])
assert.equal(obj.high, arr[8])
assert.equal(obj.low, arr[9])
assert.equal(obj.symbol, arr[0])
assert.equal(obj.bid, arr[1])
assert.equal(obj.bidSize, arr[2])
assert.equal(obj.ask, arr[3])
assert.equal(obj.askSize, arr[4])
assert.equal(obj.dailyChange, arr[5])
assert.equal(obj.dailyChangePerc, arr[6])
assert.equal(obj.lastPrice, arr[7])
assert.equal(obj.volume, arr[8])
assert.equal(obj.high, arr[9])
assert.equal(obj.low, arr[10])
})
})
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