Re-Execute Order
The re-execute order API allows you to re-attempt order placement when temporary errors or issues occur during the original order placement. This functionality is particularly useful in scenarios such as:
- Network connectivity issues
- Temporary broker API failures
- Session timeouts
- Rate limit exceeded errors
- Temporary market-related rejections
Use Cases
- Error Recovery: When an order fails due to temporary issues, you can re-execute it with the same parameters
- Multiple Account Retry: If order placement fails in some accounts but succeeds in others, you can retry for specific accounts
- Session Management: When orders fail due to expired sessions, you can re-execute after session renewal
API Details
- Method: POST
- Endpoint:
https://apiv.maticalgos.com/reExecute
Request Parameters
Parameter | Type | Description |
---|---|---|
strategyname | string | Name of the strategy under which the order will be placed |
orderType | string | Type of order (Market/Limit/SL-Limit) |
productType | string | Type of product (Intraday/Delivery) |
limitPrice | number | Price at which the limit order should be placed |
token | string | Exchange:Token of the instrument (e.g., "NSE:212") |
qty | number | Quantity of the order |
transType | string | Transaction type (Buy/Sell) |
splitby | number | Split the order quantity into smaller batches (default: 0) |
triggerPrice | number | Trigger price for SL-Limit orders |
ForwardTest | boolean | Flag for forward testing |
operations | object | Order execution operations settings |
identifier | string | Optional identifier for specific account (UCC:AccountName). Use this to retry order in specific accounts |
ticksize | number | Tick size for the instrument (default: 0.05) |
Operations Object Structure
operations = {
"timeLimit": 0, # Time to wait for order execution (in seconds)
"shouldExecute": True,# Action to take after timeLimit (True: modify, False: cancel)
"priceBuffer": 0 # Price range to wait from limit price
}
Example Usage
- Basic Re-execution:
from maticalgos.sparkLib import SparkLib
spk = SparkLib(apikeys="apikeys")
spk.generate_token()
# Re-execute a limit order
spk.reexecute(
strategyname='test1',
orderType='Limit',
productType='Intraday',
token='NSE:212', # ASHOKLEY token
qty=1,
transType='Buy',
limitPrice=201.1,
splitby=0
)
- Re-execution for Specific Account:
# Re-execute order only in a specific account
spk.reexecute(
strategyname='test1',
orderType='Limit',
productType='Intraday',
token='NSE:212',
qty=1,
transType='Buy',
limitPrice=201.1,
identifier="8E808E0:test_acc_2" # Specify account for retry
)
Response Structure
On successful execution:
{
"status": true,
"error": false,
"data": [{
"strefID": "4071",
"placedIn": ["8E808E0:test_acc_2"]
}],
"message": "Order placed in 8E808E0:test_acc_2"
}
On error:
{
"status": false,
"error": true,
"message": "Error message description",
"data": ["Additional error details"]
}
Important Notes
- The re-execute functionality maintains all the features available in the regular place order functionality
- When using the
identifier
parameter, orders will only be re-executed in the specified account - Operations parameters can be used to implement smart execution strategies
- The order will be placed in all accounts that are currently active and linked to the strategy (unless an identifier is specified)
- If the strategy link is deactivated or if an account is deactivated, orders will not be placed in those accounts
- It's recommended to implement proper error handling and retry logic when using re-execute to avoid infinite retry loops
Best Practices
- Implement proper error handling before attempting re-execution
- Set appropriate timeouts and retry limits
- Log failed attempts and their reasons
- Use the identifier parameter when retrying for specific accounts
- Verify order status before attempting re-execution