delta-exchange / python-rest-client

https://pypi.org/project/delta-rest-client/
13 stars 19 forks source link

Create bracket order #22

Closed VikasKad closed 4 years ago

VikasKad commented 4 years ago

Any example to create bracket limit order with python?

bbc4468 commented 4 years ago

Currently, Bracket orders are stop market orders which trigger at a certain price. Currently, there is no option to set stop limit order in bracket orders.

The python package doesn't have any explicit function to create bracket orders but you can do it using the base request function. Here is an example

delta_client = DeltaRestClient(....)
bracket_payload = {
  "product_id": 27,                // BTCUSD
  "stop_loss_order": {
    "order_type": "market_order",
    "stop_price": "9500"
  },
  "take_profit_order": {
    "order_type": "market_order",
    "stop_price": "12991"
  }
}

response = delta_client.request("POST", "orders/bracket", bracket_payload, auth=True)
response = response.json()
bbc4468 commented 4 years ago

Here is the documentation for the bracket order endpoint https://docs.delta.exchange/#place-bracket-order