Skip to content

Instantly share code, notes, and snippets.

@adamjstevenson
Last active March 10, 2018 23:11
Show Gist options
  • Select an option

  • Save adamjstevenson/220dc8c7cb11d7c6da09789d5cd35a2c to your computer and use it in GitHub Desktop.

Select an option

Save adamjstevenson/220dc8c7cb11d7c6da09789d5cd35a2c to your computer and use it in GitHub Desktop.

Revisions

  1. adamjstevenson revised this gist Mar 10, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gdax-buy.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ function buyOrder(orderSize, currentPrice){
    const args = {
    'product_id': 'ETH-USD',
    'type': 'market',
    'side': 'buys',
    'side': 'buy',
    'size': orderSize
    }

  2. adamjstevenson created this gist Mar 10, 2018.
    20 changes: 20 additions & 0 deletions gdax-buy.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // Place a buy order
    function buyOrder(orderSize, currentPrice){
    const args = {
    'product_id': 'ETH-USD',
    'type': 'market',
    'side': 'buys',
    '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);
    });
    }