Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active March 10, 2018 21:13
Show Gist options
  • Save adamjstevenson/13ccdc278cd2a874b5ad815493a217e2 to your computer and use it in GitHub Desktop.
Save adamjstevenson/13ccdc278cd2a874b5ad815493a217e2 to your computer and use it in GitHub Desktop.
Check the price of ETH with GDAX
// Check the price of ETH to determine how much to buy
gdaxClient.getProductTicker(
'ETH-USD'
)
.then(data => {
// Determine what $10 of ETH costs
const price = (10/data.price);
// Return smallest unit available for purchase
const orderSize = price.toString().substr(0,10);
// Place a buy order
buyOrder(orderSize, data.price);
})
.catch(err => {
// Dump the entire error and send failure notification
console.error(err);
sendSMS("Unable to get ETH ticker price. Response from GDAX: "+err.response.statusMessage+ ", "+err.data.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment