Skip to content

Bracket Order Support

Compare
Choose a tag to compare
@ttt733 ttt733 released this 06 Feb 07:02
· 248 commits to master since this release
8571b86

This release adds support for bracket orders. Bracket orders are submitted to the Alpaca API like so:

{
  "side": "buy",
  "symbol": "SPY",
  "type": "market",
  "qty": "100",
  "time_in_force": "gtc",
  "class": "bracket",
  "take_profit": {
    "limit_price": "301"
  },
  "stop_loss": {
    "stop_price": "299",
    "limit_price": "298.5"
  }
}

Fields matching these have been added to the PlaceOrderRequest object. Please also note the inclusion of the new nested parameter in the order list call. Specifying nested as true will make it so that bracket orders have legs fields which will contain their child orders. Child orders will be in this nested field rather than the main array of orders. For more information about using bracket orders with Alpaca, please refer to https://docs.alpaca.markets.