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
- Normal(if order is placed, when market is closed. the order will be places as AMO order)
- Cover order having stop loss
- Bracket order having target and stoploss
- GTT(GTT orders are explained in GTT order section)
- 2L
- 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.
type | endpoint | Description |
---|---|---|
POST | /order/ | Place New order of various types |
PUT | /order/:order_id | Modify order |
DELETE | /order/:order_id | Cancel order |
POST | /order/margin | get 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
Field | Field type | Description |
---|---|---|
exchange_name | integer | Exchange name. see details |
trading_symbol | string | trading symbol of the scrip. |
quantity | integer | quantity. For F&O segment quantity should be multiple of lot size |
disclosed_quantity | integer | disclosed quantity. Only applicable for equity segments and should be atleast 10 percent of quantity |
price | string | price at which order is placed |
trigger_price | string | stop loss trigger price |
order_type | integer | Order type. see details |
trasaction_type | integer | Buy or Sell. see details |
price_type | integer | Price type. see details |
Validity | integer | Order validity. see details |
OrderSource | integer | Order source. see details |
Response
{
"order_id": "2022082210001"
}
Response Parameters
Field | Field type | Description |
---|---|---|
order_id | string | unique 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_typeNote: 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
Field | Field type | Description |
---|---|---|
order_type | integer | Order 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
Field | Field type | Description |
---|---|---|
order_id | string | order 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
Field | Field type | Description |
---|---|---|
exchange_name | integer | Exchange name. see details |
trading_symbol | string | trading symbol of the scrip. |
quantity | integer | quantity. For F&O segment quantity should be multiple of lot size |
token | string | token number of the instrument |
tick_size | string | size of tick price |
lot_size | string | lot size |
disclosed_quantity | integer | disclosed quantity. Only applicable for equity segments and should be atleast 10 percent of quantity |
price | string | price at which order is placed |
price_precision | string | no of decimal places in price |
trigger_price | string | stop loss trigger price |
order_type | integer | Order type. see details |
trasaction_type | integer | Buy or Sell. see details |
price_type | integer | Price type. see details |
Validity | integer | Order validity. see details |
status | int enum | order status see details |
is_amo | bool | is order AMO order |
reject_reason | string | Rejection reason |
order_id | string | unique order identifier |
target_price | string | target price for bracket order |
stop_loss_price | string | stop loss price for cover or bracket order |
OrderSource | integer | Order source. see details |
oms_time | string | order update time from OMS |
entry_time | string | orderr entry time at OMS |
price_factor | string | price factor |