Alpaca-API icon indicating copy to clipboard operation
Alpaca-API copied to clipboard

[Feature Request] api.cancel_all_orders(side='buy')

Open sshcli opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. According to de documentation here: https://alpaca.markets/docs/api-references/trading-api/orders/

You can only cancel all orders, there is no parameters to specify the side you want to cancel. (Buy or Sell)

The following optional params does not work here:

api.cancel_all_orders(params={'side':'buy'})
api.cancel_all_orders(params={'side':'sell'})

Describe the solution you'd like We need an easy way to cancel all orders filtered by the side (Cancel all buy orders or cancel or sell orders)

We need something like these:

api.cancel_all_orders(side='buy')
api.cancel_all_orders(side='sell')

Describe alternatives you've considered As a workaround you could try to perform this task by adding extra Python code to your program. But IMHO, simple is better than complex

Additional context In response to the request made here https://github.com/alpacahq/alpaca-trade-api-python/issues/611

sshcli avatar Apr 26 '22 01:04 sshcli

Hey @sshcli just to clarify a little when I asked you to open an issue here it was about requesting that the api endpoint itself be updated to have the new query parameter to allow for the functionality, not to come here and ask for changes to the python sdk 😞; sorry about not being more clear on that front.

For clarity for everyone else, this request is to update the Trading api endpoint for deleting all orders (DELETE /v2/orders) to allow for a new query parameter named side that allows you to cancel orders only matching that side. IE specifying ?side=buy will only close out your orders to buy; leaving your sell orders in place.

drew887 avatar Apr 26 '22 01:04 drew887

Thank you @drew887 for your clarification. Regards,

sshcli avatar Apr 26 '22 02:04 sshcli

This can be done in the new SDK GetOrdersRequest(symbols=[symbol], side='buy')

See: https://github.com/alpacahq/alpaca-py/issues/140

I'm closing this one

sshcli avatar Oct 23 '22 14:10 sshcli