Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active March 10, 2018 23:11
Show Gist options
  • Save adamjstevenson/220dc8c7cb11d7c6da09789d5cd35a2c to your computer and use it in GitHub Desktop.
Save adamjstevenson/220dc8c7cb11d7c6da09789d5cd35a2c to your computer and use it in GitHub Desktop.
Place a buy order on GDAX
// Place a buy order
function buyOrder(orderSize, currentPrice){
const args = {
'product_id': 'ETH-USD',
'type': 'market',
'side': 'buy',
'size': orderSize
}
gdaxClient.buy(args)
.then(data => {
// Send success notification
sendSMS("💸 Purchased "+orderSize+" ETH! The current USD price of ETH is $"+currentPrice.substr(0,6)+".");
})
.catch(err => {
// Dump the entire error and send failure notification
console.error(err);
sendSMS("Unable to place buy order for ETH. 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