Closed tristanpenman closed 2 months ago
@itsjafer apologies for taking so long to get this ready for review. This has been on my TODO list for many weeks now, and I've just gone through and tidied up my changes. The main changes since I first raised the PR are:
lazy
parameter for the login
method. I found that this was more practical when testing with my mini trading server. It ensures that the server starts up, even if the Schwab API is down. Login attempts will be performed lazily, on subsequent requests. This is the same as if the previous login credentials expire.I've tried to ensure that this is all backwards compatible with the existing API.
As far as potential improvements go, I think it would be worth rate-limiting login attempts. However, I chose not to do that as part of this PR, to keep the changeset reasonably small. It is also possible for the async login process to get stuck when invalid credentials are used - I think this is pre-existing, so I'll raise an issue for that.
Thanks for the PR! I looked through the code and didn't find anything of note -- I'll test out the functionality locally sometime this week to confirm it works as expected, and then merge this in!
Raising this as a draft, for some early feedback. This is just my first pass at doing this, and I feel that some of the error cases are not yet handled well enough.
A quick summary of the changes so far:
update_token
failsKeen to hear what you think!