You can place a after market order with the placeOrder API. All the parameters that needs to be passed are listed below. An instrument token will be required to place the order, to get the instrument token you can download the given CSV file. To place an amo order, feed the execution_type parameter as ‘amo’.
Endpoint: /api/v1/orders
Method-Type: POST
Header Name Value Description x-authorization-token <your_access_token>Valid JWT token for authentication x-device-type WEBThe device type (e.g., WEB, ANDROID, IOS) Content-Type application/jsonFormat of the request body
Request Packet
{
"exchange": "NSE",
"instrument_token": "14366",
"client_id": "clientId",
"order_type": "LIMIT",
"amo": true,
"price": 13,
"quantity": 1,
"disclosed_quantity": 0,
"validity": "DAY",
"product": "MIS",
"order_side": "BUY",
"device": "WEB",
"user_order_id": 1,
"trigger_price": 0,
"execution_type": "amo"
}
Example cURL Request
curl --location 'https://algo.pocketful.in/api/v1/orders' \
--header 'Content-Type: application/json' \
--header 'x-authorization-token: <your_access_token>' \
--header 'x-device-type: WEB' \
--data '{
"exchange": "NSE",
"instrument_token": "14366",
"client_id": "clientId",
"order_type": "LIMIT",
"amo": true,
"price": 13,
"quantity": 1,
"disclosed_quantity": 0,
"validity": "DAY",
"product": "MIS",
"order_side": "BUY",
"device": "WEB",
"user_order_id": 1,
"trigger_price": 0,
"execution_type": "amo"
}'
Body Params
FieldName Datatype Description exchange StringName of the exchange where the order is being placed. Possible values include NSE, BSE, NFO, MCX. instrument_token StringThe unique ID of the financial instrument. client_id StringThe unique ID of the user placing the order. order_type StringThe type of order being placed. Possible values are LIMIT, SL. amo BooleanIndicates whether the order is an After Market Order (AMO). It can be either TRUE or FALSE. price FloatThe price at which the order should be executed. If order_type is MARKET, the value is 0; otherwise, it’s the limit price. quantity IntegerThe total quantity of the financial instrument to be traded. disclosed_quantity IntegerThe quantity of the order that is hidden from the market. validity StringThe validity of the order. Possible values are DAY (valid until the end of the trading day) or IOC (Immediate or Cancel). product StringThe type of product being traded. Possible values are CNC (Cash and Carry), MIS (Margin Intraday Square off), NRML (Normal). order_side StringIndicates whether it’s a buy or sell order. Possible values are BUY or SELL. device StringThe device from which the order is being placed. Possible values are Web or Mobile. user_order_id IntegerThe unique order ID generated by the user. trigger_price FloatThe specified activation threshold for Stop Loss (SL) orders. execution_type StringThe execution type of the order, which is typically amo for after market orders.
Example Code
response = pocket.placeOrder({
"exchange": "NSE",
"instrument_token": "14366",
"client_id": "clientId",
"order_type": "LIMIT",
"amo": False,
"price": 13,"quantity": 1,
"disclosed_quantity": 0,
"validity": "DAY",
"product": "MIS",
"order_side": "BUY",
"device": "WEB",
"user_order_id": 1,
"trigger_price": 0,
"execution_type": "AMO"
})
Response
{
"data":
{
"oms_order_id": "200018000000003"
},
"message": "Order place successfully",
"status": "success"
}
Key Description oms_order_id The ID assigned to the order in the Order Management System. message A message indicating the result of the order placement. status The status of the operation (success/failure).
Error Responses
In different scenarios, you can get different error responses, the error response will be like the below JSON example.
{
"data": {},
"error_code": 44000,
"message": "`product` is invalid",
"status": "error"
}
Various error codes can be seen depending on the errors encountered within the code. Below are some of the defined error codes.
Error Code Description 44000 In case of any of the parameter like Exchange, order_type, product being invalid 45000 In case of Invalid Price or Quantity. 45010 “Something Went Wrong” message occurs if you have given wrong instrument token