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

Options Chain command (options_chain) errors out while retrieving information #16

Closed
sher85 opened this issue Sep 4, 2020 · 6 comments

Comments

@sher85
Copy link

sher85 commented Sep 4, 2020

while using the options.chain command in jupyter notebook, the code block displayed at the end of this issue errors out. In the error description, I can read the following

FinnhubRequestException: FinnhubRequestException: Invalid Response:

followed by the actual information I was requesting which is too lengthy to show here.
The code producing this error is this:

import finnhub
import os
finnhub_client = finnhub.Client(api_key=os.environ['FINNHUB_KEY'])

test = finnhub_client.option_chain(symbol='TSLA')
@KurtPrice
Copy link

I've been seeing the same issue. I'm not sure why this is happening. I'm going to look into a fix myself. My initial thoughts are that the validation on responses is incorrect and throwing this exception erroneously. Using the API documentation I was able to find https://finnhub.io/api/v1/stock/option-chain?symbol=TSLA which works without an API key in my browser. So in the mean time it may just be best to setup something with bs4 to grab the info from https.

If you have any ideas that are causing this issue, let me know here. I'd be excited to actually resolve this issue.

@KurtPrice
Copy link

Okay, so I figured out the root cause. It turns out that the api is returning the message without encoding. i.e. content-type = 'text/plain'.

client.py:L52 with raise the exception that we see here. In the mean time you can add an if statement to handle this specific call. I have a hunch that this is the expected behavior by the client, and the real issue lies with the API not setting the content-type to be application/json.

I'll make a pull request either way to fix this.

@KurtPrice
Copy link

Pull request I mentioned above: #18 @nongdenchet

@nongdenchet
Copy link
Contributor

hey guys I have been busy recently. Let's me have a look

nongdenchet added a commit that referenced this issue Sep 19, 2020
@nongdenchet
Copy link
Contributor

Please upgrade your library to 2.2.1 to get the fix

@nongdenchet
Copy link
Contributor

I have tested and confirmed that the issue is fixed for me. Thank you @KurtPrice

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