Trading APIs

Order Request

Purpose

This method allows the customer to place, modify or cancel an order.

Request URL https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/OrderRequest

Request Method POST
Request format: JSON

Request Header Content-Type:application/json

Request Body

Header

Field Name Description Data Type (max length) Validation Sample Value
appName App Name provided at the time of registration String Cannot be empty. APPTRIAL
appVer Developer App Version String Cannot be empty. 1.0
key UserKey generated at the time of registration String Cannot be empty. ue73jHVeEzBswG5ss9ugyrAasdasdyKYxg
osName Channel of order String Cannot be Empty WEB, Android, iOS
requestCode Request Code of the API called String Cannot be Empty 5POrdReq
userId User ID generated at the time of registration String Cannot be empty. asdue73jHVeE
password Password generated at the time of registration String Cannot be empty. 9ugyrAasdasdy

Body

Field Name Description Data Type (max length) Validation Mandatory Sample Value
ClientCode Client code for whom order is being placed. String Cannot be empty. Yes 12345678
OrderFor P- Place (Fresh ), M-Modify, C- Cancel Order String Cannot be empty. Yes P
M
C
Exchange Exchange in which order has been placed. N- NSE, B- BSE, M-MCX Char Cannot be empty. Yes N
B
M
ExchangeType Exchange segment. C-Cash, D-Derivative, U - Currency Char Cannot be empty. Yes C
D
U
Price Rate at which client wants to Buy / Sell the stock.(Price=0 for at market order) Double Cannot be empty. Yes 10200.00
OrderID It is an incremental number for each order after login. Long Cannot be empty. Yes -
OrderType Client want to buy or sell the String Cannot be empty. Yes Buy
MSell
Qty Total quantity client want to buy or sell (In Case Of Derivative Send Market Lot in Qty) Long Cannot be empty. Yes 2
OrderDateTime Local date at which order has been placed. Date Cannot be empty. Yes /Date(1522923287588)/
ScripCode Scrip Code of the requested order. Long Cannot be empty. Yes 22
AtMarket Specifies where the order placed is at market or Limit Order. Send False for Limit Order and True for At Market Order. Boolean Cannot be empty. Yes true
false
RemoteOrderID This will be unique ID for each order created by you. String Cannot be empty. Yes 57129776201804050344475
ExchOrderID This is order reference number generated by exchange for an order. Send 0 for fresh order and for modify cancel send the exchange order id received from exchange. String Cannot be empty. Yes 5
DisQty Quantity exposed in the exchange. Disclosed quantity is never larger than order quantity. Long Cannot be empty. Yes 0
StopLossPrice This will be the trigger price. This will be set when user want to place stop loss order. (For Buy Stop loss, Trigger price should not be greater than Limit Price. And for Sell Stop Loss Order Trigger Price should not be less than Limit Price) Double Cannot be empty. Yes -
IsStopLossOrder This will indicate where client has placed stop loss order. Send True if order placed is stop loss and send False if it is regular order Boolean Cannot be empty. Yes true
false
IOCOrder Send False in case order is not IOC Boolean Cannot be empty. Yes true
false
IsIntraday For Intraday order send this flag as True and for Delivery order send it as False Boolean Cannot be empty. Yes true
false
ValidTillDate Order Validity Date For VTD (GTD in Case of Commodity) Order should not be today’s or earlier date. Date should be in Range of 45 days from next Day Date Cannot be empty. Yes /Date(1522923270611)/
AHPlaced Y-in case order placed after market closed
N-Normal Market time Order
Char Cannot be empty. Yes Y
N
PublicIP Local IP address of the Device used by client to place an order String Cannot be empty. Yes 10.0.2.15
iOrderValidity Enum of OrderValidity OrderValidity Cannot be empty. Yes 0 - Day
4 - EOS
2 - GTC
1- GTD
3 - IOC
6 - FOK
TradedQty Pass the traded qty. For placing fresh order, value should be 0. For modification/cancellation, send the actual traded qty. Incorrect value would lead to order rejection. Long Cannot be empty. Yes 0
OrderRequesterCode Clientcode of customer String Cannot be empty. Yes 12345678
AppSource App source generated at the time of registration Integer Cannot be empty. Yes 5

Response Body

Field Name Description Data Type (Max length)
ClientCode Client code who had placed the order. String
LocalOrderID Local Order Id of an order. UInt16
BrokerOrderID Order ID generated by 5paisa. UInt32
ExchOrderID Order id received from exchange. In case of rejections, these would be null String
Exch Exchange in which order has been placed (N-NSE, B-BSE, M- MCX) Char
ExchType Exchange segment. C-Cash, D-Derivative, U- Currency, X - Char
RMSResponseCode Repsonse code send by RMS (0- Success) Integer
Status Returns the status of the response. Integer
Message Returns the message of the reponse. String
Time Exchange Order time received from exchange. Empty in case of rejected orders DateTime
ScripCode Returns Scrip Code Integer

Sample Request

{
    "head": {
        "appName": "APPTRIAL",
        "appVer": "1.0",
        "key": "ue73jH6AKVXeEASDAAwG5ss9ugyrAyKYxg",
        "osName": "WEB",
        "requestCode: "5POrdReq",
        "userId": "s9RzASDAKCjdL9N",
        "password": "nznS4Fasd11134zXw"
    },
    "body": {
	    "ClientCode": "1234567",
	    "OrderFor": "P",
	    "Exchange": "N",
	    "ExchangeType": "C",
	    "Price": 717.65,
	    "OrderID": 0,
	    "OrderType": "BUY",
	    "Qty": 2,
	    "OrderDateTime": "/Date(1556104184000)/",
	    "ScripCode": 11809,
	    "AtMarket": false,
	    "RemoteOrderID": "57129776201804050344475",
	    "ExchOrderID": 0,
	    "DisQty": 0,
	    "IsStopLossOrder": false,
	    "StopLossPrice": 0,
	    "IsVTD": false,
	    "IOCOrder": false,
	    "IsIntraday": false,
	    "PublicIP": "192.168.88.41",
	    "AHPlaced": "N",
	    "ValidTillDate": "/Date(1556104184000)/",
	    "iOrderValidity": 0,
	    "TradedQty": 0,
	    "OrderRequesterCode": "1234567",
	    "AppSource": 56
    }
}

Sample Response

{
    "body": {
        "BrokerOrderID": 91049576,
        "ClientCode": "1234567",
        "Exch": "7",
        "ExchOrderID": "",
        "ExchType": "6",
        "LocalOrderID": 0,
        "Message": "Order rejected by RMS as margin required is Rs732, while available margin is Rs547.75",
        "RMSResponseCode": -7,
        "ScripCode": 11809,
        "Status": 1,
        "Time": "/Date(1556130600000+0530)/"
    },
    "head": {
        "responseCode": "5POrdReq",
        "status": "0",
        "statusDescription": "Success"
    }
}