# Having issue with bracket orders

**URL:** <https://forum.alpaca.markets/t/having-issue-with-bracket-orders/11415>\
**Category:** Alpaca Trading\
**Created:** [December 23, 2022, 8:10pm UTC](https://forum.alpaca.markets/t/having-issue-with-bracket-orders/11415 "2022-12-23T20:10:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephon2019](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/stephon2019/32/4946_2.png) [@stephon2019](https://forum.alpaca.markets/u/stephon2019)\
**Post date:** [December 23, 2022, 8:10pm UTC](https://forum.alpaca.markets/t/having-issue-with-bracket-orders/11415/1 "2022-12-23T20:10:54Z")

</div>

Hi, I’m having some issues with the sdk in submitting bracket orders.

I’m trying to do something like buy I share of TSLA stock with a stop sell order

```python
symbol = 'TSLA'
quantity = 1

stop_price = 120
take_profit_price = 135

take_profit_request = TakeProfitRequest(
    limit_price=take_profit_price
)

stop_loss_request = StopLossRequest(
    stop_price=stop_price
)

market_order = MarketOrderRequest(
    symbol = symbol, 
    qty = quantity, 
    side = OrderSide.BUY, 
    time_in_force = TimeInForce.GTC, 
    take_profit = take_profit_request, 
    stop_loss= stop_loss_request, 
    order_class = OrderClass.BRACKET
    
)
order = trading_client.submit_order(order_data=market_order)

```

**I do this and get the following error:**

```auto
ValidationError Traceback (most recent call last)
c:\Users\srerr\Documents\Projects\PersonalProjects\stonks\alpaca\strategies\rsi_long_short_stocks.ipynb Cell 13 in <cell line: 1>()
----> 1 order = trading_client.submit_order(order_data=market_order)

File c:\Users\srerr\.conda\envs\stonks\lib\site-packages\alpaca\trading\client.py:94, in TradingClient.submit_order(self, order_data)
     91 if self._use_raw_data:
     92 return response
---> 94 return Order(**response)

File c:\Users\srerr\.conda\envs\stonks\lib\site-packages\alpaca\trading\models.py:182, in Order. __init__ (self, **data)
    179 if "order_class" not in data or data["order_class"] == "":
    180 data["order_class"] = OrderClass.SIMPLE
--> 182 super(). __init__ (**data)

File c:\Users\srerr\.conda\envs\stonks\lib\site-packages\pydantic\main.py:342, in pydantic.main.BaseModel. __init__ ()

ValidationError: 2 validation errors for Order
legs -> 0 -> status
  value is not a valid enumeration member; permitted: 'new', 'partially_filled', 'filled', 'done_for_day', 'canceled', 'expired', 'replaced', 'pending_cancel', 'pending_replace', 'accepted', 'pending_new', 'accepted_for_bidding', 'stopped', 'rejected', 'suspended', 'calculated' (type=type_error.enum; enum_values=[<OrderStatus.NEW: 'new'>, <OrderStatus.PARTIALLY_FILLED: 'partially_filled'>, <OrderStatus.FILLED: 'filled'>, <OrderStatus.DONE_FOR_DAY: 'done_for_day'>, <OrderStatus.CANCELED: 'canceled'>, <OrderStatus.EXPIRED: 'expired'>, <OrderStatus.REPLACED: 'replaced'>, <OrderStatus.PENDING_CANCEL: 'pending_cancel'>, <OrderStatus.PENDING_REPLACE: 'pending_replace'>, <OrderStatus.ACCEPTED: 'accepted'>, <OrderStatus.PENDING_NEW: 'pending_new'>, <OrderStatus.ACCEPTED_FOR_BIDDING: 'accepted_for_bidding'>, <OrderStatus.STOPPED: 'stopped'>, <OrderStatus.REJECTED: 'rejected'>, <OrderStatus.SUSPENDED: 'suspended'>, <OrderStatus.CALCULATED: 'calculated'>])
legs -> 1 -> status
  value is not a valid enumeration member; permitted: 'new', 'partially_filled', 'filled', 'done_for_day', 'canceled', 'expired', 'replaced', 'pending_cancel', 'pending_replace', 'accepted', 'pending_new', 'accepted_for_bidding', 'stopped', 'rejected', 'suspended', 'calculated' (type=type_error.enum; enum_values=[<OrderStatus.NEW: 'new'>, <OrderStatus.PARTIALLY_FILLED: 'partially_filled'>, <OrderStatus.FILLED: 'filled'>, <OrderStatus.DONE_FOR_DAY: 'done_for_day'>, <OrderStatus.CANCELED: 'canceled'>, <OrderStatus.EXPIRED: 'expired'>, <OrderStatus.REPLACED: 'replaced'>, <OrderStatus.PENDING_CANCEL: 'pending_cancel'>, <OrderStatus.PENDING_REPLACE: 'pending_replace'>, <OrderStatus.ACCEPTED: 'accepted'>, <OrderStatus.PENDING_NEW: 'pending_new'>, <OrderStatus.ACCEPTED_FOR_BIDDING: 'accepted_for_bidding'>, <OrderStatus.STOPPED: 'stopped'>, <OrderStatus.REJECTED: 'rejected'>, <OrderStatus.SUSPENDED: 'suspended'>, <OrderStatus.CALCULATED: 'calculated'>])

```

Would really appreciate some help on this. I get this `ValidationError` but when I check my alpaca markets dashboard, I’m seeing that the market buy order goes through and the legs of the trade are there as well. not sure what’s going on. thanks

---

<div class="post-metadata">

**Author:** ![phellstrand](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/phellstrand/32/4169_2.png) [@phellstrand](https://forum.alpaca.markets/u/phellstrand)\
**Post date:** [April 4, 2023, 9:50pm UTC](https://forum.alpaca.markets/t/having-issue-with-bracket-orders/11415/2 "2023-04-04T21:50:25Z")

</div>

You’re a godsend; I struggled with the syntax for a bracket order with the updated alpaca-py library, and your code example works perfectly. It’s crazy that it’s not documented anywhere for the updated API.

Thank you!  
P
