Advertisement
BigRedDoge

Untitled

Apr 12th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. const Gdax = require('gdax');
  2. const publicClient = new Gdax.PublicClient();
  3.  
  4. function loop() {
  5.  
  6. publicClient.getProduct24HrStats('BTC-USD', (err, response, data) => {
  7.  
  8. if (err) {
  9. console.log(err);
  10. } else {
  11. console.log("BITCOIN");
  12. console.log("Last Price: $" + parseFloat(JSON.parse(response.body).last).toFixed(2));
  13. console.log("High Price: $" + parseFloat(JSON.parse(response.body).high).toFixed(2));
  14. console.log("Low Price: $" + parseFloat(JSON.parse(response.body).low).toFixed(2));
  15. console.log(" ");
  16. }
  17. });
  18.  
  19. publicClient.getProduct24HrStats('ETH-USD', (err, response, data) => {
  20. if (err) {
  21. console.log(err);
  22. } else {
  23. console.log("ETHEREUM");
  24. console.log("Last Price: $" + parseFloat(JSON.parse(response.body).last).toFixed(2));
  25. console.log("High Price: $" + parseFloat(JSON.parse(response.body).high).toFixed(2));
  26. console.log("Low Price: $" + parseFloat(JSON.parse(response.body).low).toFixed(2));
  27. console.log(" ");
  28. }
  29. });
  30.  
  31.  
  32.  
  33. publicClient.getProduct24HrStats('LTC-USD', (err, response, data) => {
  34. if (err) {
  35. console.log(err);
  36. } else {
  37. console.log("LITECOIN");
  38. console.log("Last Price: $" + parseFloat(JSON.parse(response.body).last).toFixed(2));
  39. console.log("High Price: $" + parseFloat(JSON.parse(response.body).high).toFixed(2));
  40. console.log("Low Price: $" + parseFloat(JSON.parse(response.body).low).toFixed(2));
  41. console.log(" ");
  42. }
  43. });
  44.  
  45. setTimeout(function() { loop(); }, 3000);
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement