Skip to content

place_equity_order and preview_equity_order ignore resp_format parameter #123

@FrenchCommando

Description

@FrenchCommando

Four methods in order.py hardcode "xml" in the final perform_request call, ignoring the resp_format kwarg passed by the caller:

  • preview_equity_order (line 548)
  • place_option_order (line 574)
  • place_equity_order (line 619)
  • place_option_order — the PUT variant (line 669)

e.g. place_equity_order, line 619

return self.perform_request(self.session.post, api_url, payload, "xml")

When a user passes resp_format="json", the request is still sent and parsed as XML via xmltodict. This means the response structure differs from what the JSON documentation shows (e.g.
single items become dicts instead of lists), and the resp_format parameter is effectively dead code in these methods.

Expected behavior: resp_format should be forwarded to perform_request, consistent with how other methods like list_order_details handle it.

Suggested fix:
return self.perform_request(
self.session.post, api_url, payload, kwargs.get("resp_format", "xml")
)

Found in pyetrade 2.1.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions