Last active
March 10, 2018 21:13
-
-
Save adamjstevenson/13ccdc278cd2a874b5ad815493a217e2 to your computer and use it in GitHub Desktop.
Check the price of ETH with GDAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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