Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not valid stock symbol weird output #226

Open
2 of 9 tasks
jacksteussie opened this issue Nov 13, 2020 · 2 comments
Open
2 of 9 tasks

not valid stock symbol weird output #226

jacksteussie opened this issue Nov 13, 2020 · 2 comments

Comments

@jacksteussie
Copy link

Issue Label:

  • Bug
  • New feature
  • Enhancement
  • New component

Description:
I get the correct output when I do:

bash -x stocks nvda

But when I do just:

stocks nvda

I get the not a valid stock symbol error.

If its a bug make sure to include this section.

OS and OS version:

  • Mac
  • Linux 32 Bit
  • Linux 64 Bit
  • Windows 32 Bit
  • Windows 64 Bit

OS Version: Fedora 33

@navanchauhan
Copy link
Contributor

navanchauhan commented Nov 14, 2020

This is because of changes made to the API service being used. It now requires an API key. The bash snippet will be needed to be updated to provide the API key.

stockProfile="$(httpGet "https://financialmodelingprep.com/api/v3/company/profile/${1}")" > /dev/null
# this is realtime data.
stockPrice="$(httpGet "https://financialmodelingprep.com/api/v3/stock/real-time-price/${1}")" > /dev/null
# necessary for python in some cases
export PYTHONIOENCODING=utf8
# checking if we get any information back from the server if not
# chances are it isnt a valid stock symbol
AccessJsonElement "$stockProfile" "profile" "companyName" > /dev/null 2>&1 \
|| { echo "$1: Not a valid stock symbol"; exit 1; }

Output of bash -x stocks nvda

...
+ unset response
+ printStockInformation NVDA
++ httpGet https://financialmodelingprep.com/api/v3/company/profile/NVDA
++ case "$configuredClient" in
++ curl -A curl -s https://financialmodelingprep.com/api/v3/company/profile/NVDA
+ stockProfile='{"Error Message" : "Invalid API KEY. Please retry or visit our documentation to create one FREE https://financialmodelingprep.com/developer/docs"}'
++ httpGet https://financialmodelingprep.com/api/v3/stock/real-time-price/NVDA
++ case "$configuredClient" in
++ curl -A curl -s https://financialmodelingprep.com/api/v3/stock/real-time-price/NVDA
+ stockPrice='{"Error Message" : "Invalid API KEY. Please retry or visit our documentation to create one FREE https://financialmodelingprep.com/developer/docs"}'
+ export PYTHONIOENCODING=utf8
+ PYTHONIOENCODING=utf8
+ AccessJsonElement '{"Error Message" : "Invalid API KEY. Please retry or visit our documentation to create one FREE https://financialmodelingprep.com/developer/docs"}' profile companyName
+ echo 'NVDA: Not a valid stock symbol'
NVDA: Not a valid stock symbol
+ exit 1

As you can see the error message states the API key is invalid. You can either patch the snippet yourself and pass a free API key you can get from their website or you can wait until this issue is fixed ( but even then you will have to generate the API key yourself and put it in you ~/.bashrc, ~/.bash_profile or ~./zshrc as the API key cannot be provided with the bash-snippets code.

@alexanderepstein
Copy link
Owner

Hmm so if they now require an api key it means I should try to find another service that does it for free, my goal with bash-snippets is to prevent any need for setup and api keys are usually something I try to work around. If anyone would like to take up replacing the current stocks api with a different one that didn't use an API key I would most likely merge the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants