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

get_orders_by_query() with multiple statuses leads to HTTP 400 "error" : is not a valid Order #169

Open
ray310 opened this issue Feb 13, 2021 · 1 comment

Comments

@ray310
Copy link

ray310 commented Feb 13, 2021

Description of Bug
When attempting to query orders with multiple statuses such as FILLED and QUEUED , a 400 "error" : "'FILLED,QUEUED' is not a valid Order Status.... is returned as the response.

Code to Reproduce

client = tda.auth.client_from_token_file(token_path, api_key)

my_statuses = [
    tda.client.Client.Order.Status.FILLED,
    tda.client.Client.Order.Status.QUEUED,
]

orders = client.get_orders_by_query(statuses=my_statuses)
print(orders.content)  # "error" : "\'FILLED,QUEUED\' is not a valid Order Status.

Expected Behavior
Expected the function to return a HTTP 200 Response object with orders containing the input statuses

Actual Behavior
Returned HTTP 400 Response indicating an error with the formatting of the query

Error/Exception Log, If Applicable
bug.log

@ray310
Copy link
Author

ray310 commented Feb 13, 2021

I think the issue may be in line 178 in tda/client/base with the make_order_query() function.

def _make_order_query(self,
                          *,
                          max_results=None,
                          from_entered_datetime=None,
                          to_entered_datetime=None,
                          status=None,
                          statuses=None):
        status = self.convert_enum(status, self.Order.Status)
        statuses = self.convert_enum_iterable(statuses, self.Order.Status)  # returns a list

        if status:
            params['status'] = status
        if statuses:
            params['status'] = ','.join(statuses)  # I think this is causing the issue

        return params

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 a pull request may close this issue.

1 participant