# Simultaneous buy and sell orders

**URL:** <https://forum.alpaca.markets/t/simultaneous-buy-and-sell-orders/11992>\
**Category:** Alpaca Trading\
**Created:** [March 11, 2023, 8:06am UTC](https://forum.alpaca.markets/t/simultaneous-buy-and-sell-orders/11992 "2023-03-11T08:06:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobross](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@bobross](https://forum.alpaca.markets/u/bobross)\
**Post date:** [March 11, 2023, 8:06am UTC](https://forum.alpaca.markets/t/simultaneous-buy-and-sell-orders/11992/1 "2023-03-11T08:06:42Z")

</div>

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:

> [@Submit Buy & Sell Limit Orders at same time](https://forum.alpaca.markets/t/submit-buy-sell-limit-orders-at-same-time/2131):
>
> Is there any plans to support entering limits orders for both buy and sell at the same time. So if I wanted to sell at the ask and buy at the bid, one will get filled and the other order is a valid closing order.

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

---

<div class="post-metadata">

**Author:** ![bobross](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@bobross](https://forum.alpaca.markets/u/bobross)\
**Post date:** [March 14, 2023, 7:56am UTC](https://forum.alpaca.markets/t/simultaneous-buy-and-sell-orders/11992/2 "2023-03-14T07:56:29Z")

</div>

Can anyone comment on this? Maybe @Dan_Whitnable_Alpaca

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [March 14, 2023, 1:32pm UTC](https://forum.alpaca.markets/t/simultaneous-buy-and-sell-orders/11992/3 "2023-03-14T13:32:07Z")

</div>

@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).
