GithubHelp home page GithubHelp logo

coinbase-exchange-node's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coinbase-exchange-node's Issues

Failed Authenticated Client on Sandbox URL

I tried creating an authenticated client like so:

var authedClient = new CoinbaseExchange.AuthenticatedClient(Env.ACCESS_KEY, Env.SECRET_KEY, Env.PASSPHRASE_KEY, Env.REST_URL);

Where Env.REST_URL is the url to the sandbox API:
https://api-public.sandbox.exchange.coinbase.com

When I try to get the accounts it fails with the timestamp error:

authedClient.getAccounts(function(error, response, data){
...
});

{"statusCode":400,"body":"{"message":"request timestamp expired...

Do any other options need to be set to use this with the sandbox?

When websocket connection is closed, the orderbook should change state.

Currently, the orderbook doesn't change state when connection is lost, so client code doesn't have an opportunity to reopen the connection.
Normally, this problem can be fixed by implementing simple heartbeat functionality, but it seems Coinbase websocket API doesn't yet support ping/pong events.

Invalid API Key responce from CoinbaseExchange.AuthenticatedClient

Hello,

I can only get {message: 'Invalid API Key'} from the authClient.getOrders() response body for some reason.
The returned status code is 400

Generated and copied the API key from gdax.com/settings into:

var authClient = new CoinbaseExchange.AuthenticatedClient(key, b64secret, passphrase)

My callback code looks like this:

authClient.getOrders(function(err, response, data){
    if(err){
      console.log("Error getting orders:", err);
    }
    else{
      console.log("statusCode: ", response.statusCode);
      console.log(data);
    }
  });

Public methods are working fine, such as authClient.getProductOrderBook().

Any ideas why this is? Am I missing something? From your docs it shows that the statusCode should be 401 not 400 for this type of response.

Thanks!

Calling any method from ClojureScript on PublicClient causes error 'self.makeRelativeUri is not a function'.

traderbot.core> ((.-getProducts (cb.PublicClient.)) (fn [_ _ _] nil))
#object[TypeError TypeError: self.makeRelativeURI is not a function]
TypeError: self.makeRelativeURI is not a function
    at prototype.request (/Users/jonathan/Documents/SourceCode/traderbot/clojure/node_modules/coinbase-exchange/lib/clients/public.js:58:40)
    at apply (/Users/jonathan/Documents/SourceCode/traderbot/clojure/node_modules/coinbase-exchange/node_modules/lodash.partial/node_modules/lodash._createwrapper/index.js:72:25)
    at wrapper (/Users/jonathan/Documents/SourceCode/traderbot/clojure/node_modules/coinbase-exchange/node_modules/lodash.partial/node_modules/lodash._createwrapper/index.js:415:12)
    at prototype.getProducts (/Users/jonathan/Documents/SourceCode/traderbot/clojure/node_modules/coinbase-exchange/lib/clients/public.js:70:26)
    at eval (eval at figwheel$client$utils$eval_helper (/Users/jonathan/Documents/SourceCode/traderbot/clojure/target/server_dev/figwheel/client/utils.cljs:46:5), <anonymous>:1:140)
    at eval (eval at figwheel$client$utils$eval_helper (/Users/jonathan/Documents/SourceCode/traderbot/clojure/target/server_dev/figwheel/client/utils.cljs:46:5), <anonymous>:11:3)
    at eval (eval at figwheel$client$utils$eval_helper (/Users/jonathan/Documents/SourceCode/traderbot/clojure/target/server_dev/figwheel/client/utils.cljs:46:5), <anonymous>:16:4)
    at figwheel$client$utils$eval_helper (/Users/jonathan/Documents/SourceCode/traderbot/clojure/target/server_dev/figwheel/client/utils.cljs:46:5)

Close Websocket

I couldn't find any documentation for closing a websocket

I'm using Node.js. A simple example would be opening a websocket, then once the first message is received, close the connection. This would essentially mean "listen until you receive one, and only one message." Is this possible?

var CoinbaseExchange = require('coinbase-exchange');
var websocket = new CoinbaseExchange.WebsocketClient();

websocket.on('message', function(data) {
    console.log(data);
    websocket.done();  // or .close();
});

Transfer funds

Hello,
how I can transfer funds via coinbase-exchange api?

Orderbook Sync only returns { asks: [], bids: [] }

Readme example of Orderbook Sync

var CoinbaseExchange = require('coinbase-exchange');
var orderbookSync = new CoinbaseExchange.OrderbookSync();
console.log(orderbookSync.book.state());

only returns { asks: [], bids: [] }. Should it be return the snapshot of order book?

Update Coinbase Exchange to GDAX

Now that gdax.com officially replace exchange.coinbase.com, we should avoid endpoint redirection on the library, and decides on the new name for this library.

Failing to parse getProducts call

Looks like the request data is already parsed by the time it hits the JSON.parse(data) call in makeRequestCallback. I am seeing it throw an exception with the following data being returned:

[ { id: 'BTC-USD',
base_currency: 'BTC',
quote_currency: 'USD',
base_min_size: 0.01,
base_max_size: 10000,
quote_increment: 0.01,
display_name: 'BTC/USD' } ]

SyntaxError: Unexpected token o

This same error is happening with all the product related API calls. Also I am using the sandbox, so not sure if it is different on the live exchange.

Web socket times out after 1 minute of inactivity

On the public sandbox, I was noticing that the websocket client was exiting while trying to listen to messages. By default there is a 1 minute timeout and the connection will close if no messages are sent/received over this period.

Error thrown calling public and authenticated client methods in node-webkit/nwjs

When using the module in node-webkit I encountered an issue related to having multiple contexts:

<html>
  <body>
    <script>
      var coinbase = require("coinbase-exchange");
      var publicClient = new coinbase.PublicClient();
      publicClient.getProductTicker(function(err, resp, data){
         //this anonymous callback function is created in webkit context
      });
    </script>
  </body>
</html>

In the public client and authenticated client, for example:

if (!callback && (opts instanceof Function)) {

..checking if the callback is an instanceof Function will evaluate to false and thus throwing an error.

The explanation for this behaviour is in the nwjs docs:
https://github.com/nwjs/nw.js/wiki/Differences-of-JavaScript-contexts#working-around-differences-of-contexts

Getting error message 'request timestamp expired' when trying to post an order using Coinbase API

Hi,

Using help of https://github.com/coinbase/coinbase-php, i am trying to post order.

It's working correctly in my local server.

But when i upload to our server, we are getting error message 'request timestamp expired'.
Using this url(http://lazybux.com/info.php), you can see our server configuration.

Here is our code:

require DIR . '/vendor/autoload.php';
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey('Our API Key', 'Our API Secret');
$configuration->setApiUrl(Configuration::SANDBOX_API_URL);
$client = Client::create($configuration);

use Coinbase\Wallet\Enum\Param;
use Coinbase\Wallet\Exception\TwoFactorRequiredException;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Resource\Checkout;
use Coinbase\Wallet\Value\Money;
use Coinbase\Wallet\Resource\Order;

try {
$order = new Order([
'name' => 'Order #12',
'amount' => new Money(4, 'USD'),
]);

$client->createOrder($order);

echo $bitCoinAddress = $order->getBitcoinAddress();
$bitCoinUrl = $order->getBitcoinUri();
?>
?
}
catch(Exception $e) {
echo 'Message: ' .$e->getMessage();

}

Can you please help us to resolve this issue?
Thank you.

getProductTrades only works with pagination argument

The ReadMe says that getProductTrades method will work without providing an argument object specifying pagination details. However, that returns an error of /coinbase-exchange/lib/clients/public.js:54 throw "Must supply a callback."

publicClient.getProductTrades(callback);
// To make paginated requests, include page parameters
publicClient.getProductTrades({'after': 1000}, callback);

This could be resolved by 1.) updating the ReadMe to remove the example in the first line above that shows it being optional, 2.) or the lib could be updated to check if type is an object or a function, if it is a function then to use a default value for the pagination.

I can submit a pull request for option 2 if this is the desired solution. Let me know.

create real time sync price

Hello guys , i'm trying to create a real time app to track the real time bitcoin ask and bid price on coinbase , but every time my source unsync the actual price , can any one tell me what can i do to make it precise with the actual price bid and ask price, here goes my source:

`var CoinbaseExchange = require('coinbase-exchange');
var websocket = new CoinbaseExchange.WebsocketClient();
bid =0;
ask =0;
websocket.on('message', function(data) {

if(data.side == 'sell')
{
    if(data.price > bid )
    bid = data.price;

}else{

    if(data.price > ask)
    ask = data.price;
}

if(data.type == 'match')
{
    ask = data.price;
    bid = data.price;
}

console.log('BID:'+bid+' ASK:'+ask); 

});`

i'm really confused of how to track the current bid / ask price , pelase help me

OrderbookSync throws error in a callback

OrderbookSync throws an error inside an internal callback (when the getProductOrderBook does not successfully fetch the orderbook), see e.g. the line:
throw 'Failed to load orderbook: ' + err;
in lib/orderbook_sync.js. This error is thrown, for instance, when there is no internet connection.
It is not easy to catch this kind of error in a client application. One option how to fix this problem would be to emit the error (instead of throwing it), e.g.:
self.emit('error', 'Failed to load orderbook: ' + err);
return;

Crossed order book

If I try to determine the best bid and offer (BBO) prices at a point in time that is between receiving a 'received' message and a 'match' message, I could observe a crossed order book.

For example, if we see a 'received' message for a buy order that is priced above the best offer, the bid will be added to the orderbook which will create a crossed market until we see a 'match' message (or the 'done' message that follows if we're strictly comparing prices and not excluding zero-quantity orders).

I'm not sure what the best solution is. I'm not suggesting ignoring 'received' messages because that would lead to having 'match'es involving orders you never saw. Maybe there could be some sort of pending book?

change messages in orderbook.js

I'm taking a look at the change method in orderbook.js and it looks like its assuming that every time a change message is received, the order must be in the order book.
According to https://docs.exchange.coinbase.com/ that may not be the case: 'change messages for received but not yet open orders can be ignored when building a real-time order book.'
Am I missing something ?
Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.