Skip to main content

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

  1. Error Recovery: When an order fails due to temporary issues, you can re-execute it with the same parameters
  2. Multiple Account Retry: If order placement fails in some accounts but succeeds in others, you can retry for specific accounts
  3. 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

ParameterTypeDescription
strategynamestringName of the strategy under which the order will be placed
orderTypestringType of order (Market/Limit/SL-Limit)
productTypestringType of product (Intraday/Delivery)
limitPricenumberPrice at which the limit order should be placed
tokenstringExchange:Token of the instrument (e.g., "NSE:212")
qtynumberQuantity of the order
transTypestringTransaction type (Buy/Sell)
splitbynumberSplit the order quantity into smaller batches (default: 0)
triggerPricenumberTrigger price for SL-Limit orders
ForwardTestbooleanFlag for forward testing
operationsobjectOrder execution operations settings
identifierstringOptional identifier for specific account (UCC:AccountName). Use this to retry order in specific accounts
ticksizenumberTick 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

  1. 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
)
  1. 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

  1. Implement proper error handling before attempting re-execution
  2. Set appropriate timeouts and retry limits
  3. Log failed attempts and their reasons
  4. Use the identifier parameter when retrying for specific accounts
  5. Verify order status before attempting re-execution