Guest User

Untitled

a guest
Oct 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. const anychart = require("anychart");
  2. const alp = require("alphavantage")({ key: "~" });
  3.  
  4. let stockdata = [];
  5.  
  6. anychart.onDocumentLoad(async () => {
  7. await alp.data.intraday(`amzn`).then(async data => {
  8. data = data["Time Series (1min)"];
  9.  
  10. for (let elt in data) {
  11. stockdata.push([
  12. () => {
  13. elt = stockdata[elt][0].split(" ");
  14. let hour = parseInt(elt[1].slice(0, 3));
  15. if (hour > 12) {
  16. hour -= 12;
  17. }
  18. return hour + ":" + elt[1].slice(3, 5);
  19. },
  20. (parseInt(elt["1. open"]) +
  21. parseInt(elt["2. high"]) +
  22. parseInt(elt["3. low"]) +
  23. parseInt(elt["4. close"])) /
  24. 4
  25. ]);
  26. }
  27. anychart
  28. .line(stockdata)
  29. .container("container")
  30. .draw();
  31. });
  32. });
Add Comment
Please, Sign In to add comment