Skip to main content

Orders

The orders API lets you place new orders, modify or cancel an existing order. The APIs will also give margin requirements for single or basket orders. . Various supported order types are as follows

  1. Normal(if order is placed, when market is closed. the order will be places as AMO order)
  2. Cover order having stop loss
  3. Bracket order having target and stoploss
  4. GTT(GTT orders are explained in GTT order section)
  5. 2L
  6. 3L

We can place orders of various types like regular, after market order(AMO), cover and bracket order. We can place order which are longterm and intraday. If orders are placed when markets are closed then orders are sent as AMO order and will be sent to exchange on next available trading session. Various price types like market, limit or stop loss limit or stop loss market orders are supported.

Cover order and bracket order are intraday orders and comes with more than one legs in the order details. Cover order will be having a stop loss leg. Bracket order has stop loss and target leg defined by the user while placing the order. The stop loss for bracket order could trail if trailing stop loss is defined. Once you have taken the positions if the price reaches target or stop loss, the positions is squared-off and the other leg is cancelled.


typeendpointDescription
POST/order/Place New order of various types
PUT/order/:order_idModify order
DELETE/order/:order_idCancel order
POST/order/marginget Order margin for single or basket orders

New order

Place new order

On placing an order, the order goes to OMS and will be successfully sent to the exchange depending on various factors like Margin available in the account, exchange market timings , risk check etc. Once the order reaches OMS, on success a response will receive a field order_id for that particular order.

To know the status of the request, you could subscribe to Websockets endpoint to receive orders and trade updates in real-time.

Request

curl --location --request POST '{BASEURL}/order/create' \
--header 'Content-Type: application/json' \
--header 'access-token: access-token' \
{
"order": {
"exchange_name": 1,
"trading_symbol": "ACC-EQ",
"order_type": 5,
"quantity": 1,
"price": "1700",
"transaction_type": 1,
"price_type": 1,
"validity": 1,
"order_source":4,
"stop_loss_price" : "10.05", //only present in cover or breacket order
"target_price" : "10.30", //only present in bracket order
“meta”: “This is optional extra information”
}
}

Request Parameters

FieldField typeDescription
exchange_nameintegerExchange name. see details
trading_symbolstringtrading symbol of the scrip.
quantityintegerquantity. For F&O segment quantity should be multiple of lot size
disclosed_quantityintegerdisclosed quantity. Only applicable for equity segments and should be atleast 10 percent of quantity
pricestringprice at which order is placed
trigger_pricestringstop loss trigger price
order_typeintegerOrder type. see details
trasaction_typeintegerBuy or Sell. see details
price_typeintegerPrice type. see details
ValidityintegerOrder validity. see details
OrderSourceintegerOrder source. see details

Response

{
"order_id": "2022082210001"
}

Response Parameters

FieldField typeDescription
order_idstringunique order id received from Wealthy

Modify order

Modify Order

Modify a few attributes of an order which is pending or partially traded. If the order is completed or rejected you will not be able to modify the order. Also only certain fields are allowed to be modfied like 1. quantity 2. disclosed quantity in case exchang is NSE or BSE 3. price 4. trigger price if price type is stop loss limit or stop loss market 5. validity 6. price_type

Note: If order is cover order or bracket order, then stop loss price or target price could also be changed

Request

curl --location --request PUT 'https://api.wealthydev.in/broking/api/v0/order/1575813469108703232/' \
--header 'X-USER-TOKEN: {{kambala_token}}' \
--header 'X-USER-ID: INV31' \
--header 'Content-Type: application/json' \
 {
"price_type": 1,
"quantity": 2,
"disclosed_qty": 2,
"price":"530",
"validity": 1,
"order_source": 1
}

Reponse Http response code 200 comes for successful modification else HTTP status code 4XXX or 5XX response comes in case of unsuccessful modification

{}

Cancel/Exit order

Cancel order

If an order is completed or rejected, you will not be able to cancel the order. For bracket or cover order, untill all legs are completed or cancelled/rejected, we could use this API to exit the position taken from bracket or cover order.

Request

