From 4f1e58e3d49ee480bd0933d88bc89453c6f9247f Mon Sep 17 00:00:00 2001 From: Chris Vanderloo Date: Wed, 15 Aug 2018 17:13:01 -0400 Subject: [PATCH] added error handling alpha vantage --- examples/example.js | 4 ++-- src/index.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/example.js b/examples/example.js index 999bb9c..70ce856 100644 --- a/examples/example.js +++ b/examples/example.js @@ -51,6 +51,6 @@ client.init({ function emaAlgorithm(buy, sell, data) { console.log(" ") console.log(data.price); - console.log(data.sma.daily(50)); - console.log(data.sma.daily(200)); + console.log(data.ema.daily(10)); + console.log(data.ema.daily(50)); } \ No newline at end of file diff --git a/src/index.js b/src/index.js index bda9de1..c1c3e35 100644 --- a/src/index.js +++ b/src/index.js @@ -195,6 +195,9 @@ module.exports = { } }).then((res) => { res = JSON.parse(res); + if (res['Information']) throw new Error( + "Alpha Vantage Call volume exceeded - try decreasing how often the API is verified" + ); var obj = res[Object.keys(res)[1]]; var first_el = obj[Object.keys(obj)[0]]; callback(first_el[Object.keys(first_el)[0]]); -- 2.51.2