alpaca-py icon indicating copy to clipboard operation
alpaca-py copied to clipboard

[Feature Request] Merge similar orders

Open sshcli opened this issue 3 years ago • 6 comments
trafficstars

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe.

About the problem:

  • There is a limit of 500 sell orders, you can't have more
  • More orders means slow response
  • You must pay reg fees for every sale order
  • You get unnecessary errors with api call

Describe the solution you'd like.

For example: We have 3 separated orders to sell AAPL at $170.02

Sell Order1: Symbol: APPL Qty: 1 Limit Price: 172.02

Sell Order2: Symbol: APPL Qty: 5 Limit Price: 172.02

Sell Order3: Symbol: APPL Qty: 3 Limit Price: 172.02

We need a feature to be able to convert those 3 orders in just 1 order. The results will be something like this:

Unique Sell Order: Symbol: APPL Qty: 9 Limit Price: 172.02

This new feature will help us to:

  • Reduce the amount of open orders
  • Reduce the time spent querying open orders
  • Reduce regulatory fees
  • Avoid unnecessary errors with api call

Describe an alternate solution.

Occam's razor | keep it simple

Anything else? (Additional Context)

Occam's razor | keep it simple

sshcli avatar Oct 23 '22 14:10 sshcli

More simply, I think it would be nice to have a backend feature to merge an unsubmitted new order into an accepted order. This is assuming the direction of long or short is the same across the two orders. Currently this doesn't seem possible. I assume the combined limit price can then be its weighted average. If the merge fails, then just the new order can be submitted.

In any case, I don't think this package is the best place for backend requests. This package is just the SDK over the backend interfaces.

impredicative avatar Oct 25 '22 00:10 impredicative

The feature could be also available in the web version. See image below: merge-similar-orders

sshcli avatar Nov 02 '22 15:11 sshcli

I am not convinced that this should be a global setting for the account. I currently take the more conservative opinion that it should be API driven.

impredicative avatar Nov 02 '22 16:11 impredicative

Someone from Alpaca team has suggested a method in the py package.

sshcli avatar Nov 02 '22 18:11 sshcli

Someone from Alpaca team has suggested a method in the py package.

I have looked and there is no applicable method that replaces an accepted order. The only way I know to do it is to cancel the existing order(s) and submit a new order.

impredicative avatar Nov 02 '22 18:11 impredicative

The suggestion was for implement it, is not available yet.

sshcli avatar Nov 02 '22 19:11 sshcli