Download OpenAPI specification:
This is the REST API documentation for the Orvix application. You can learn more about API by visiting orvixtech.com/. Please contact in this number +91 9274541010 to obtain API & Secret Key. To test the authorization filters for this sample, you can utilize provided API_key and secret_key.
This API is documented and designed to facilitate algorithmic trading activities. It incorporates standard REST API principles to enable seamless communication between trading applications and the underlying platform. The structure of the API is based on the Orvix sample provided by our team. Additionally, it has been extended to showcase the capabilities of the API tool and leverage Orvix documentation. In addition to adhering to standard REST API syntax, the API also utilizes a few vendor extensions to enhance its functionality.
The API provides detailed information for all available endpoints, including:
The API follows standard REST conventions combined with Orvix-specific vendor extensions to improve performance and enable advanced trading functionality.
| Revised Date | Description |
|---|---|
| 25-04-2025 | Added NetPosition API |
| 05-11-2025 | Added Market Quotes and LTP Quotes in Market Data API |
| 21-11-2025 | Added Cancel All Request API documentation, including request/response structure and usage description. |
| 24-11-2025 | Added Square Up All Request API (positiontype, product, segment, clientcode), response structure, note on pending orders. |
| Language | Version | Required Libraries / Packages |
|---|---|---|
| Python | v3.10.12 | requests (v2.31.0), json, websockets (v12.0), asyncio (v3.4.3), nest_asyncio (v1.6.0), ssl |
| Node.js | v20.11.1 | request (v2.88.2), websockets (v8.16.0) |
| API Name | Description | Limit (Requests/Sec) |
|---|---|---|
| /orders | Get OrderBook / OrderHistory | 1 |
| /orders | Place Order | 10 |
| /orders/cover | Place Cover Order | 10 |
| /orders?AppOrderID | Cancel Order | 10 |
| /orders/cancelall | Cancel All Orders | 10 |
| /portfolio/holdings | Get Holdings | 1 |
| /portfolio/position | Get Net Position | 1 |
| /user/balance | Get Balance | 1 |
| Status_Code | Description | Example Response |
|---|---|---|
| 401 | Invalid AccessToken | {"status": "unsuccessful", "data": {"error": "Invalid AccessToken"}} |
| 410 | Application Not Active | {"status": "unsuccessful", "data": {"error": "Application Not Active"}} |
| 404 | Application Not Found | {"status": "unsuccessful", "data": {"error": "Application Not Found"}} |
| 500 | API Server Not Connected | {"status": "unsuccessful", "data": {"error": "Api Server Not Connected"}} |
| 409 | Invalid API version 4 needed | {"status": "unsuccessful", "data": {"error": "Invalid API version 4 needed"}} |
| 405 | Invalid Method | {"status": "unsuccessful", "data": {"error": "Invalid Method"}} |
| 404 | Wrong Request (Invalid Path) | {"status": "unsuccessful", "data": {"error": "Wrong Request please check path"}} |
| 429 | Msg rate limit exceeded | {"status": "unsuccessful", "data": {"error_text": "Message rate limit has exceeded by it's limit"}} |
| Service | Port | Base URL | Description |
|---|---|---|---|
| Access Web Server | 15207 | https://wss.orvixtech.com:15207 |
REST API |
| WebSocket Feed Server | 15208 | wss://wss.orvixtech.com:15208 |
Real-time data stream |
| Service | Port Variable | Base URL |
|---|---|---|
| Access Web Server | {apiPort} |
https://{clientBaseUrl}:{apiPort} |
| WebSocket Feed Server | {wsPort} |
wss://{clientBaseUrl}:{wsPort} |
Variables
clientBaseUrl: Client host domain clientPort: Client port numberThe Orvix API uses a combination of two authentication methods:
This endpoint is used to authenticate a user by sending the api_key and api_secrets to the Interactive API server.
Upon successful validation, the server generates and returns a request token, which remains valid for 24 hours.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| api_key | string The API application key (e.g., |
| api_secrets | string The secret key for authentication (e.g., |
import requests url = "https://wss.orvixtech.com:15207/connect/login" payload = { "api_key": "API_KEY", "api_secrets": "API_SECRET" } headers = { "Content-Type": "application/x-www-form-urlencoded", "Api-Version": "4" } response = requests.post(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "request_token": "o%sZ|iPUWe7xfUQgBXKX",
- "validity": "20251118-14:44:35"
}
}This endpoint invalidates the user's active session token and terminates the API session.
After logout, the user must log in again to obtain a fresh request token.
Any API calls using an invalidated token will result in authentication errors.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/connect/login" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.delete(url, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "Message": "successfully logged out"
}
}You need to log in every day or whenever you launch the application. The session token lasts for 24 hours or until logout. If the token expires or the user logs out, a new login is required. This ensures secure, continuous access.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/session/token" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "user_type": "3",
- "email": "support@orvixtech.com",
- "user_name": "ORVIX_User",
- "user_shortname": "User",
- "broker": "",
- "exchanges": "",
- "products": [
- "CNC",
- "NRML"
], - "avatar_url": "",
- "user_id": "DAPI1",
- "api_key": "",
- "access_token": "o%sZ|iPUWe7xfUQgBXKX",
- "order_types": [
- "MARKET",
- "LIMIT",
- "SL",
- "SL-M"
], - "login_time": "2024-02-03 13:15:21"
}
}This endpoint retrieves the user's profile details stored by the broker. Users can access their profile at any time.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/user/profile" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "user_id": "DAPI1",
- "user_type": "3",
- "email": "support@orvixtech.com",
- "user_name": "ORVIX_User",
- "user_shortname": "User",
- "broker": "",
- "exchanges": [
- "BSECM",
- "BSECOM",
- "BSEFO",
- "BSEFX",
- "BSEINX",
- "CQG",
- "DGCX",
- "IB",
- "MAXXTRADER",
- "MCX",
- "MCX1",
- "NCDEX",
- "NSECD",
- "NSECM",
- "NSECOM",
- "NSEFO",
- "NSEIFSC",
- "NSESLBM",
- "XT"
], - "products": [
- "CNC",
- "NRML"
], - "order-types": [
- "MARKET",
- "LIMIT",
- "SL",
- "SL-M"
], - "avatar_url": ""
}
}The User Margin endpoint provides detailed information regarding funds, cash, and margin status for the user across both equity and commodity segments. Upon a successful request, the server responds with a JSON object containing various fields, including "status" and "data". The "data" field further encapsulates detailed information related to the user's margin status.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
{- "status": "successful",
- "data": {
- "CM": {
- "enabled": true,
- "net": "186819082.50",
- "available": {
- "adhoc_margin": "0.00",
- "cash": "436819082",
- "collateral": "0.00",
- "intraday_payin": "0"
}, - "utilized": {
- "debits": "249999999.5",
- "exposure": "0.00",
- "m2m_realised": "0",
- "m2m_unrealised": "0.00",
- "option_premium": "0",
- "payout": "0.00",
- "span": "0.00",
- "holding_sales": "0.00",
- "turnover": "0.00"
}
}, - "DEPOSIT": {
- "enabled": true,
- "net": "186819082.50",
- "available": {
- "adhoc_margin": "0.00",
- "cash": "545235633",
- "collateral": "0.00",
- "intraday_payin": "0"
}, - "utilized": {
- "debits": "358416550.5",
- "exposure": "0.00",
- "m2m_realised": "0",
- "m2m_unrealised": "0.00",
- "option_premium": "0",
- "payout": "0.00",
- "span": "0.00",
- "holding_sales": "0.00",
- "turnover": "0.00"
}
}, - "FO": {
- "enabled": true,
- "net": "386819082.50",
- "available": {
- "adhoc_margin": "0.00",
- "cash": "948579472",
- "collateral": "0.00",
- "intraday_payin": "0"
}, - "utilized": {
- "debits": "561760389.5",
- "exposure": "0.00",
- "m2m_realised": "0",
- "m2m_unrealised": "0.00",
- "option_premium": "0",
- "payout": "0.00",
- "span": "0.00",
- "holding_sales": "0.00",
- "turnover": "0.00"
}
}, - "MCX": {
- "enabled": true,
- "net": "385819082.50",
- "available": {
- "adhoc_margin": "0.00",
- "cash": "873027432.00",
- "collateral": "0.00",
- "intraday_payin": "0"
}, - "utilized": {
- "debits": "487208349.5",
- "exposure": "0.00",
- "m2m_realised": "0",
- "m2m_unrealised": "0.00",
- "option_premium": "0",
- "payout": "0.00",
- "span": "0.00",
- "holding_sales": "0.00",
- "turnover": "0.00"
}
}
}
}The order APIs facilitate placing orders of various types and retrieving daily order information. Users can initiate orders on exchanges and execute orders with stop-loss protection.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| tradingsecurity | string Unique Security_ID of the script, e.g., "3045" |
| exchange | string BSECM, BSECOM, BSEFO, BSEINX, BSEFX, CQG, MCX, NSECD, NSECM, NSEFO, NSEIFSC, NSESLBM, DGCX, IB, MAXXTRADER, NCDEX, NSECOM |
| transaction_type | string BUY or SELL |
| order_type | string MARKET, LIMIT, SL, SL-M |
| quantity | string Quantity to trade, e.g., "10" |
| validity | string DAY, IOC, GTT, GTC, OPG, FOK, GTX, GTD, EOS, FAK, ATO, ATC |
| price | string Price of the order, e.g., "830.00" |
| product | string CNC or NRML |
| tag | string Optional alphanumeric tag (max 20 chars) |
| trigger_price | string Trigger price for SL / SL-M orders |
| disclosed_quantity | string Quantity to disclose publicly (Optional) |
| userid | string ClientID (Optional). For manager terminal, pass ClientID here. |
import requests url = "https://wss.orvixtech.com:15207/orders/regular" payload = { "tradingsecurity": "3045", "exchange": "NSECM", "transaction_type": "BUY", "order_type": "LIMIT", "quantity": "10", "validity": "DAY", "price": "830", "product": "CNC" } headers = { "Content-Type": "application/x-www-form-urlencoded", "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.post(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "orderid": "128439"
}
}The Orders Regular SLBM APIs enable users to place and manage orders within the Stock Lending and Borrowing Market (SLBM).
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| tradingsecurity | string Unique Security_ID of the script, e.g., "150013" |
| exchange | string NSESLBM |
| transaction_type | string BUY / SELL |
| order_type | string MARKET, LIMIT |
| quantity | string Example: 10 |
| validity | string DAY, IOC |
| price | string Example: 800.00 |
| product | string CNC, NRML |
| open_close | string BUY => Borrow/Recall, SELL => Lend/Repay |
| userid | string ClientID: User id of the user provided by Orvix (Optional). ManagerID: If manager terminal, ClientID is sent here. |
import requests url = "https://wss.orvixtech.com:15207/orders/regular" payload = { "tradingsecurity": "150013", "exchange": "NSESLBM", "transaction_type": "SELL", "order_type": "LIMIT", "quantity": "8", "validity": "DAY", "price": "800", "product": "NRML", "open_close": "Lend", "userid": "DAPI1" } headers = { "Content-Type": "application/x-www-form-urlencoded", "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.post(url, data=payload, headers=headers) data = response.json() print(data)
{- "status": "successful",
- "data": {
- "orderid": "17801"
}
}This will provide order status of all the placed trades.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/orders" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, headers=headers) data = response.json() print(data)
{- "status": "successful",
- "data": [
- {
- "order_id": "2918",
- "parent_order_id": "2918",
- "exchange_order_id": "O30452918",
- "placed_by": "DAPI1",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "transaction_type": "Sell",
- "order_type": "MARKET",
- "status": "Execute",
- "product": "CNC",
- "validity": "DAY",
- "price": "830.000000",
- "userid": "DAPI1",
- "quantity": "10",
- "trigger_price": "829.0000",
- "average_price": "747.700000",
- "pending_quantity": "0",
- "filled_quantity": "10",
- "disclosed_quantity": "0",
- "market_protection": "0.00",
- "order_timestamp": "23/03/202415:01:11",
- "exchange_timestamp": "23/03/202420:31:11",
- "status_message": "",
- "tag": "ReferenceTag"
}, - {
- "order_id": "2919",
- "parent_order_id": "2919",
- "exchange_order_id": "O30452919",
- "placed_by": "DAPI1",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "transaction_type": "Sell",
- "order_type": "MARKET",
- "status": "Execute",
- "product": "CNC",
- "validity": "DAY",
- "price": "830.000000",
- "userid": "DAPI1",
- "quantity": "10",
- "trigger_price": "0.000000",
- "average_price": "747.400000",
- "pending_quantity": "0",
- "filled_quantity": "10",
- "disclosed_quantity": "0",
- "market_protection": "0.00",
- "order_timestamp": "23/03/202415:01:19",
- "exchange_timestamp": "23/03/202420:31:19",
- "status_message": "",
- "tag": "Orvix"
}, - {
- "order_id": "2920",
- "parent_order_id": "2920",
- "exchange_order_id": "O30452920",
- "placed_by": "DAPI1",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "transaction_type": "Sell",
- "order_type": "MARKET",
- "status": "Execute",
- "product": "NRML",
- "validity": "DAY",
- "price": "830.000000",
- "userid": "DAPI1",
- "quantity": "10",
- "trigger_price": "829.000000",
- "average_price": "748.050000",
- "pending_quantity": "0",
- "filled_quantity": "10",
- "disclosed_quantity": "0",
- "market_protection": "0.00",
- "order_timestamp": "23/03/202415:02:24",
- "exchange_timestamp": "23/03/202420:32:24",
- "status_message": "",
- "tag": "ReferenceTag"
}
]
}Retrieve the status of a placed trade using the OrderID.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/orders/2920" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, headers=headers) data = response.json() print(data)
{- "status": "Successful",
- "data": [
- {
- "order_id": "2920",
- "parent_order_id": "2920",
- "exchange_order_id": "O30452920",
- "placed_by": "DAPI1",
- "status": "Execute",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "transaction_type": "Sell",
- "order_type": "MARKET",
- "product": "NRML",
- "validity": "DAY",
- "price": "829.000000",
- "userid": "DAPI1",
- "quantity": "10",
- "trigger_price": "0.000000",
- "average_price": "0.00",
- "pending_quantity": "0",
- "filled_quantity": "10",
- "disclosed_quantity": "0",
- "market_protection": "0.00",
- "order_timestamp": "23/03/2024 15:02:24",
- "exchange_timestamp": "23/03/2024 20:32:24",
- "status_message": "",
- "tag": "ReferenceTag"
}
]
}Retrieve the status of a placed trade using the Tag (Reference) and OrderID.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/orders/ReferenceTag/2920" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, headers=headers) data = response.json() print(data)
{- "status": "Successful",
- "data": [
- {
- "order_id": "2920",
- "parent_order_id": "2920",
- "exchange_order_id": "O30452920",
- "placed_by": "DAPI1",
- "status": "Execute",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "transaction_type": "Sell",
- "order_type": "MARKET",
- "product": "NRML",
- "validity": "DAY",
- "price": "829.000000",
- "userid": "DAPI1",
- "quantity": "10",
- "trigger_price": "0.000000",
- "average_price": "0.00",
- "pending_quantity": "0",
- "filled_quantity": "10",
- "disclosed_quantity": "0",
- "market_protection": "0.00",
- "order_timestamp": "23/03/2024 15:02:24",
- "exchange_timestamp": "23/03/2024 20:32:24",
- "status_message": "",
- "tag": "ReferenceTag"
}
]
}Modify your open orders by changing order type (MARKET, LIMIT, SL, SL-M), price, quantity, disclosed quantity, or stop-loss.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| order_type | string Type of order (MARKET, LIMIT, SL, SL-M) |
| quantity | string Number of units to buy or sell |
| price | string Price at which the user wants to place the order |
| validity | string Order validity (DAY, IOC, GTT, GTC, OPG, FOK, GTX, GTD, EOS, FAK, ATO, ATC) |
| trigger_price | string Price at which order should be triggered (for SL, SL-M) |
| disclosed_quantity | string Quantity to disclose publicly (for equities, optional) |
| userid | string User ID provided by Orvix (optional) |
import requests url = "https://wss.orvixtech.com:15207/orders/regular/128439" payload = { "order_type": "MARKET", "quantity": "5", "validity": "DAY", "price": "830" } headers = { "Content-Type": "application/x-www-form-urlencoded", "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.put(url, data=payload, headers=headers) data = response.json() print(data)
{- "status": "successful",
- "data": {
- "orderid": "128439"
}
}This endpoint is used to update a regular order by its ID. It sends a PUT request to update the price or type of a regular order.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| order_type | string MARKET, LIMIT, SL, SL-M |
import requests url = "https://wss.orvixtech.com:15207/orders/regular/128439" payload = { 'order_type': 'MARKET' } headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN' } response = requests.request("PUT", url, headers=headers, data=payload) print(response.text)
{- "status": "successful",
- "data": {
- "orderid": "128439"
}
}This API can be called to cancel any open order of the user by providing the correct appOrderID matching with the chosen open order to cancel.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/orders/regular/128439" payload = {} headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN' } response = requests.request("DELETE", url, headers=headers, data=payload) print(response.text)
{- "status": "successful",
- "data": {
- "order_id": "194719"
}
}This API cancels all open orders for the authenticated user. The request does not require any specific order identifiers. Once invoked, the system automatically detects and cancels every order that is currently in an open state for the user.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/orders/cancelall" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.delete(url, headers=headers) print(response.text)
{- "status": "successful",
- "data": [
- {
- "order_id": "194719"
}
]
}When any order gets executed, a new trade event is generated by the server. Clients can listen to these events by registering to receive them.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/trades" headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN' } response = requests.get(url, headers=headers) print(response.text)
{- "status": "successful",
- "data": [
- {
- "trade_id": "1740",
- "order_id": "22",
- "exchange": "NSECM",
- "tradingsymbol": "SBIN",
- "instrument_token": "3045",
- "product": "CNC",
- "average_price": "747.70000000000005",
- "quantity": "10",
- "tag": "ReferenceTag",
- "placed_by": "DAPI1",
- "userid": "DAPI1",
- "transaction_type": "SELL",
- "exchange_order_id": "O30452918",
- "fill_timestamp": "23/03/202420:31:11",
- "order_timestamp": "15:01:11",
- "exchange_timestamp": "23/03/202420:31:11"
}, - {
- "trade_id": "1741",
- "order_id": "23",
- "exchange": "NSECM",
- "tradingsymbol": "SBIN",
- "instrument_token": "3045",
- "product": "CNC",
- "average_price": "747.39999999999998",
- "quantity": "10",
- "tag": "ReferenceTag",
- "placed_by": "DAPI1",
- "userid": "DAPI1",
- "transaction_type": "SELL",
- "exchange_order_id": "O30452919",
- "fill_timestamp": "23/03/202420:31:19",
- "order_timestamp": "15:01:19",
- "exchange_timestamp": "23/03/202420:31:19"
}, - {
- "trade_id": "1742",
- "order_id": "24",
- "exchange": "NSECM",
- "tradingsymbol": "SBIN",
- "instrument_token": "3045",
- "product": "NRML",
- "average_price": "748.04999999999995",
- "quantity": "10",
- "tag": "ReferenceTag",
- "placed_by": "DAPI1",
- "userid": "DAPI1",
- "transaction_type": "SELL",
- "exchange_order_id": "O30452920",
- "fill_timestamp": "23/03/202420:32:24",
- "order_timestamp": "15:02:24",
- "exchange_timestamp": "23/03/202420:32:24"
}
]
}Fetch executed trade details for a specific order using its OrderID.
| OrderID required | string Unique order ID |
| Api-Version required | string Default: 4 API version for this endpoint. Must be 4. |
import requests url = "https://wss.orvixtech.com:15207/trades/2920" headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN' } response = requests.get(url, headers=headers) print(response.text)
{- "status": "successful",
- "data": [
- {
- "trade_id": "1742",
- "order_id": "24",
- "exchange_order_id": "O30452920",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "product": "NRML",
- "average_price": "748.05",
- "quantity": "10",
- "placed_by": "DAPI1",
- "userid": "DAPI1",
- "transaction_type": "SELL",
- "tag": "ReferenceTag",
- "fill_timestamp": "23/03/2024 20:32:24",
- "exchange_timestamp": "23/03/2024 20:32:24"
}
]
}Retrieve executed trade details using a reference tag and OrderID.
| Reference required | string Reference tag associated with the order |
| orderID required | string Unique order ID |
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/trades/ReferenceTag/2920" headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN' } response = requests.get(url, headers=headers) print(response.text)
{- "status": "Successful",
- "data": [
- {
- "trade_id": "1742",
- "order_id": "24",
- "exchange_order_id": "O30452920",
- "tradingsymbol": "SBIN",
- "exchange": "NSECM",
- "instrument_token": "3045",
- "product": "NRML",
- "average_price": "748.04999999999995",
- "quantity": "10",
- "placed_by": "DAPI1",
- "userid": "DAPI1",
- "transaction_type": "SELL",
- "tag": "ReferenceTag",
- "fill_timestamp": "23/03/2024 20:32:24",
- "exchange_timestamp": "23/03/2024 20:32:24"
}
]
}The Instruments API provides a single, consolidated CSV list of tradable assets from various exchanges and segments.
Retrieving the full instrument list
Unlike other APIs that return JSON, this API returns a gzipped CSV dump containing instruments across all exchanges.
The dump is generated once per day, therefore the last_price field is not real-time.
Response Structure (Sample Rows)
| security_id | security_id. | symbol | security_description | previous_close | expiry_date | strike_price | tick_size | quantity | option_type | instrument_type | exchange | face_value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2000259 | 2000259 | TRENT | TRENT24FEB3640PE | 128.75 | 29FEB2024 | 3640.00 | 0.05 | 400.00 | PE | OPTSTK | BSEFO | 1.00 |
| 2000259 | 2000259 | TRENT | TRENT24FEB3620CE | 132.50 | 29FEB2024 | 3620.00 | 0.05 | 300.00 | CE | OPTSTK | BSEFO | 1.00 |
| 2000260 | 2000259 | INFY | INFY24FEB2000CE | 45.80 | 29FEB2024 | 2000.00 | 0.05 | 500.00 | CE | OPTSTK | NSEFO | 5.00 |
| 2000260 | 2000259 | INFY | INFY24FEB2100PE | 50.00 | 29FEB2024 | 2100.00 | 0.05 | 700.00 | PE | OPTSTK | NSEFO | 5.00 |
| 2000261 | 2000259 | RELIANCE | REL24FEB2500PE | 73.20 | 29FEB2024 | 2500.00 | 0.05 | 200.00 | PE | OPTSTK | NSEFO | 10.00 |
Note:
The actual CSV is very large; the above is only a snippet.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests import csv url = "https://wss.orvixtech.com:15207/instruments" headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.get(url, headers=headers, verify=False) if response.status_code == 200: content = response.content.decode('utf-8') csv_data = [line.split(',') for line in content.split('\n') if line.strip()] with open('response_data.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerows(csv_data) print("Data has been written to response_data.csv successfully.") else: print(f"Error: {response.status_code}")
This endpoint allows the user to retrieve all available expiry dates of a contract using the symbol and exchange.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| symbol | string Symbol of the instrument (e.g., "NIFTY") |
| exchange | string Exchange of the instrument (e.g., "NSEFO") |
import requests url = "https://wss.orvixtech.com:15207/expirydate" payload = { "symbol": "NIFTY", "exchange": "NSEFO" } headers = { "Api-Version": "4", "Content-Type": "application/x-www-form-urlencoded", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, params=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "exchange": "NSEFO",
- "symbol": "NIFTY",
- "expiry": "06JUN2024,09MAY2024,16MAY2024,23MAY2024,24DEC2025,24JUN2027,25JUL2024,25JUN2026"
}
}The NetPosition API provides the user's current positions.
Fetches user net positions.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| positiontype | string Type of position to fetch:
|
import requests url = "https://wss.orvixtech.com:15207/netposition" payload = 'positiontype=expiry' headers = { 'Api-Version': '4', 'Authorization': 'API_KEY:REQUEST_TOKEN', 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.post(url, headers=headers, data=payload) print(response.text)
{- "data": [
- {
- "buy_amount": "142505",
- "buy_qty": "100",
- "buy_avg": "1425",
- "sell_amount": "0",
- "sell_qty": "19527824",
- "sell_avg": "0",
- "net_amount": "-142505",
- "net_qty": "-19527724",
- "net_avg": "0",
- "multiplier": "1",
- "client_id": "",
- "exchange": "NSECM",
- "security_id": "1594",
- "script_id": "1594",
- "symbol": "INFY",
- "security_type": "EQUITY",
- "expiry_date": "EQ",
- "option_type": "",
- "strike_price": "0.0000",
- "tradingsecurity": "INFY-EQ",
- "user_id": "ATAPI",
- "member_id": "",
- "manager_id": "",
- "product": "CNC",
- "open_close": "NONE",
- "ref_text": "",
- "strategy_name": "",
- "trading_unit_factor": "1.0",
- "ticksize": "0.05",
- "ltp": "1500.00",
- "pnl": "100.00",
- "bid_pnl": "50.00",
- "ask_pnl": "50.00",
- "realised": "100.00",
- "unrealised": "0.00",
- "positiontype": "expiry"
}, - {
- "buy_amount": "142505",
- "buy_qty": "100",
- "buy_avg": "1425",
- "sell_amount": "0",
- "sell_qty": "19527824",
- "sell_avg": "0",
- "net_amount": "-142505",
- "net_qty": "-19527724",
- "net_avg": "0",
- "multiplier": "1",
- "client_id": "",
- "exchange": "NSECM",
- "security_id": "1594",
- "script_id": "1594",
- "symbol": "INFY",
- "security_type": "EQUITY",
- "expiry_date": "EQ",
- "option_type": "",
- "strike_price": "0.0000",
- "tradingsecurity": "INFY-EQ",
- "user_id": "ATAPI",
- "member_id": "",
- "manager_id": "",
- "product": "CNC",
- "open_close": "NONE",
- "ref_text": "",
- "strategy_name": "",
- "trading_unit_factor": "1.0",
- "ticksize": "0.05",
- "ltp": "1500.00",
- "pnl": "100.00",
- "bid_pnl": "50.00",
- "ask_pnl": "50.00",
- "realised": "100.00",
- "unrealised": "0.00",
- "positiontype": "expiry"
}, - {
- "buy_amount": "142505",
- "buy_qty": "100",
- "buy_avg": "1425",
- "sell_amount": "0",
- "sell_qty": "19527824",
- "sell_avg": "0",
- "net_amount": "-142505",
- "net_qty": "-19527724",
- "net_avg": "0",
- "multiplier": "1",
- "client_id": "",
- "exchange": "NSECM",
- "security_id": "1594",
- "script_id": "1594",
- "symbol": "INFY",
- "security_type": "EQUITY",
- "expiry_date": "EQ",
- "option_type": "",
- "strike_price": "0.0000",
- "tradingsecurity": "INFY-EQ",
- "user_id": "ATAPI",
- "member_id": "",
- "manager_id": "",
- "product": "CNC",
- "open_close": "NONE",
- "ref_text": "",
- "strategy_name": "",
- "trading_unit_factor": "1.0",
- "ticksize": "0.05",
- "ltp": "1500.00",
- "pnl": "100.00",
- "bid_pnl": "50.00",
- "ask_pnl": "50.00",
- "realised": "100.00",
- "unrealised": "0.00",
- "positiontype": "expiry"
}
]
}The Square Up All API allows you to square off your positions for a specific client.
You can execute square-up based on the following parameters:
positiontype:
expiry / blank("") → Square-up positions based on expiry daily → Square-up only daily positionsproduct:
blank("") → all productsNRML → Normal trading product CNC → Cash-and-carry productsegment:
blank("") → all segmentsNSECM, NSEFO, BSECM, MCX → The exchange segment for the positionsclientcode:
blank("") → all mapped clientcode wiseNote: Before executing a square-up-all request, it is mandatory to cancel all orders request.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| positiontype | string Type of position to fetch:
|
| product | string Type of product for trading. Options:
|
| segment | string Exchange segment to fetch positions from. Options:
|
| clientcode | string Client code for which the square-up request should be executed.
|
import requests url = "https://wss.orvixtech.com:15207/squareupall" payload = "positiontype=daily&product=NRML&segment=NSECM&clientcode=DAI1" headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN", "Content-Type": "application/x-www-form-urlencoded" } response = requests.post(url, headers=headers, data=payload) print(response.text)
{- "status": "successful",
- "data": {
- "NetPos_Count": "3",
- "Message": "NetPos_request_send_successfully"
}
}This endpoint allows users to fetch the InstrumentID (also known as SecurityID or TradingSecurity) of an index instrument using the symbol, exchange, and instrument type.
| symbol required | string Example: symbol=NIFTY Symbol of the instrument (e.g., "NIFTY") |
| exchange required | string Example: exchange=NSECM Exchange of the instrument (e.g., "NSECM") |
| instrument_type required | string Example: instrument_type=INDEX Instrument type (e.g., "INDEX") |
| Api-Version required | string Default: 4 API version (must be 4 for this request) |
import requests url = "https://wss.orvixtech.com:15207/instrumentid" payload = { "symbol": "NIFTY", "exchange": "NSECM", "instrument_type": "INDEX" } headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, params=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "exchange": "NSECM",
- "symbol": "Nifty 50",
- "expiry_date": "",
- "strike_price": "21000.00",
- "instrument_type": "INDEX",
- "instrument_id": "Nifty 50"
}
}Retrieve the InstrumentID for a specific Equity.
The InstrumentID is also known as the SecurityID or TradingSecurity.
Notes:
expiry_date = "EQ"expiry_date = "A"| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| symbol | string Symbol of the instrument (e.g., "TCS") |
| expiry_date | string Expiry date of the instrument.
|
| exchange | string Exchange of the instrument (e.g., "NSECM") |
| instrument_type | string Instrument type (e.g., "EQUITY") |
import requests url = "https://wss.orvixtech.com:15207/instrumentid" payload = { "symbol": "TCS", "expiry_date": "EQ", "exchange": "NSECM", "instrument_type": "EQUITY", } headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "exchange": "NSECM",
- "symbol": "TCS",
- "expiry_date": "EQ",
- "instrument_type": "EQUITY",
- "instrument_id": "11536"
}
}Retrieve the InstrumentID for an Option instrument. This is also known as the SecurityID or TradingSecurity.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| symbol | string Symbol of the instrument (e.g., "NIFTY") |
| expiry_date | string Expiry date of the contract (e.g., "16MAY2024") |
| strike_price | string Strike price of the option (e.g., "21000") |
| option_type | string Option type (e.g., "CE" or "PE") |
| exchange | string Exchange of the instrument (e.g., "NSEFO") |
| instrument_type | string Instrument type (e.g., "OPT", "OPTIDX") |
import requests url = "https://wss.orvixtech.com:15207/instrumentid" payload = { "symbol": "NIFTY", "expiry_date": "16MAY2024", "strike_price": "21000", "option_type": "PE", "exchange": "NSEFO", "instrument_type": "OPT", } headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "symbol": "NIFTY",
- "expiry_date": "16MAY2024",
- "strike_price": "21000",
- "option_type": "PE",
- "exchange": "NSEFO",
- "instrument_type": "OPT",
- "instrument_id": "35007"
}
}Retrieve the InstrumentID for a Future contract. This is also known as the SecurityID or TradingSecurity.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| symbol | string Symbol of the instrument (e.g., "NIFTY") |
| expiry_date | string Expiry date of the contract (e.g., "25JUL2024") |
| exchange | string Exchange of the instrument (e.g., "NSEFO") |
| instrument_type | string Instrument type (e.g., "FUT", "FUTIDX") |
import requests url = "https://wss.orvixtech.com:15207/instrumentid" payload = { "symbol": "NIFTY", "expiry_date": "25JUL2024", "exchange": "NSEFO", "instrument_type": "FUT", } headers = { "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.get(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "exchange": "NSEFO",
- "symbol": "NIFTY",
- "expiry_date": "25JUL2024",
- "instrument_type": "FUTIDX",
- "instrument_id": "35007"
}
}Place an Auction Order for stocks currently available in auction. Only stocks present in the user's demat account will appear in auction lists.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
| tradingsecurity | string Unique Security_ID of the script (e.g., "220") |
| exchange | string Exchange name (e.g., "NSECM") |
| transaction_type | string Transaction type (SELL) |
| order_type | string Order type (AUCTION) |
| quantity | string Order quantity |
| validity | string Order validity (e.g., DAY) |
| price | string Order price |
| product | string Product type (e.g., CNC, NRML) |
| userid | string ClientID: User ID provided by Orvix (optional). ManagerID: If manager terminal, ClientID must be sent in this parameter. |
| tag | string Optional tag to identify the order (max 20 chars) |
| auction_number | string Auction number assigned to the stock |
import requests url = "https://wss.orvixtech.com:15207/auctionorder" payload = { "tradingsecurity": "220", "exchange": "NSECM", "transaction_type": "SELL", "order_type": "AUCTION", "quantity": "10", "validity": "DAY", "price": "830", "product": "CNC", "userid": "DAPI1", "tag": "ReferenceTag", "auction_number": "2044" } headers = { "Content-Type": "application/x-www-form-urlencoded", "Api-Version": "4", "Authorization": "API_KEY:REQUEST_TOKEN" } response = requests.post(url, data=payload, headers=headers) print(response.json())
{- "status": "successful",
- "data": {
- "orderid": "1378"
}
}The Auction Orders API provides a daily gzipped CSV file of auction orders from exchanges.
Response CSV Columns:
| SecurityID | Symbol | AuctionNo | AuctionStatus | InitiatorType | TotalBuyQty | BuyAmount | TotalSellQty | SellAmount | AuctionQty | AuctionPrice | SettlementPeriod | DateTime |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4668 | BANKBARODA | 15 | OPEN_SOLICITOR_PERIOD | 0 | 1 | 0.00 | 4 | 265.00 | 0 | 0.00 | 1 | 15:47:03 |
| 383 | BEL | 16 | OPEN_SOLICITOR_PERIOD | 0 | 1 | 0.00 | 3 | 228.00 | 0 | 0.00 | 1 | 08:52:33 |
| 21113 | BFINVEST | 17 | OPEN_SOLICITOR_PERIOD | 0 | 1 | 0.00 | 2 | 591.00 | 0 | 0.00 | 1 | 08:54:18 |
| 4749 | CONCOR | 30 | OPEN_SOLICITOR_PERIOD | 0 | 1 | 0.00 | 1 | 1049.00 | 0 | 0.00 | 1 | 15:46:45 |
| 422 | BHARATFORG | 19 | OPEN_SOLICITOR_PERIOD | 0 | 1 | 0.00 | 1500 | 1433.85 | 0 | 0.00 | 1 | 08:53:52 |
Note: The CSV file is large; above is just a snippet.
| Api-Version required | string Default: 4 Keep API Version set to 4 for all API calls. |
import requests url = "https://wss.orvixtech.com:15207/auctions" headers = { 'Api-Version': '4' } response = requests.get(url, headers=headers) print(response.text)
{- "status": "string",
- "error": "INVALID_REQUEST"
}import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15207') as websocket:
sc = '{"Message":"Login","API_KEY":"QnO9<!*v>RhT|yGv.eZ1KTMxJ","REQUEST_TOKEN":"7xO9zEyrBId3N*<|!Vxq"}'
await websocket.send(sc)
while True:
response = await websocket.recv()
print( response )
return
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connectToServer() {
const ws = new WebSocket('wss://wss.orvixtech.com:15207');
ws.on('open', function open() {
const sc = '{"Message":"Login","API_KEY":"QnO9<!*v>RhT|yGv.eZ1KTMxJ","REQUEST_TOKEN":"7xO9zEyrBId3N*<|!Vxq"}';
ws.send(sc);
});
ws.on('message', function incoming(data) {
console.log(data);
});
}
connectToServer();
When the websocket connection is established and the user is Successfuly logged in, a "success" response will be received. The connection will then remain open, awaiting further updates from the server, such as when a new order is placed.
{
"Message": "LoginResponse",
"Status": "success"
}
When an order is placed via API or through ORVIX (outside of the websocket), this will provide the following response:
{
"Message": "Order",
"status": "Successful",
"data": {
"order_id": "23",
"parent_order_id": "6746",
"exchange_order_id": "",
"placed_by": "DAPI1",
"tradingsymbol": "RELIANCE",
"exchange": "NSECM",
"instrument_token": "2885",
"transaction_type": "Buy",
"order_type": "MARKET",
"status": "Unknown",
"product": "CNC",
"validity": "DAY",
"price": "0.00",
"userid": "DAPI1",
"quantity": "100",
"trigger_price": "0.00",
"pending_quantity": "100",
"filled_quantity": "0",
"disclosed_quantity": "0",
"order_timestamp": "02\/03\/2024 18:58:09",
"exchange_timestamp": "01\/01\/1970 05:30:00",
"status_message": "",
"tag": "HELLOMOTO2"
}
}
Order structure:
Response 2 -
When an trade happens in a order placed via API or through ORVIX, this will provide the following Trade response:
{
"Message": "Trade",
"status": "Successful",
"data": {
"trade_id": "12440",
"order_id": "6746",
"exchange_trade_id": "T28856746975208",
"exchange_order_id": "O28856746",
"Exchange": "NSECM",
"tradingsymbol": "RELIANCE",
"instrument_token": "2885",
"tag": "HELLOMOTO2",
"product": "CNC",
"average_price": "2939.50",
"price": "2939.50",
"quantity": "100",
"pending_quantity": "0",
"transaction_type": "BUY",
"fill_timestamp": "2024-03-03 00:28:09",
"order_timestamp": "00:28:09",
"exchange_timestamp": "2024-03-03 00:28:09"
}
}
Trade Response structure:
This API retrieves historical market data (OHLCV) for a specified security within a given date and time range.
You must provide the exchange, security identifier, resolution (interval), and the start–end timestamps.
The API supports multiple resolutions:
The returned data typically includes:
Useful for charting, analysis, and back-testing strategies.
| EXC | string Represents the exchange where the security is traded (e.g., "NSECM", "NSEFO"). |
| SECID | string Unique security identifier for which historical data is requested (e.g., "2885"). |
| FROM | string The start timestamp or date (epoch format) from where historical data should be fetched. |
| TO | string The end timestamp or date (epoch format) up to where historical data should be fetched. |
| RESOLUTION | string Defines the interval of historical data:
|
import requests url = "https://wss.orvixtech.com:15208/ticks?EXC=NSECM&SECID=2885&FROM=1719998100&TO=1720020600&RESOLUTION=15" response = requests.request("GET", url) print(response.text)
{- "Response": "Success",
- "FROM": "1719809100",
- "TO": "1719914400",
- "data": [
- {
- "0": [
- "1719809100",
- "2897.00",
- "2898.95",
- "2895.00",
- "2895.55",
- "715000",
- "65000"
], - "1": [
- "1719810000",
- "2896.30",
- "2898.80",
- "2893.55",
- "2896.35",
- "970000",
- "65000"
], - "2": [
- "1719810900",
- "2896.00",
- "2898.95",
- "2893.55",
- "2896.30",
- "971000",
- "65000"
], - "3": [
- "1719811800",
- "2895.80",
- "2898.95",
- "2893.55",
- "2896.00",
- "969000",
- "63000"
], - "4": [
- "1719812700",
- "2894.20",
- "2898.95",
- "2893.55",
- "2895.35",
- "971000",
- "65000"
]
}
]
}This endpoint retrieves real-time market quote information for a specified security.
By providing the exchange code (EXC) and security identifier (SECID), the API returns
the latest available market data, such as last traded price (LTP), bid/ask details,
volume, and other key parameters used for live market analysis.
| EXC | string Represents the exchange where the security is traded (e.g., "NSECM"). |
| SECID | string Represents the security identifier (e.g., "3045" ). |
import requests url = "https://wss.orvixtech.com:15208/quote?EXC=NSECM&SECID=3045" response = requests.request("GET", url) print(response.text)
{- "status": "successful",
- "data": {
- "EXC": "NSECM",
- "SECID": "3045",
- "BT": "1760691163",
- "B": [
- {
- "P": "889.45",
- "Q": "558",
- "C": "3"
}, - {
- "P": "889.40",
- "Q": "596",
- "C": "4"
}, - {
- "P": "889.35",
- "Q": "574",
- "C": "4"
}, - {
- "P": "889.30",
- "Q": "368",
- "C": "6"
}, - {
- "P": "889.25",
- "Q": "87",
- "C": "1"
}
], - "A": [
- {
- "P": "889.85",
- "Q": "91",
- "C": "3"
}, - {
- "P": "889.90",
- "Q": "835",
- "C": "5"
}, - {
- "P": "889.95",
- "Q": "2249",
- "C": "12"
}, - {
- "P": "890.00",
- "Q": "14511",
- "C": "63"
}, - {
- "P": "890.05",
- "Q": "339",
- "C": "5"
}
], - "TQT": "6608378",
- "LTP": "889.80",
- "LTQ": "50",
- "LTT": "1760691162",
- "VWAP": "888.60",
- "TBQTY": "423661",
- "TSQTY": "1109882",
- "O": "887.50",
- "H": "894.75",
- "L": "883.00",
- "C": "886.95",
- "OI": "0",
- "LL": "680.00",
- "LH": "953.40",
- "TV": "58722.05",
- "DPR": "854.75-1044.65"
}
}This API returns the Last Traded Price (LTP) of a security in real time.
Users must provide the exchange (EXC) and security identifier (SECID),
and the API responds with the most recent traded price along with basic
symbol information.
This endpoint is ideal for use cases requiring quick LTP refreshes
without full market depth or quote details.
| EXC | string Represents the exchange where the security is traded (e.g., "NSECM"). |
| SECID | string Represents the security identifier (e.g., "3045" ). |
import requests url = "https://wss.orvixtech.com:15208/quote/ltp?EXC=NSECM&SECID=3045" response = requests.request("GET", url) print(response.text)
{- "status": "successful",
- "data": {
- "EXC": "NSECM",
- "SECID": "3045",
- "LTP": "890.30",
- "LTQ": "2",
- "LTT": "1760691330"
}
}The WebSocket API is the most efficient (speed, latency, resource consumption, and bandwidth) way to receive quotes for instruments across all exchanges during live market hours. A quote consists of fields such as open, high, low, close, last traded price, 5 levels of bid/offer market depth data etc.
To achieve the equivalent WebSocket connection, you can use the websockets library. Here's how you can do it:
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
print("WebSocket connection successful!")
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connectToServer() {
const websocket = new WebSocket('wss://wss.orvixtech.com:15208');
websocket.on('message', function(message) {
if (message.includes('HandShake')) {
console.log('WebSocket connection successful!');
} else {
console.log('WebSocket connection failed');
}
websocket.close();
});
}
connectToServer();
It awaits a message (response) from the server using websocket.recv(). If the received message contains the substring "HandShake", it prints "WebSocket connection successful!" indicating that the handshake process was successful. If the message does not contain "HandShake", it prints "WebSocket connection failed".
The script establishes a WebSocket connection to a server, sends a "Broadcast" message upon receiving a handshake, and processes and prints the received broadcast messages containing market data.
{
"Message": "Broadcast",
"EXC": "NSECM",
"SECID": "3045"
}
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = '{"Message":"Broadcast","EXC":"NSECM","SECID":"3045"}'
await websocket.send(sc)
response = await websocket.recv()
if '"Broadcast"' in response:
print(response)
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connect() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', () => ws.send('{"Message":"Broadcast","EXC":"NSECM","SECID":"3045"}'));
ws.on('message', data => {
if (data instanceof Buffer) {
// Convert binary buffer to string
data = data.toString('utf-8');
}
console.log(data.includes('"Broadcast"') ? data : 'WebSocket connection failed');
});
}
connect();
Upon receiving a response to this broadcast message, it checks if the response contains "Broadcast". If so, it prints the entire response.
The broadcast response itself is a JSON object containing various fields related to market data. It can further be parsed according to the need and requirement.
{
"Message": "Broadcast",
"EXC": "NSECM",
"SECID": "3045",
"BT": "1709113203",
"B": [
{
"P": "743.45",
"Q": "91",
"C": "4"
},
{
"P": "743.40",
"Q": "2453",
"C": "8"
},
{
"P": "743.35",
"Q": "26",
"C": "3"
},
{
"P": "743.30",
"Q": "2327",
"C": "16"
},
{
"P": "743.25",
"Q": "316",
"C": "8"
}
],
"A": [
{
"P": "743.50",
"Q": "11",
"C": "1"
},
{
"P": "743.55",
"Q": "267",
"C": "4"
},
{
"P": "743.65",
"Q": "1500",
"C": "1"
},
{
"P": "743.70",
"Q": "11",
"C": "1"
},
{
"P": "743.75",
"Q": "2530",
"C": "7"
}
],
"TQT": "10120104",
"LTP": "743.50",
"LTQ": "12",
"LTT": "1709113203",
"VWAP": "748.39",
"TBQTY": "609120",
"TSQTY": "1216842",
"O": "749.85",
"H": "756.75",
"L": "741.00",
"C": "749.85",
"OI": "0",
"LL": "501.55",
"LH": "777.50",
"TV": "75737.85"
}
The broadcast response itself is a JSON object containing various fields related to market data. Here's a breakdown of the structure:
Parsing Live VWAP value (From Broadcast)
This is the sample code for getting live VWAP out of broadcast message. Similarly we can all other like the Volume Last trded price (LTP), Last Traded Quantity (LTQ), Close price(C), and more. It's all about finding the right names for these values in the JSON data and adjusting the script accordingly. With a bit of tweaking, you can easily fetch and keep an eye on various live market statistics that matter to you.
Python
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = "{\"Message\":\"Broadcast\",\"EXC\":\"NSECM\",\"SECID\":\"3045\"}"
await websocket.send(sc)
OldVWAP = -1
while True:
response = await websocket.recv()
if "\"Broadcast\"" in response:
response_string = response
responses = response_string.strip().split("\n\n")
for res in responses:
data = json.loads(res)
if "LTP" in data:
if (OldVWAP != data["VWAP"] ):
OldVWAP = data["VWAP"]
print("VWAP:", data["VWAP"])
asyncio.run(connect_to_server())
Node.js
const WebSocket = require('ws');
async function connectToServer() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', async () => {
const sc = '{"Message":"Broadcast","EXC":"NSECM","SECID":"3045"}';
await ws.send(sc);
});
let oldVWAP = -1;
ws.on('message', data => {
const response = data.toString();
if (response.includes('"VWAP"')) {
const responses = response.trim().split("\n\n");
for (const res of responses) {
try {
const jsonData = JSON.parse(res);
if (jsonData["VWAP"] && oldVWAP !== jsonData["VWAP"]) {
oldVWAP = jsonData["VWAP"];
console.log("VWAP:", jsonData["VWAP"]);
}
} catch (error) {
console.error('Error parsing JSON:', error);
}
}
}
});
}
connectToServer().catch(console.error);
VWAP: 766.44
VWAP: 766.45
VWAP: 766.46
VWAP: 766.47
VWAP: 766.48
VWAP: 766.51
VWAP: 766.52
VWAP: 766.53
VWAP: 766.54
VWAP: 766.62
VWAP: 766.76
.
.
.
and so on
VWAP is crucial in stock trading, showing the average price weighted by volume. Traders rely on it to gauge fair value, decide on trades, and minimize market impact. It's especially handy for intraday analysis and algorithmic trading, offering a key reference point for efficient market navigation.
It is the Last Traded Price at which a security was traded on an exchange. It provides a real-time snapshot of a security's valuation, guiding investment decisions and trading strategies based on current market sentiment.
{
"Message": "LTP",
"EXC": "NSEFO",
"SECID": "35020"
}
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = '{"Message":"LTP","EXC":"NSEFO","SECID":"35020"}'
await websocket.send(sc)
while True:
response = await websocket.recv()
if '"LTP"' in response:
print(response)
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connect() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', () => ws.send('{"Message":"LTP","EXC":"NSEFO","SECID":"35020"}'));
ws.on('message', data => {
if (data instanceof Buffer) {
// Convert binary buffer to string
data = data.toString('utf-8');
}
console.log(data.includes('"LTP"') ? data : 'WebSocket connection failed');
});
}
connect();
{
"Message": "LTP",
"EXC": "NSEFO",
"SECID": "35020",
"LTP": "20915.00"
}
OHLCL stands for Open, High, Low, Close. It's a set of data points commonly used in financial markets to summarize the trading activity of a security over a given period. This data is essential for technical analysis, charting, and understanding market trends.
{
"Message": "OHLCL",
"EXC": "NSEFO",
"SECID": "35707"
}
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = '{"Message":"OHLCL","EXC":"NSEFO","SECID":"35707"}'
await websocket.send(sc)
while True:
response = await websocket.recv()
if '"OHLCL"' in response:
print(response)
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connect() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', () => ws.send('{"Message":"OHLCL","EXC":"NSEFO","SECID":"35707"}'));
ws.on('message', data => {
if (data instanceof Buffer) {
// Convert binary buffer to string
data = data.toString('utf-8');
}
console.log(data.includes('"OHLCL"') ? data : 'WebSocket connection failed');
});
}
connect();
{
"Message": "OHLCL",
"EXC": "NSEFO",
"SECID": "35707",
"O": "11015.00",
"H": "11099.25",
"L": "11013.10",
"C": "10985.00",
"LTP": "11092.05"
}
The provided data includes essential information for tracking securities in financial markets. It covers details such as the exchange where the security is traded, its unique identifier, and recent trading activity. Other important data points encompass the total quantity and value traded, along with prices at the open, high, low, and close of trading sessions. Additionally, it includes timestamps for the last trade and broadcast, as well as open interest and volume-weighted average price. These details are vital for investors and traders to monitor market movements and make informed decisions.
{
"Message": "Watch",
"EXC": "NSEFO",
"SECID": "71441"
}
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = '{"Message":"Watch","EXC":"NSEFO","SECID":"71441"}'
await websocket.send(sc)
while True:
response = await websocket.recv()
if '"Watch"' in response:
print(response)
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connect() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', () => ws.send('{"Message":"Watch","EXC":"NSEFO","SECID":"71441"}'));
ws.on('message', data => {
if (data instanceof Buffer) {
// Convert binary buffer to string
data = data.toString('utf-8');
}
console.log(data.includes('"Watch"') ? data : 'WebSocket connection failed');
});
}
connect();
{
"Message": "Watch",
"EXC": "NSEFO",
"SECID": "71441",
"LTP": "22287.55",
"LTQ": "50",
"BP": "22285.05",
"BQ": "50",
"SP": "22287.05",
"SQ": "250",
"TQT": "1495350",
"TV": "332965.69659000001",
"BT": "1708663448",
"LLT": "1708663447",
"VWAP": "22266.74",
"OI": "11420900",
"O": "22285.10",
"H": "22344.45",
"L": "22235.10",
"C": "22243.25"
}
This script establishes a WebSocket connection to a server, sends an "Auction" message upon receiving a handshake, and processes and prints the received auction messages containing auction data.
{
"Message": "Auction",
"EXC": "NSECM",
"SECID": "10397"
}
import asyncio
import websockets
async def connect_to_server():
async with websockets.connect('wss://wss.orvixtech.com:15208') as websocket:
response = await websocket.recv()
if "HandShake" in response:
sc = '{"Message":"Auction","EXC":"NSECM","SECID":"10397"}'
await websocket.send(sc)
response = await websocket.recv()
if '"Auction"' in response:
print(response)
else:
print("WebSocket connection failed")
asyncio.run(connect_to_server())
const WebSocket = require('ws');
async function connect() {
const ws = new WebSocket('wss://wss.orvixtech.com:15208');
ws.on('open', () => ws.send('{"Message":"Auction","EXC":"NSECM","SECID":"10397"}'));
ws.on('message', data => {
if (data instanceof Buffer) {
// Convert binary buffer to string
data = data.toString('utf-8');
}
console.log(data.includes('"Auction"') ? data : 'WebSocket connection failed');
});
}
connect();
{
"Message": "Auction",
"EXC": "NSECM",
"SECID": "10397",
"BT": "1709113203",
"B": [
{
"P": "0.00",
"Q": "151",
"C": "0"
},
{
"P": "0.00",
"Q": "0",
"C": "0"
},
{
"P": "0.00",
"Q": "0",
"C": "0"
},
{
"P": "0.00",
"Q": "0",
"C": "0"
},
{
"P": "0.00",
"Q": "0",
"C": "0"
}
],
"A": [
{
"P": "89.00",
"Q": "151",
"C": "0"
},
{
"P": "90.90",
"Q": "150",
"C": "0"
},
{
"P": "91.00",
"Q": "151",
"C": "0"
},
{
"P": "91.50",
"Q": "50",
"C": "0"
},
{
"P": "91.86",
"Q": "151",
"C": "0"
}
],
"TQT": "0",
"LTP": "0.00",
"LTQ": "0",
"LTT": "0",
"VWAP": "0.00",
"TBQTY": "0",
"TSQTY": "653",
"O": "0.00",
"H": "0.00",
"L": "0.00",
"C": "0.00",
"OI": "0",
"LL": "0.00",
"LH": "0.00",
"TV": "0.00",
"DPR": "60.82-91.23"
}