Irage FIX Python API Documentation
A. APIs
- Overview
- Installation And Dependencies
- Configuration File
- API Methods
- Initialization
- Starting the Client
- New Order
- Modify Order
- Cancel Order
- Logout
- Stop
- Logging
B. FIX Messages
- Connection Flow
- Irage FIX Messages
- Logon Message
- Logon Response
- Logout Message
- Logout Response
- Heartbeat Message
- New Order
- Modify Order
- Cancel Order
- Order Response Common Error Handling
- Login Errors
- Order Processing Errors Appendix
C.Algo Orders
- Overview
- VWAP Order Parameters
- Detailed Parameter Descriptions
- Order Placement
- Response Format
- Limitations and Considerations
- Best Practices
- Error Codes
Overview
Welcome to the Irage FIX Python API Documentation. This document explains how to use the Irage FIX Python API client and describes the FIX messages used by the Irage trading platform. The client encapsulates the FIX protocol details and provides a simple interface for establishing connections and sending orders.
Installation and Dependencies
The client requires:
- Python 3.7+
- QuickFIX library (pip install quickfix
)
Configuration File
Create a configuration file (e.g., client.cfg
) with the following:
[DEFAULT]
ConnectionType = initiator
ReconnectInterval = 2
FileStorePath = store
FileLogPath = log
StartTime = 00:00:00
EndTime = 00:00:00
UseDataDictionary = Y
DataDictionary = spec/FIX42.xml
ValidateUserDefinedFields = N
ValidateFieldsOutOfOrder = N
[SESSION]
BeginString = FIX.4.2
SenderCompID=YOUR_SENDER_ID
TargetCompID = IRZ
HeartBtInt = 30
SocketConnectHost = YOUR_HOST
SocketConnectPort = YOUR_PORT
# Client Authentication Information (Required)
UCC = PARTH
Settlor = TEST6
PANnumber = PARTH123
CpCode = CPCODE6
AuthToken = YOUR_JWT_TOKEN
AuthToken length = LENGTH_OF_TOKEN
Configuration Parameters
Parameter | Description |
---|---|
ConnectionType |
Type of connection (initiator or acceptor ). |
ReconnectInterval |
Time in seconds to wait before attempting to reconnect. |
FileStorePath |
Directory to store FIX messages. |
FileLogPath |
Directory to store log files. |
StartTime |
Session start time in HH:MM:SS format. |
EndTime |
Session end time in HH:MM:SS format. |
UseDataDictionary |
Whether to use a data dictionary (Y or N ). |
DataDictionary |
Path to the FIX data dictionary file. |
ValidateUserDefinedFields |
Whether to validate custom fields (Y or N ). |
ValidateFieldsOutOfOrder |
Whether to allow out-of-order fields (Y or N ). |
BeginString |
FIX protocol version (e.g., FIX.4.2 ). |
SenderCompID |
Sender's unique identifier. |
TargetCompID |
Receiver's unique identifier. |
HeartBtInt |
Heartbeat interval in seconds. |
SocketConnectHost |
Host address of the FIX server. |
SocketConnectPort |
Port number of the FIX server. |
UCC |
Unique Client Code for authentication. |
Settlor |
Settlor name. |
PAN Number |
PAN number of the client. |
CpCode |
Client participant code. |
AuthToken |
JWT authentication token. |
AuthToken length |
Length of the authentication token. |
API Methods
Initialization
client = FixClient("client.cfg")
Initializes a new FIX client with the specified configuration file.
- Parameters:
config_file
(str): Path to the configuration file
Starting the Client
client.start()
Starts the FIX session and performs the login process. This method blocks until the login is complete or fails.
Returns: None
Raises:
- FixClientError
: If there's an error starting the session
Example:
try:
client.start()
print("Successfully logged in")
except FixClientError as e:
print(f"Failed to start: {e}")
Response Handling: After successful login, you'll receive a logon response with margin information in the respective logs (refer to logging section):
8=FIX.4.2|9=111|35=A|34=1|49=IRZ|52=20250128-12:30:31.959572800|56=R001-1|1=R001|98=0|108=30|1000=31815520|1001=20000000000000|10=036|
Key fields in the response:
- 1000
: Margin Utilized
- 1001
: Margin Allocated
client.send_new_order(order_id, side, ordertype, quantity, price, symbolid, NSEFO)
Sends a new order to the market.
- Parameters:
order_id
(str): Unique order identifierside
(str): Buy/Sell (1=Buy, 2=Sell)ordertype
(str): Order type (1=Market, 2=Limit)quantity
(int): Order quantity (raw quantity value, not in lots). Must be a multiple of the contract's lot sizeprice
(float): Price at which order is placedsymbolid
(str): Security identifierNSEFO
(str): Exchange destination (e.g., "NSEFO")
Returns: None
Example:
# Send a buy limit order
client.send_new_order("112", "1", "2", 100, 4629535, "35012", "NSEFO")
Response Handling: After sending a new order, you'll receive an execution report in the respective logs (refer to logging section):
8=FIX.4.2|9=285|35=8|49=IRZ|56=R001-1|34=2|52=20250127-13:59:30.64264414|39=0|100=NSEFO|44=4629535|48=35012|38=100|151=100|11=1456|37=101000011|14=0|54=1|55=BANKNIFTY|20=0|150=0|17=0|6=4629535|9010=0|4000=20250127-13:59:30.56993432|4001=20250127-13:59:30.57016567|4002=20250127-13:59:30.64263776|1=R001|10=220|
Modify Order
client.send_modify_order(order_id, origcid, side, ordertype, quantity, price, symbolid, NSEFO)
Modifies an existing order.
- Parameters:
order_id
(str): New order identifier (can be same as original)origcid
(str): Original order identifier to modifyside
(str): Buy/Sell (1=Buy, 2=Sell)ordertype
(str): Order type (1=Market, 2=Limit)quantity
(int): New order quantity (raw quantity value, not in lots). Must be a multiple of the contract's lot sizeprice
(float): Price at which order is placedsymbolid
(str): Security identifierNSEFO
(str): Exchange destination (e.g., "NSEFO")
Returns: None
Example:
# Modify an existing order to change the price
client.send_modify_order("112", "112", "1", "2", 100, 4629536, "35012", "NSEFO")
Response Handling: After sending a modify order request, you'll receive an execution report in the respective logs (refer to logging section):
8=FIX.4.2|9=297|35=8|34=2|49=IRZ|52=20250127-14:30:00.414959626|56=R001-1|1=R001|6=4629536|11=6541|14=0|17=0|20=0|37=101000003|38=100|39=5|41=6541|44=4629536|48=35012|54=1|55=BANKNIFTY|100=NSEFO|150=5|151=100|4000=20250127-14:30:00.406215357|4001=20250127-14:30:00.406236307|4002=20250127-14:30:00.414959129|9010=0|10=239|
Cancel Order
client.send_cancel_order(order_id, orig_order_id, side, ordertype, symbolid, NSEFO)
Cancels an existing order.
- Parameters:
order_id
(str): Order identifier for this cancel requestorig_order_id
(str): Original order identifier to cancelside
(str): Buy/Sell (1=Buy, 2=Sell)ordertype
(str): Order type (1=Market, 2=Limit)symbolid
(str): Security identifierNSEFO
(str): Exchange destination (e.g., "NSEFO")
Returns: None
Example:
# Cancel an existing order
client.send_cancel_order("112", "112", "1", "2", "35012", "NSEFO")
Response Handling: After sending a cancel request, you'll receive an execution report in the respective logs (refer to logging section):
8=FIX.4.2|9=306|35=8|49=IRZ|56=R001-1|34=2|52=20250127-13:28:57.47541976|39=4|100=NSEFO|44=4629535|48=35012|38=100|151=100|41=1237|11=1237|37=101000009|14=0|54=1|55=BANKNIFTY|20=0|150=4|84=100|103=0|17=0|6=4629535|9010=0|4000=20250127-13:28:57.30488917|4001=20250127-13:28:57.30496289|4002=20250127-13:28:57.47531646|1=R001|10=173|
Logout
client.logout()
Sends a logout message and closes the FIX session.
Returns: None
Example:
# Cleanly close the session
client.logout()
Response Handling: After sending a logout request, you'll receive a logout message in the respective logs (refer to logging section):
8=FIX.4.2|9=075|35=5|49=IRZ|56=12345|34=3|52=20241017-10:59:25.99|58=User initiated Logout|10=15|
Key fields in the response:
- 35
: Message type (5=Logout)
- 58
: Text message confirming logout
Stop
client.stop()
Stops the FIX session without sending a logout message. This is called automatically by logout()
.
Returns: None
Logging
All the messages sent and recieved by client will be stored in the logging path specified in configuration. The file name will be of the following format .
FIX.4.2-{SENDER-COMP-ID}-IRZ.event.current.log
Complete Usage Example
from fix_client import FixClient
# Initialize client
client = FixClient("client.cfg")
try:
# Start session (login)
client.start()
print("Login successful")
# Send a new order
client.send_new_order("112", "1", "2", 100, 4629535, "35012", "NSEFO")
print("Order sent")
# Wait for order to be processed
time.sleep(2)
# Modify the order
client.send_modify_order("112", "112", "1", "2", 100, 4629536, "35012", "NSEFO")
print("Order modified")
time.sleep(2)
# Cancel the order
client.send_cancel_order("112", "112", "1", "2", "35012", "NSEFO")
print("Order cancelled")
# Logout
client.logout()
print("Logged out")
except Exception as e:
print(f"Error: {e}")
client.stop()
Irage FIX MESSAGES
Version 1.0
Irage FIX Messages are based on the industry-standard FIX 4.2, with minor modifications to support custom functionality. This document describes the workflow and modifications from standard FIX.
Connection Flow
For clients to initiate the FIX connection, they first need to obtain an Authorization token, by login in to Irage Authorization Gateway**, which will then provide the necessary auth token.
Currently this can be obtained via the irage python-connect wrapper. (Gateway and login details are shared upon account creation)
After obtaining the authorization token, the client can then initiate the Fix connection, and provide the Logon message as described below.(There are few fields which are custom to the Irage System to be sent in the Logon message).
Once the login is successful, client can then proceed with sending normal order related messages as described in the sections below
Irage FIX Messages
Logon Message
The Logon <A>
message authenticates a user establishing a connection to a remote system. The Logon <A>
message must be the first message sent by the application requesting to initiate a FIX session.
Below fields have been added to Irage Logon Fix message
Additional Fields for Logon:
Tag | Value |
---|---|
96 | AuthToken |
439 | Settlor (clearing/NSE) |
1 | UCC |
9002 | PAN Number (Custom Field) |
9003 | CpCode (BSE) |
95 | AuthToken length |
Sample Message:
8=FIX.4.2|9=121|35=A|34=1|49=12345|52=20240930-08:24:22.507|56=IRZ|95=7|96=nse@123|98=0|108=30|141=Y|439=TEST1|1=R001|9002=Pan|10=156|
Logon Response
The logon response message builds on the original FIX message, with additional fields as mentioned below
Tag | Value |
---|---|
1000 | Margin Utilized (Custom Field) |
1001 | Margin Allocated (Custom Field) |
Sample Message:
8=FIX.4.2|9=111|35=A|34=1|49=IRZ|52=20250128-12:30:31.959572800|56=R001-1|1=R001|98=0|108=30|1000=31815520|1001=20000000000000|10=036|
Logout Message
The Logout <35=5> message initiates or confirms the termination of a FIX session. Disconnection without the exchange of Logout <35=5> messages should be interpreted as an abnormal condition.
Tag | Value |
---|---|
1 | UCC |
Sample Message:
8=FIX.4.2|9=60|35=5|34=3|49=12345|52=20241017-05:27:23.022|56=IRZ|1=R001|10=124|
Logout Response Message
Below is the logout response message client should receive on successful processing of the message .
Sample Message:
8=FIX.4.2|9=075|35=5|49=IRZ|56=12345|34=3|52=20241017-10:59:25.99|58=User initiated Logout|10=15|
Heartbeat Message
The Heartbeat <35=0> monitors the status of the communication link and identifies when the last of a string of messages was not received. Following field has been added and is mandatory to be sent for our systems
Tag | Value |
---|---|
1 | UCC |
Sample Message:
8=FIX.4.2|9=60|35=0|34=8|49=12345|52=20240930-10:14:51.326|56=IRZ|1=R001|10=127|
New Order Message
While sending a new message , below fields should be used based on necessity. Few of these fields are optionals and have been marked appropriately.
Mandatory Fields:
Tag | Value |
---|---|
48 | SecurityID |
100 | ExDestination |
1 | UCC |
11 | ClOrdID |
55 | Symbol (Optional) |
54 | Side |
40 | OrdType |
38 | OrdQty |
44 | Price |
9368 | AlgoId (Optional) |
9369 | AlgoCategory (Optional) |
18 | ExecInst (Optional) |
111 | Max single order qty (Optional) |
59 | TimeInforce (Optional) |
168 | StartTime (Optional) |
126 | EndTime (Optional) |
211 | Price Buffer (Optional) |
389 | Limit Price Increment (Optional) |
9011 | MaxTry Order (Optional) |
9012 | Order Alternative (Optional) |
9013 | Wait time (Optional) |
9014 | Order Level (Optional) |
9015 | Time Interval (Optional) |
9010 | User Defined OrderTag (It will be echoed) |
ExecInst <18> field can be used to provide Instructions for order handling on exchange trading floor. If more than one instruction is applicable to an order, this field can contain multiple instructions separated by space.
The purpose of this field is to enable clients to be able to provide a execution type e.g. VWAP, TWAP etc. Few of the valid fields for this tag is mentioned below
Code | Meaning |
---|---|
9 | Stay on bidside |
0 | Stay on offerside |
L | Last peg (last sale) |
M | Mid-price peg (midprice of inside quote) |
O | Opening peg |
P | Market peg |
W | Peg to VWAP |
Max single order qty <111> field can be used in conjunction with the ExecInst <18>, to provide the value for the maximum single order quantity to be sent to exchange
Some of the fields added above have special meaning and more details for them have been specified in Appendix.
Sample Message:
8=FIX.4.2|9=112|35=D|34=2|49=R001-1|52=20250127-08:27:31.575|56=IRZ|1=R001|11=1456|38=100|40=2|44=4629535|48=35012|54=1|100=NSEFO|10=105|
Modify Order Message
While sending a modify message, client needs to populate the following fields using the OrderCancelReplaceRequest Fix message .
Tag | Value |
---|---|
41 | OrigClOrdID |
11 | ClOrdID |
55 | Symbol (Optional) |
54 | Side |
40 | OrdType |
38 | OrdQty |
44 | Price |
48 | SecurityID |
1 | UCC |
100 | ExDestination |
9010 | User Defined OrderTag (Optional, echoed) |
Sample Message:
8=FIX.4.2|9=139|35=G|34=2|49=R001-1|52=20250127-08:58:01.925|56=IRZ|1=R001|11=6541|38=100|40=2|41=6541|44=4629536|48=35012|54=1|55=APPL|100=NSEFO|440=R001-1|10=213|
Cancel Order
For canceling an existing order client needs to use OrderCancelRequest FIX message, populated with the following information.
Tag | Value |
---|---|
41 | OrigClOrdID |
11 | ClOrdID |
48 | SecurityID |
54 | Side |
1 | UCC |
100 | ExDestination |
40 | OrdType |
Sample Message:
8=FIX.4.2|9=120|35=F|34=2|49=R001-1|52=20250127-07:56:58.547|56=IRZ|1=R001|11=1237|38=100|40=2|41=1237|44=4629535|48=35012|54=1|100=NSEFO|10=224|
Order Response Message
For a successful message we provide the standard Execution Report message.(Purpose of Execution Report is to send order information to a FIX client, such as confirmations, fills, and unsolicited changes)
The Execution Report <35=8> message is used to:
- Confirm the receipt of an order
- Confirm changes to an existing order (i.e. accept cancel and replace requests)
- Relay order status information
- Relay fill information on working orders
- Reject orders
- Report post-trade fees calculations associated with a trade
Below are some of the response messages using the Execution Report, to communicate the order status.
Tag | Value |
---|---|
39 | OrdStatus |
100 | ExDestination |
44 | Price |
48 | SecurityID |
38 | OrderQty |
151 | LeavesQty |
11 | ClOrdID |
37 | OrderID |
14 | CumQty |
54 | Side |
55 | Symbol |
20 | ExecTransType |
150 | ExecType |
17 | ExecID |
6 | AvgPx |
1 | UCC |
9010 | User Defined OrderTag (Optional, echoed) |
4000 | Timestamp when received by OMS |
4001 | Timestamp when sent to exchange |
4002 | Timestamp of response from exchange |
4003 | Timestamp when sent to client |
Sample Message:
Sample Create Order Response:
8=FIX.4.2|9=285|35=8|49=IRZ|56=R001-1|34=2|52=20250127-13:59:30.64264414|39=0|100=NSEFO|44=4629535|48=35012|38=100|151=100|11=1456|37=101000011|14=0|54=1|55=BANKNIFTY|20=0|150=0|17=0|6=4629535|9010=0|4000=20250127-13:59:30.56993432|4001=20250127-13:59:30.57016567|4002=20250127-13:59:30.64263776|1=R001|10=220|
Sample Modify Order Response:
8=FIX.4.2|9=297|35=8|34=2|49=IRZ|52=20250127-14:30:00.414959626|56=R001-1|1=R001|6=4629536|11=6541|14=0|17=0|20=0|37=101000003|38=100|39=5|41=6541|44=4629536|48=35012|54=1|55=BANKNIFTY|100=NSEFO|150=5|151=100|4000=20250127-14:30:00.406215357|4001=20250127-14:30:00.406236307|4002=20250127-14:30:00.414959129|9010=0|10=239|
Sample Cancel Order Response:
8=FIX.4.2|9=306|35=8|49=IRZ|56=R001-1|34=2|52=20250127-13:28:57.47541976|39=4|100=NSEFO|44=4629535|48=35012|38=100|151=100|41=1237|11=1237|37=101000009|14=0|54=1|55=BANKNIFTY|20=0|150=4|84=100|103=0|17=0|6=4629535|9010=0|4000=20250127-13:28:57.30488917|4001=20250127-13:28:57.30496289|4002=20250127-13:28:57.47531646|1=R001|10=173|
Common Error Handling
Login Errors
Type | Message |
---|---|
Invalid UCC | 58=UCC(1) not/wrong provided |
Invalid Settlor | 58=Wrong settlor(439) Provided: Immediate Disconnect |
Invalid PAN | 58=Wrong PAN(9002) Provided: Immediate Disconnect |
Invalid CpCode | 58=Wrong CpCode(9003) Provided: Immediate Disconnect |
Invalid Credentials | 58=Invalid Credentials |
Invalid Credentials Raw Length | 58=RawData(95 and 96) not/wrong provided |
Order Processing Errors
Common Checks During Create, Update, Cancel
Type | Message |
---|---|
Invalid Quantity | 58=Qty(38) not/wrong provided |
Invalid Exchange Destination | 58=EXCHANGE_DESTINATION(100) not/wrong provided |
Invalid Price | 58=New Order Failed - Reason Code = E_RMS_DPR |
Invalid SecurityID | 58=securityId(48) not/wrong provided |
Invalid Order ID | 58=cid(11) not/wrong provided |
Invalid Order Type | 58=OrdType(40) not/wrong provided |
Invalid Side | 58=side(54) not/wrong provided |
Specific Checks During Order Operations
During Create:
Type | Message |
---|---|
Duplicate Order ID | 58=NEW REJ: ORDER ALREADY STANDING ON THIS CID |
During Update/Cancel:
Type | Message |
---|---|
Modify on Same Price/Quantity | 58=Rpl Order Failed - Reason Code = REPLACE ON SAME PRICE AND QTY |
Modify Order with Side Change | 58=MOD/CXL REJ: NO ORDER STANDING ON ORIG_CID(41) |
Modify Order with Side Change | 58=CANNOT CHANGE SECURITY_ID(48) ON MOD/CXL |
Exchange order id mismatch | 58=CANNOT CHANGE EXCH_ORDER_ID(37) ON MOD/CXL |
Duplicate Order ID | 58=MOD/CXL REJ: ORDER ALREADY STANDING ON NEW CID(11) |
Side Mismatch | 58=CANNOT CHANGE SIDE(54) ON MOD/CXL |
Appendix
Fields Description
Authentication & Settlement
AuthToken (Tag 96)
- Used for authentication purposes.
- Example -
96=eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJkNTQ2M2EwZi01OGI5LTRjMmMtYTI0YS1jZDVmZWQ5NDJlMzYifQ.eyJleHAiOjE3NDAwMjk1MDQsImlhdCI6MTczOTk0MzEwNCwianRpIjoiZWViMDNmNDEtNTY1Ny00MjYzLTg5ZWEtZDg3MmM3ZDIyMTBjIiwiaXNzIjoiaHR0cHM6Ly9hcnJvdy5pcmFnZS5pbjo4NDQzL3JlYWxtcy9JQlNMIiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiSUJTTDkwMDY4Iiwic2lkIjoiZDQ3MWM0ZmUtOTAyMy00MWEzLWFhODItNzc4YmFlMDRmNmUzIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCJ9.OzJ_0IQDGWFIH4rxc_xs1B3rTIdkzHSxvfWGmX8yZ6w
Settlor (Tag 439)
- Represents the entity responsible for settlement.
- Example
439=TEST1
UCC (Tag 1)
- Unique Client Code used for identification.
- Example
1=R001
PAN (Tag 9002)
- Permanent Account Number used for tax and financial transactions.
- Example
9002=ABCDEF123456
AuthToken length (Tag 95)
- Specifies the length of the authentication token.
- Example
95=461
Security & Order Identifiers
SecurityID (Tag 48)
- Identifies the security being traded.
- Example
48=35012
ExDestination (Tag 100)
- Specifies Execution destination as defined by client when order is entered.
- Example
100=NSEFO
OrigClordID (Tag 41)
- ClOrdID <11> of the previous order (NOT the initial order of the day) as assigned by the institution, used to identify the previous order in cancel and cancel/replace requests.
- Example
41=1237
ClordID (Tag 11)
- Unique identifier for Order as assigned by client for each order.
- Example
11=1237
Order Details
Side (Tag 54)
- Indicates the buy or sell side of the order.
- Valid Values:
Value | Meaning |
---|---|
1 | BUY |
2 | SELL |
OrdType (Tag 40)
- Specifies the type of order (e.g., Market, Limit).
- Valid Values:
Value | Meaning |
---|---|
1 | MARKET |
2 | LIMIT |
3 | STOP |
OrdQty (Tag 38)
- Defines the quantity of the order.
- Example
38=10
Price (Tag 44)
- Specifies the price at which the order is placed.
- Example
44=84451
Execution Details
OrdStatus (Tag 39)
- Represents the current status of the order.
- Valid Values:
Value | Meaning |
---|---|
0 | NEW |
1 | PARTIALLY FILLED |
2 | FILLED |
3 | DONE FOR DAY |
4 | CANCELLED |
5 | REPLACED |
LeavesQty (Tag 151)
- Quantity of the order yet to be executed.
- LeavesQty <151> = OrderQty <38> - CumQty <14>.
- Example
11=100
OrderID (Tag 37)
- Unique identifier assigned to the order by the OMS.
- Example
37=101000011
CumQty (Tag 14)
- Cumulative quantity executed so far.
- Example
14=0
ExecTransType (Tag 20)
- Indicates the transaction type (e.g., New, Cancel, Correct).
- Valid Values:
Value | Meaning |
---|---|
0 | NEW |
1 | CANCEL |
2 | CORRECT |
3 | STATUS |
ExecType (Tag 150)
- Describes the specific Execution Report (i.e. Pending Cancel) while OrdStatus <39> will always identify the current order status (i.e. Partially Filled)
- Valid Values:
Value | Meaning |
---|---|
0 | NEW |
1 | REPLACED |
2 | REPLACED |
3 | DONE FOR DAY |
4 | CANCELLED |
5 | REPLACED |
ExecID (Tag 17)
- Unique identifier for the execution event assigned by the OMS.
- Example
17=0
AvgPx (Tag 6)
- Average price of the executed order.
- As average price is not been calculated on OMS side , it will always be filled 0.
NewOrderSingle Message - Special Algo Fields
This document provides details on specific FIX fields that have special meaning when used with certain algorithms.
Special Algo Fields
EffectiveTime (Tag 168)
- Used as Start Time for a particular algo.
- Format:
YYYYMMDD-HH:MM:SS
ExpireTime (Tag 126)
- Used as End Time for a particular algo.
- Format:
YYYYMMDD-HH:MM:SS
PegDifference (Tag 211)
- Used for the Price Buffer parameter associated with an algo.
DiscretionOffset (Tag 389)
- Used for the Limit Price Increment parameter associated with an algo.
MaxTry (Tag 9011)
- Specifies the maximum number of times an existing order can be modified.
- Used for the Limit Price max Try parameter in an algo.
Order Alternative (Tag 9012)
- Used for the Limit Price Alternative, which is specific to some algos.
Valid Values:
Value | Meaning |
---|---|
0 | MARKET |
1 | CANCEL |
2 | PENDING |
Wait Time (Tag 9013)
- Specifies the time in milliseconds to wait before modifying/canceling an order post its update.
- Used for the Limit Price Wait parameter in an algo.
Order Level (Tag 9014)
- Used for the Place At parameter in an algo.
Valid Values:
Value | Meaning |
---|---|
0 | BID |
1 | ASK |
2 | LTP |
3 | BID_2 |
4 | ASK_2 |
Time Interval (Tag 9015)
- Specifies the execution time for an algo.
- Used in conjunction with Start Time (Tag 168).
VWAP Order API Documentation
VWAP Overview
The Volume-Weighted Average Price (VWAP) algorithm is designed to execute orders over a specified time period with the goal of achieving an average execution price close to the volume-weighted average price of the security during that period. This document outlines how to use the VWAP order API, including parameter specifications, limitations, and request/response formats.
VWAP Order Parameters
Parameter | FIX Tag | Description | Data Type | Required | Notes |
---|---|---|---|---|---|
total_qty |
13013 | Total quantity to be executed | Integer | Yes | Total number of units to be traded |
start_time |
13010 | Execution start time | Time (HH:MM:SS) | Yes | When the VWAP execution should begin |
duration |
13011 | Duration of VWAP execution | Integer | Yes | Time in seconds for the VWAP execution |
symid |
13008 | Symbol identifier | Integer | Yes | Unique identifier for the trading instrument |
side |
13009 | Order side | String/Enum | Yes | "BUY" or "SELL" |
max_order_size |
13000 | Maximum size for individual orders | Integer | Yes | Limits the size of each child order |
start_price_point |
13001 | Reference price point | Integer | Yes | -1 for Last Traded Price, ≥0 for a specific book level |
start_price_side |
N/A | Side for reference price | String/Enum | Conditional | Required when start_price_point ≥ 0. "BID" or "ASK" |
price_buffer |
13002 | Price buffer for quoting | Integer | Yes | In paisa (e.g., +10 means 10 paisa above reference) |
min_price_change |
13003 | Minimum price change for replacement | Integer | Yes | Threshold that triggers order replacement |
max_replace_count |
13004 | Maximum replacement count per order | Integer | Yes | After this limit is reached, order is canceled and a new one is placed |
do_after_vwap_run |
13005 | Action after VWAP completion | Integer/Enum | Yes | 0=Cancel, 1=Market Hit, 2=Keep Standing |
min_replace_time_gap |
13006 | Minimum time between replacements | Integer | Yes | In microseconds |
max_outstanding_order |
13007 | Maximum concurrent orders | Integer | Yes | Limit on number of standing orders at any time |
is_ioc |
13012 | Immediate-Or-Cancel flag | Boolean | Yes | Default is false |
Detailed Parameter Descriptions
total_qty
The total number of units to be executed by the VWAP algorithm over the specified duration.
start_time
The time at which the VWAP execution should begin, in HH:MM:SS format.
duration
The time period (in seconds) over which the VWAP algorithm will execute the order.
symid
The unique identifier for the trading instrument (e.g., 58958 for BANKNIFTY25MARFUT).
side
Specifies whether the order is to buy or sell the instrument.
- BUY: Purchase the specified quantity
- SELL: Sell the specified quantity
max_order_size
The maximum size for any individual order placed by the VWAP algorithm. This helps manage market impact.
start_price_point
Defines the reference price point for order placement:
- -1: Use the Last Traded Price (LTP)
- ≥0: Use a specific book level (e.g., 0 for top of book)
start_price_side
When start_price_point
≥ 0, this parameter specifies which side of the order book to use:
- BID: Use the bid side of the book
- ASK: Use the ask side of the book
price_buffer
The price adjustment (in paisa) applied to the reference price when quoting a new order. For example:
- For a BUY order with a buffer of +5, the price will be LTP + 5 paisa
- For a SELL order with a buffer of -5, the price will be LTP - 5 paisa
min_price_change
The minimum price movement (in paisa) that will trigger a replacement of an existing order.
max_replace_count
The maximum number of times an order can be replaced before it is canceled and a new order is placed.
do_after_vwap_run
Specifies the action to take after the VWAP execution period ends:
- 0 (kCancel): Cancel all remaining standing orders
- 1 (kMarketHit): Aggressively execute any remaining quantity at market price
- 2 (kKeepStanding): Leave any remaining orders standing in the market
min_replace_time_gap
The minimum time (in microseconds) that must elapse between consecutive order replacements.
max_outstanding_order
The maximum number of orders that can be active in the market simultaneously.
is_ioc
If set to true, orders will be executed with Immediate-Or-Cancel behavior, meaning any portion that cannot be executed immediately will be canceled.
Order Placement
JSON Format Request Example
{
"order_type": "VWAP",
"parameters": {
"total_qty": 30000,
"start_time": "11:20:00",
"duration": 10,
"symid": 58958,
"side": "BUY",
"max_order_size": 90,
"start_price_point": -1,
"price_buffer": 5,
"min_price_change": 1,
"max_replace_count": 5,
"do_after_vwap_run": 0,
"min_replace_time_gap": 25000,
"max_outstanding_order": 3,
"is_ioc": false
}
}
FIX Format Request Example
8=FIX.4.2|9=356|35=D|34=124|49=CLIENT|56=SERVER|52=20250225-11:19:45|11=order123|55=BANKNIFTY25MARFUT|54=1|38=30000|40=D|59=0|847=VWAP|13013=30000|13010=11:20:00|13011=10|13008=58958|13009=1|13000=90|13001=-1|13002=5|13003=1|13004=5|13005=0|13006=25000|13007=3|13012=0|10=248|
FIX Tag Mapping
Parameter | FIX Tag | Values |
---|---|---|
total_qty | 13013 | Integer |
start_time | 13010 | Time (HH:MM:SS) |
duration | 13011 | Integer (seconds) |
symid | 13008 | Integer |
side | 13009 | 1=BUY, 2=SELL |
max_order_size | 13000 | Integer |
start_price_point | 13001 | Integer (-1 for LTP, ≥0 for book level) |
price_buffer | 13002 | Integer (paisa) |
min_price_change | 13003 | Integer (paisa) |
max_replace_count | 13004 | Integer |
do_after_vwap_run | 13005 | 0=Cancel, 1=Market Hit, 2=Keep Standing |
min_replace_time_gap | 13006 | Integer (microseconds) |
max_outstanding_order | 13007 | Integer |
is_ioc | 13012 | 0=false, 1=true |
Response Format
JSON Response Example (Success)
{
"status": "accepted",
"order_id": "vwap_123456",
"message": "VWAP order accepted",
"timestamp": "2025-02-25T11:19:48.123Z"
}
JSON Response Example (Error)
{
"status": "rejected",
"error_code": "INVALID_PARAMETER",
"message": "Invalid start_time format. Expected HH:MM:SS",
"timestamp": "2025-02-25T11:19:48.123Z"
}
FIX Response Example (Success)
8=FIX.4.2|9=129|35=8|34=125|49=SERVER|56=CLIENT|52=20250225-11:19:48|11=order123|37=vwap_123456|150=0|39=0|847=VWAP|58=VWAP order accepted|10=165|
FIX Response Example (Error)
8=FIX.4.2|9=143|35=8|34=125|49=SERVER|56=CLIENT|52=20250225-11:19:48|11=order123|37=NONE|150=8|39=8|847=VWAP|58=Invalid start_time format. Expected HH:MM:SS|10=112|
Limitations and Considerations
1.Time Precision: The start_time
must be provided in HH:MM:SS format. Orders placed with start times in the past will be rejected.
2.Quantity Constraints:
total_qty
must be greater than zero and less than the exchange-defined maximum for the symbolmax_order_size
must be less than or equal tototal_qty
-
Error on invalid quantity:
8=FIX.4.2|9=202|35=U8|49=IRZ|56=R001-1|34=255|52=20250408-14:30:30.768060853|39=8|100=NSEFO|41=01|11=500018|47=1|103=99|9010=ALGO_ORDER|18049=0|4000=1744102830076789666|4003=1744102830076806085|58=Invalid Qty for Vwap Algo|10=246
3.Duration Constraints:
- Minimum duration: 1 second
- Maximum duration: 86400 seconds (24 hours)
4.Price Buffer:
- For BUY orders: Positive values increase the reference price, negative values decrease it
- For SELL orders: Positive values decrease the reference price, negative values increase it
5.Order State Management:
- If
max_replace_count
is reached for an order, it will be canceled and replaced with a new order - If market conditions prevent order replacement within
min_replace_time_gap
, the replacement will be queued
6.Market Hours:
- VWAP orders can only be executed during regular market hours
- If the VWAP duration extends beyond market close, the algorithm will complete execution by market close
7.Rate Limiting:
- Maximum of 10 VWAP orders per second per client
- Maximum of 100 VWAP orders per day per client
Best Practices
1.Duration Selection:
- For liquid securities, shorter durations (minutes to hours) are typically sufficient
- For less liquid securities, longer durations may be necessary to minimize market impact
2.Order Size Management:
- Set
max_order_size
to a small percentage of average daily volume to minimize market impact - Consider market liquidity when setting
max_outstanding_order
3.Price Buffer Management:
- For highly volatile securities, consider using larger values for
min_price_change
- Adjust
price_buffer
based on typical bid-ask spreads for the security
4.Post-VWAP Action:
- Use
do_after_vwap_run=0
(Cancel) for time-sensitive orders where partial fills are acceptable - Use
do_after_vwap_run=1
(Market Hit) when full execution is more important than price - Use
do_after_vwap_run=2
(Keep Standing) for less time-sensitive orders where price is more important
5.Cancelling or Stopping an Algo:
- To cancel or stop an algo, send a FIX message with
35=UF
and repeat the sameClientID
used in the original order - Example:
8=FIX.4.2|35=UF|34=125|49=SERVER|56=CLIENT|41=ClientID|11=ClientID
Error Codes
Error Code | Description |
---|---|
INVALID_PARAMETER | One or more parameters have invalid values |
MISSING_PARAMETER | One or more required parameters are missing |
INSTRUMENT_NOT_FOUND | The specified instrument ID does not exist |
MARKET_CLOSED | The market is currently closed |
INSUFFICIENT_BALANCE | Insufficient balance to execute the order |
RATE_LIMIT_EXCEEDED | Client has exceeded the rate limit for VWAP orders |
INTERNAL_ERROR | An internal server error occurred |
Disclaimer
This document is subject to updates. Users should check regularly for changes.