curl --location --request DELETE '{BASEURL}/order/22080100000003' \
--header 'access-token: access-token' \
--header 'Content-Type: application/json'
{
"order_type" : 1
}

Request Parameters

FieldField typeDescription
order_typeintegerOrder type. see details

Response On success, the response is the order id of the canceled order. After this the order status for this order is canceled.

{
“Order_id”: “22080100000003”
}

Response Attributes

FieldField typeDescription
order_idstringorder id of the cancelled order

Get orders

Get all orders

The orders in order book contains orders for the present trading day. When you retrieve orders, you get all the orders for the day including open, pending, and executed ones.

Request

curl --location --request GET '{BASEURL}/order' \
--header 'access-token: access-token' \
--header 'Content-Type: application/json'

Response

On success, the response is the list of all the orders for today.

[ 
{
"exchange_order_id": "15",
"is_amo": false,
"status": 3,
"price_precision": "2",
"lot_size": 1,
"tick_size": "0.05",
"price_factor": "1.000000",
"entry_time": "2022-11-22 17:26:05",
"oms_time": "2022-11-22 17:26:05",
"exchange_time": "2022-11-22 17:26:05",
"order_source": 0,
"order_id": "1595023309643190272",
"exchange_name": 1,
"token": "12018",
"trading_symbol": "SUZLON-EQ",
"quantity": 1,
"price": "9.65",
"order_type": 2,
"transaction_type": 1,
"price_type": 1,
"validity": 1,
"disclosed_quantity": 0
},
{
"exchange_order_id": "14",
"is_amo": false,
"status": 3,
"price_precision": "2",
"lot_size": 1,
"tick_size": "0.05",
"price_factor": "1.000000",
"entry_time": "2022-11-22 17:07:18",
"oms_time": "2022-11-22 17:07:18",
"exchange_time": "2022-11-22 17:07:18",
"req_stop_loss_price": "7.00",
"order_source": 0,
"order_id": "1595018579672043520",
"target_price": "20.00",
"stop_loss_price": "7.00",
"exchange_name": 1,
"token": "12018",
"trading_symbol": "SUZLON-EQ",
"quantity": 1,
"price": "8.05",
"order_type": 5,
"transaction_type": 1,
"price_type": 1,
"validity": 1,
"disclosed_quantity": 0
},
{
"is_amo": false,
"reject_reason": "RED:Margin Shortfall:INR 18.47 Available:INR 111.00 for C-INV31 [NORMAL]",
"status": 7,
"price_precision": "2",
"lot_size": 1,
"tick_size": "0.05",
"price_factor": "1.000000",
"entry_time": "2022-11-22 17:06:30",
"oms_time": "2022-11-22 17:06:30",
"order_source": 0,
"order_id": "1595018378576138240",
"target_price": "20.00",
"stop_loss_price": "7.00",
"exchange_name": 1,
"token": "12018",
"trading_symbol": "SUZLON-EQ",
"quantity": 1,
"price": "8.05",
"order_type": 5,
"transaction_type": 1,
"price_type": 1,
"validity": 1,
"disclosed_quantity": 0
}
]

Response Attributes

FieldField typeDescription
exchange_nameintegerExchange name. see details
trading_symbolstringtrading symbol of the scrip.
quantityintegerquantity. For F&O segment quantity should be multiple of lot size
tokenstringtoken number of the instrument
tick_sizestringsize of tick price
lot_sizestringlot size
disclosed_quantityintegerdisclosed quantity. Only applicable for equity segments and should be atleast 10 percent of quantity
pricestringprice at which order is placed
price_precisionstringno of decimal places in price
trigger_pricestringstop loss trigger price
order_typeintegerOrder type. see details
trasaction_typeintegerBuy or Sell. see details
price_typeintegerPrice type. see details
ValidityintegerOrder validity. see details
statusint enumorder status see details
is_amoboolis order AMO order
reject_reasonstringRejection reason
order_idstringunique order identifier
target_pricestringtarget price for bracket order
stop_loss_pricestringstop loss price for cover or bracket order
OrderSourceintegerOrder source. see details
oms_timestringorder update time from OMS
entry_timestringorderr entry time at OMS
price_factorstringprice factor