generateStock fails to push certain tickers to db
Closed this issue · 6 comments
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "name"). If you want to ignore undefined values, enable ignoreUndefinedProperties
.
at validateUserInput (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/node_modules/@google-cloud/firestore/build/src/serializer.js:271:19)
at Object.validateUserInput (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/node_modules/@google-cloud/firestore/build/src/serializer.js:263:13)
at validateDocumentData (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/node_modules/@google-cloud/firestore/build/src/write-batch.js:577:18)
at WriteBatch.set (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/node_modules/@google-cloud/firestore/build/src/write-batch.js:243:9)
at DocumentReference.set (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/node_modules/@google-cloud/firestore/build/src/reference.js:349:14)
at Object.addStock (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/data/stocks.js:141:59)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async generateStocks (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/data/stocks.js:155:7)
at async runScript (/Users/HNizami/Desktop/Stevens/Semester6/shifts/backend/api/script.js:62:9)
^C
(base)
Crashes after 6 stocks load
ICLN is an ETF which does not have any data in Alphavantage go. So maybe we can show an error to say it's not supported or give a warning.
https://finnhub.io/docs/api/company-profile2 potentially use this instead
check if data is null, if so then query finnhub etf. if that is null, indicate to user that it is not supported
or
db.settings({ ignoreUndefinedProperties: true })