-
-
Save FernandoEscher/5103601 to your computer and use it in GitHub Desktop.
Revisions
-
FernandoEscher revised this gist
Mar 7, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ var quantity = 10; var expectedPrice = 44.00 var jsonData = { qty: quantity }; function onComplete(data, res) { console.log(new Date().toString()); -
FernandoEscher revised this gist
Mar 6, 2013 . 1 changed file with 17 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,11 +7,13 @@ var sys = require('util'), rest = require('restler'); //set these to your coinbase API key, the amount you want to buy & the price that you're expecting for var apiKey = 'xxx'; var quantity = 10; var expectedPrice = 44.00 var jsonData = { qty: quantity }; var currentPrice = 0.0 function onComplete(data, res) { console.log(new Date().toString()); @@ -25,7 +27,19 @@ function onComplete(data, res) { }; function buy() { // Will check the price until it reaches the expected value rest.get('https://coinbase.com/api/v1/prices/buy').on('complete', function(data){ console.log("Current price: "+data.amount+". Expected price: "+expectedPrice) if(data.amount <= expectedPrice){ rest.postJson('https://coinbase.com/api/v1/buys?api_key=' + apiKey, jsonData).on('complete', onComplete); }else{ setTimeout(buy, 60000) } return }); } buy(); -
chenosaurus revised this gist
Mar 6, 2013 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ //you will need to install node.js and restler first //npm install restler //run with the following command // node buy.js var sys = require('util'), rest = require('restler'); -
chenosaurus renamed this gist
Mar 6, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chenosaurus created this gist
Mar 6, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ //you will need to install node.js and restler first //npm install restler var sys = require('util'), rest = require('restler'); //set these to your coinbase API key & the amount you want to buy var apiKey = 'xxx'; var quantity: 10; var jsonData = { qty: quantity }; function onComplete(data, res) { console.log(new Date().toString()); if (!data.success) { console.log(data.errors); setTimeout(buy, 5000); } else { console.log("SUCCESS!"); } }; function buy() { rest.postJson('https://coinbase.com/api/v1/buys?api_key=' + apiKey, jsonData).on('complete', onComplete); } buy();