Simultaneous buy and sell orders

Does Alpaca allow placing buy and sell orders for the same security simultaneously? For example, for market making, place a limit buy order at 100.00$ and a limit sell order at 100.05$.

Older threads point out this may not be possible:

but I’m not sure if this is still the case.

Can anyone comment on this? Maybe @Dan_Whitnable_Alpaca

@bobross One can have outstanding buy and sell limit orders for the same security, but there are some caveats.

First, one must already have a position in the security to cover the sell. As an example

portfolio has 100 shares XYZ
place limit order to buy 50 shares at $100.00
place limit order to sell 50 shares $100.05

This is ok.

However, one cannot have both a buy and a sell if one does not have a current position (ie 0 shares) or enough shares to cover the sell.

portfolio has 0 shares XYZ
place limit order to buy 50 shares at $100.00
place limit order to sell 50 shares $100.05
the second sell order will fail with an error ‘cannot have a short sell order open at the same time as a long buy’

portfolio has 0 shares XYZ
place limit order to sell 50 shares $100.05
place limit order to buy 50 shares at $100.00
the second buy order will fail with an error ‘cannot have a long buy order open at the same time as a short sell’

portfolio has 100 shares XYZ
place limit order to sell 150 shares $100.05
place limit order to buy 150 shares at $100.00
the first sell order will fail with an error 'insufficient quantity available

The issue is, behind the scenes (and actually how the orders are submitted to the execution venues) there is a distinction between a ‘sell’ and a ‘sell short’ and a ‘buy’ and a ‘buy to cover’. The way Alpaca determines which kind of ‘sell’, for example, is to look at the current position. If the position is 0 then it is assumed to be a ‘sell short’. For similar reasons, one cannot sell more than one has. While logically this would seem OK to simply move from a long position to a short position in one transaction, technically this requires two orders. The first order to ‘sell’ just to get the position to 0, and a second ‘sell short’ for the remaining shares. Alpaca currently doesn’t support creating two orders like that.

So the answer is yes and no (sometimes).

2 Likes