jbooker10 / node-iex-cloud Goto Github PK
View Code? Open in Web Editor NEWnode wrapper for iex-cloud
node wrapper for iex-cloud
As this document states: https://github.com/JBooker10/node-iex-cloud#batch-symbols--types
I am having issues while using .batch()
and .then()
together.
The error is:
Property 'then' does not exist on type 'Batch'
Please help me with this.
Hi.
It appears that when I request batch data with shortInterest
with a single symbol nothing is returned.
iex.symbol("googl").batch().shortInterest()...
And when I request batch data with shortInterest
with multiple symbols via batchSymbol
, I get an error: Error: "types" required with a valid value
.
iex.batchSymbols("googl", "aapl").batch().shortInterest()...
I don't see this request within IEX-Cloud docs. Maybe it should be omitted from Batch
?
Hi there, first of thanks for this great project. I am getting an error when I use the API token in a process.env saying that the token is invalid. When I use that exact same token hard coded it works just fine. Do you have a idea why this is happening? I am running on node v14.5.0
const iex = new IEXCloudClient(fetch, {
sandbox: true,
publishable: `${process.env.IEX_API_TOKEN}`,
version: 'stable',
});
Hi.
When calling batchSymbols
, I get an error: Error: Not Found
when it is invoked for the 3rd time.
This does not happen for single symbols using symbol
.
When overwriting fetch
to output the request info, I see that the 3rd request has a bad url.
const debugFetch = (info) => {
console.log(info);
return fetch(info);
};
const iex = new IEXCloudClient(debugFetch, {...
Output (3 urls are logged at the top):
https://sandbox.iexapis.com/stable/stock/market/batch/batch?symbols=googl&types=balance-sheet,book,cash-flow,ceo-compensation,company,earnings,estimates,financials&range=1m&last=0&token=*****
https://sandbox.iexapis.com/stable/stock/market/batch/batch?symbols=googl&types=fund-ownership,income,largest-trades,logo,news,options,peers,price&range=1m&last=0&token=*****
https://sandbox.iexapis.com/stable/stock//batch?types=quote&range=1m&last=0&token=*****
Error: Not Found
at IEXRequest.<anonymous> (/home/leedavidcs/projects/app_root/node_modules/node-iex-cloud/lib/request.js:128:35)
at step (/home/leedavidcs/projects/app_root/node_modules/node-iex-cloud/lib/request.js:32:23)
at Object.next (/home/leedavidcs/projects/app_root/node_modules/node-iex-cloud/lib/request.js:13:53)
at fulfilled (/home/leedavidcs/projects/app_root/node_modules/node-iex-cloud/lib/request.js:4:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
This seems to only happen when the 3rd call is made from the same IEXCloudClient instance. So, I can work around this by creating a new IEXCloudClient instance every batch request.
Please add some error handling examples in the main Readme doc or as you see fit. Thanks for the great work.
Would be good to cover Historical 'Financials':
GET /time-series/reported_financials/{symbol?}/{filing?}
Thanks!
I get Error: Forbidden
.
``I'm currently attempting a nodeJS project using commonJS modules. Whenever I try to run my server it gives me the following error:
Error: The API key provided is not valid.
at IEXRequest. (D:\Coding\iib\node_modules\node-iex-cloud\lib\request.js:128:31)
at step (D:\Coding\iib\node_modules\node-iex-cloud\lib\request.js:32:23)
at Object.next (D:\Coding\iib\node_modules\node-iex-cloud\lib\request.js:13:53)
at fulfilled (D:\Coding\iib\node_modules\node-iex-cloud\lib\request.js:4:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
This is the code I used to install `node-iex-cloud
`const { IEXCloudClient } = require("node-iex-cloud");
const fetch = require("node-fetch");
const iex_module = new IEXCloudClient(fetch, {
sandbox: true,
publishable: "pk_API_KEY",
version: "stable"
});`
When I use the tops function I get back all symbols no matter what format I send the data in to the tops call. In the example below I expect to get only 3 symbols back. But I get all symbols in the response object res
const { IEXCloudClient } = require("node-iex-cloud");
const fetch = require("node-fetch");
const iex = new IEXCloudClient(fetch,{publishable: "pk_xxxxx", version: "stable"});
iex.tops("AAPL","GOOGL","AMZN").then(res => console.log(res));
Hi,
I am still quite new to Javascript / Reactjs. I am trying to figure out the syntax for getting the iex response promise object and assigning it to a state object.
Having this as a doc example would be good for others.
This is broken syntax so I'd like to know what the recommend syntax should be...the responses already look like json so it doesn't seem like this would do anything.
function getCurrentPriceOfBatchStocks(_stock) {
iex
.symbols(_stock)
.price()
.then(res => res.json());
}
This gives me:
Unhandled Rejection (TypeError): res.json is not a function"
Called from a button:
<Button
onClick={() => getCurrentPriceOfBatchStocks("googl,amzn,fb,aapl")}>
Get Batch of Stocks - Price
</Button>
It seems to already be a json object though but other examples with fetch show this as valid syntax..
I want to have the response object mapped to a state object like this:
state = {
stocks: [ { id: 1, name: 'AAPL', price: 329.99 }, { id: 2, name: 'AMZN', price: 2563.05 }]
}
I am calling the iex client from my own fastify server. However if I give the iex client bad input to cause an exception like an Unknown Symbol, I'm not able to catch the exception in the chain and pass it back on the response.
If I make a call to fastify like this which I expect to fail:
GET http://localhost:4000/batch_stock_prices/?stocks=12312
I get an error response of undefined. However in the node terminal output I can see the exception as seen below.
Is the iex client swallowing errors? Is there any documentation example for how to properly catch errors with this client?
Exception:
09:15:00 ✨ incoming request GET xxx /batch_stock_prices/?stocks=12312
12312
Error: Unknown symbol
at IEXRequest.<anonymous> (C:\Users\Mclovin\Desktop\modfi-stock-api\node_modules\node-iex-cloud\lib\request.js:128:35)
at step (C:\Users\Mclovin\Desktop\modfi-stock-api\node_modules\node-iex-cloud\lib\request.js:32:23)
at Object.next (C:\Users\Mclovin\Desktop\modfi-stock-api\node_modules\node-iex-cloud\lib\request.js:13:53)
at fulfilled (C:\Users\Mclovin\Desktop\modfi-stock-api\node_modules\node-iex-cloud\lib\request.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
ReferenceError: response is not defined
at getCurrentPriceOfBatchStocks (C:\Users\Mclovin\Desktop\modfi-stock-api\src\services\batch_stocks\index.js:18:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Object.<anonymous> (C:\Users\Mclovin\Desktop\modfi-stock-api\src\services\batch_stocks\index.js:53:22)
09:15:00 ✨ request completed 322ms
Code:
'use strict'
const fetch = require('node-fetch')
const { IEXCloudClient } = require("node-iex-cloud")
const iex = new IEXCloudClient(fetch, {
sandbox: true,
// publishable: "pk_2f78524e53454cf88afba23c327e24b5",
publishable: "pk_2f78524e53454cf88afba23c327e24b5",
version: "stable"
})
async function getCurrentPriceOfBatchStocks(_stock) {
const stocks_to_submit = _stock['stocks'];
console.log(stocks_to_submit)
response = await iex
.batchSymbols(stocks_to_submit)
.price()
.catch(function (error) {
console.log("Exception: " + error);
throw error;
})
return Promise((resolve, reject) => {
if (response) {
resolve(response)
} else {
reject(response);
}
});
}
const batchStocksSchema = {
querystring: {
type: 'object',
properties: {
stocks: {
type: 'string'
}
},
required: ['stocks']
}
}
module.exports = async function (fastify, opts) {
fastify.get('/batch_stock_prices/', {
schema: batchStocksSchema
}, async function (request, reply) {
try {
var response = await getCurrentPriceOfBatchStocks(request.query)
// console.log(response)
return reply
.code(200)
.send(response);
} catch (e) {
console.log(e)
return reply
.code(400)
.send('Bad Request, exception: ' + e)
}
})
}
Hi.
I'm trying to get some stock data for a specific date.
The official IEX Cloud documentation suggests the following format:
/stock/aapl/chart/date/20190109?chartByDay=true
The request for the chart
data looks like this:
return _this.request('chart/' + range + (params
? '?' + Object.entries(params).map(param => `${param[0]}=${param[1]}`).join('&')
: ''));
As I understand, it's not possible to load the stock data for a specific date.
Please let me know if I can do a PR that adds this functionality.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.