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

Ally Invest returning HTML with response.ok #4

Open
wmorgansoftware opened this issue Feb 4, 2022 · 2 comments
Open

Ally Invest returning HTML with response.ok #4

wmorgansoftware opened this issue Feb 4, 2022 · 2 comments

Comments

@wmorgansoftware
Copy link
Contributor

I have been noticing an issue with the return of JSON data with Ally. Be aware I've been running a home-brew API, but noticed your code would return the same issue, so I'm adding it to help out.

Lately, I have been receiving intermittent responses from Ally where the status_code is 200, but the content is HTML webpage code stating an error on their end, instead of JSON stating something similar. As a result, when attempting to run response.json(), I get the following traceback in a 500 error:

  ... Traceback to my own code ...
    return resp.json()
  File "[PATH]/venv/lib/python3.9/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

See if something similar is happening to you; I'd love to collaborate with you on this.

return response.json()

Also as an aside (but unrelated), let me know if you're OK with pull requests on this code, as my work has done some things with orders and order previews; I'm in the process of making something for orders POST to automate trades, but this issue has been slowing my progress.

@anthonymorast
Copy link
Owner

Hi, thanks for submitting this issue. First and foremost, I'm 100% OK with Pull Requests (apologies in advance if I don't get to them right away) I would really like to see this project grow and develop into something highly applicable.

As for the error, I believe I have seen this before. If I recall correctly, in my case Ally was throttling my API calls since I was submitting too many requests or something along those lines (I could be wrong as it's been a while).

Do you know what errors you're getting in the HTML are? From this project's perspective, I don't think there's much we can do besides check if we're getting JSON back and return an error (and the HTML) if not since it's unpredictable what Ally might send back from a request.

@wmorgansoftware
Copy link
Contributor Author

So with the HTML, the contents are the "Site is experiencing issues" page that shows up if you go to Ally Invest with an internet browser and things are down. I reported it to them a while back because it wasn't JSON, and got the typical "We'll look into it" without follow-up. I agree the only thing we can do is a check to make sure that it's in JSON format, even if it's just a try/except on JSONDecodeError. They did do some adjustments over the weekend (probably from all the API call rejections happening last week, even the first request), so I want to see if the issue is OBE before making any changes.

I know there's a 60 call per minute limit. Also, on my interpretation, I'm using another source for prices because it's real-time, whereas Ally is on the delay. It's Yahoo so who knows what will happen; I still remember the whole debacle about people figuring out what the letter codes meant for the quote URL calls, and they went crazy and destroyed everything.

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

2 participants