alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
141 stars 13 forks source link

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

Closed sshcli closed 1 year ago

sshcli commented 2 years ago

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

drew887 commented 2 years ago

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.

sshcli commented 2 years ago

Thank you @drew887 for your clarification. Regards,

sshcli commented 1 year ago

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