Last active
March 10, 2018 23:11
-
-
Save adamjstevenson/220dc8c7cb11d7c6da09789d5cd35a2c to your computer and use it in GitHub Desktop.
Place a buy order on 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
// 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