coinbase-exchange
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -33,3 +33,3 @@ var util = require('util'); | ||
opts = opts || {}; | ||
if (!callback && (opts instanceof Function)) { | ||
if (!callback && (typeof opts === 'function')) { | ||
callback = opts; | ||
@@ -96,3 +96,3 @@ opts = {}; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -110,3 +110,3 @@ args = {}; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -122,3 +122,10 @@ args = {}; | ||
var self = this; | ||
_.forEach(['price', 'size', 'side', 'product_id'], function(param) { | ||
var requiredParams = ['size', 'side', 'product_id']; | ||
if (params.type !== 'market') { | ||
requiredParams.push('price'); | ||
} | ||
_.forEach(requiredParams, function(param) { | ||
if (params[param] === undefined) { | ||
@@ -153,3 +160,3 @@ throw "`opts` must include param `" + param + "`"; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -172,3 +179,3 @@ args = {}; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -175,0 +182,0 @@ args = {}; |
@@ -49,3 +49,3 @@ var request = require('request'); | ||
opts = opts || {}; | ||
if (!callback && (opts instanceof Function)) { | ||
if (!callback && (typeof opts === 'function')) { | ||
callback = opts; | ||
@@ -78,3 +78,3 @@ opts = {}; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -104,3 +104,3 @@ args = {}; | ||
args = args || {} | ||
if (!callback && (args instanceof Function)) { | ||
if (!callback && (typeof args === 'function')) { | ||
callback = args; | ||
@@ -107,0 +107,0 @@ args = {}; |
@@ -41,3 +41,2 @@ var EventEmitter = require('events').EventEmitter; | ||
self.socket.close(); | ||
self.onClose(); | ||
}; | ||
@@ -55,3 +54,3 @@ | ||
// Set a 30 second ping to keep connection alive | ||
setInterval(function(){ | ||
self.pinger = setInterval(function(){ | ||
self.socket.ping("keepalive"); | ||
@@ -64,2 +63,4 @@ }, 30000); | ||
var self = this; | ||
clearInterval(self.pinger); | ||
self.socket = null; | ||
self.emit('close'); | ||
@@ -66,0 +67,0 @@ }; |
@@ -11,6 +11,8 @@ var WebsocketClient = require('./clients/websocket.js'); | ||
// Orderbook syncing | ||
var OrderbookSync = function(productID) { | ||
var OrderbookSync = function(productID, apiURI, websocketURI) { | ||
var self = this; | ||
self.productID = productID || 'BTC-USD'; | ||
self.apiURI = apiURI || 'https://api.exchange.coinbase.com'; | ||
self.websocketURI = websocketURI || 'wss://ws-feed.exchange.coinbase.com'; | ||
@@ -20,3 +22,3 @@ self._queue = []; | ||
WebsocketClient.call(self, self.productID); | ||
WebsocketClient.call(self, self.productID, self.websocketURI); | ||
self.loadOrderbook(); | ||
@@ -49,3 +51,3 @@ }; | ||
if (!self.publicClient) { | ||
self.publicClient = new PublicClient(); | ||
self.publicClient = new PublicClient(self.productID, self.apiURI); | ||
} | ||
@@ -52,0 +54,0 @@ |
@@ -157,6 +157,14 @@ var RBTree = require('bintrees').RBTree; | ||
var node = tree.find({price: price}); | ||
assert(node); | ||
if (!node || node.orders.indexOf(order) < 0) { | ||
return; | ||
} | ||
var nodeOrder = node.orders[node.orders.indexOf(order)]; | ||
assert.equal(order.size, change.old_size); | ||
var newSize = parseFloat(order.size); | ||
var oldSize = parseFloat(change.old_size); | ||
assert.equal(oldSize, newSize); | ||
nodeOrder.size = size; | ||
@@ -163,0 +171,0 @@ self._ordersByID[nodeOrder.id] = nodeOrder; |
{ | ||
"name": "coinbase-exchange", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Coinbase", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/coinbase/coinbase-exchange-node/issues", |
@@ -172,3 +172,3 @@ var assert = require('assert'); | ||
order_id: 'super-duper-id-2', | ||
old_size: 10, | ||
old_size: '10.0', | ||
new_size: 3, | ||
@@ -175,0 +175,0 @@ price: 201, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33103
12
744
0