Skip to content

Conversation

@presto8
Copy link
Contributor

@presto8 presto8 commented Nov 28, 2025

The API response from ETrade does not always contain the error code, which will cause a KeyError exception. This changeset adds a guard to handle this condition.

  File "/home/avo/src/et/pyetrade_dev/order.py", line 644, in place_option_order
    return self.place_equity_order(**kwargs)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/avo/src/et/pyetrade_dev/order.py", line 669, in place_equity_order
    return self.perform_request(self.session.post, api_url, payload, "xml")
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/avo/src/et/pyetrade_dev/order.py", line 474, in perform_request
    return get_request_result(req, resp_format)
  File "/home/avo/src/et/pyetrade_dev/order.py", line 58, in get_request_result
    f'Etrade API Error - Code: {req_output["Error"]["code"]}, Msg: {req_output["Error"]["message"]}'
                                ~~~~~~~~~~~~~~~~~~~^^^^^^^^

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

Successfully merging this pull request may close these issues.

1 participant