Skip to main content
Version: 1.0 (Current)

Execution Settings Schema

This document provides the complete schema reference for the executionSettings configuration object. Execution settings define how the algorithm interacts with the market and executes trades.

Overview​

Execution settings are part of Step 5 of algorithm configuration. They control:

  • Execution mode (live, paper, backtest)
  • Exchange selection
  • Broker integration
  • Order types
  • Slippage assumptions
  • Indian market-specific settings

Schema Structure​

interface ExecutionSettings {
mode: 'live' | 'paper' | 'backtest'
exchange: 'NSE' | 'BSE' | 'MCX' | 'NCDEX'
broker?: 'AngelOne' | 'Zerodha' | 'Upstox' | 'Dhan'
orderType: 'market' | 'limit' | 'stop' | 'stop_limit'
slippage: number
indianMarketSettings?: IndianMarketSettings
}

Core Fields​

mode​

  • Type: enum
  • Required: Yes
  • Values:
    • live - Real trading with actual capital
    • paper - Simulated trading with real market data
    • backtest - Historical data testing
  • Example: "paper"

Mode Descriptions:

Live Trading​

  • Executes real trades through broker API
  • Uses actual capital
  • Incurs real costs (brokerage, taxes)
  • Requires broker connection
  • Risk: Real money at stake

Requirements:

  • Broker account configured
  • Sufficient balance
  • API credentials valid
  • Risk parameters validated

Paper Trading​

  • Simulates trades with real-time data
  • No real money involved
  • No brokerage costs
  • Tests strategy in live market conditions
  • Risk: None (simulation only)

Use Cases:

  • Testing new strategies
  • Validating algorithm logic
  • Building confidence before going live
  • Training and learning

Backtesting​

  • Tests strategy on historical data
  • Fast execution (no waiting for candles)
  • Evaluates past performance
  • Identifies optimal parameters
  • Risk: None (historical data only)

Use Cases:

  • Strategy development
  • Parameter optimization
  • Performance validation
  • Walk-forward analysis

Transition Path:

Backtest → Paper Trading → Live Trading

exchange​

  • Type: enum
  • Required: Yes
  • Values:
    • NSE - National Stock Exchange
    • BSE - Bombay Stock Exchange
    • MCX - Multi Commodity Exchange
    • NCDEX - National Commodity & Derivatives Exchange
  • Example: "NSE"

Exchange Details:

NSE (National Stock Exchange)​

  • Trading Hours: 09:15 - 15:30 IST
  • Pre-Open: 09:00 - 09:15 IST
  • Instruments: Equities, Futures, Options
  • Symbol Format: NSE:RELIANCE, NSE:NIFTY25JAN24500CE

Segments:

  • Cash Market (Equities)
  • Futures & Options (F&O)
  • Currency Derivatives

BSE (Bombay Stock Exchange)​

  • Trading Hours: 09:15 - 15:30 IST
  • Pre-Open: 09:00 - 09:15 IST
  • Instruments: Equities, Futures, Options
  • Symbol Format: BSE:INFY, BSE:SENSEX25JANFUT

Segments:

  • Cash Market (Equities)
  • Futures & Options (F&O)
  • Currency Derivatives

MCX (Multi Commodity Exchange)​

  • Trading Hours: 09:00 - 23:30 IST (varies by commodity)
  • Instruments: Commodity Futures
  • Symbol Format: MCX:CRUDEOIL25JANFUT, MCX:GOLD

Commodities:

  • Energy: Crude Oil, Natural Gas
  • Metals: Gold, Silver, Copper, Zinc
  • Agriculture: Cotton, Cardamom

NCDEX (National Commodity & Derivatives Exchange)​

  • Trading Hours: 10:00 - 17:00 IST (most commodities)
  • Instruments: Agricultural Commodity Futures
  • Symbol Format: NCDEX:SOYBEAN, NCDEX:WHEAT

Commodities:

  • Oilseeds: Soybean, Mustard
  • Cereals: Wheat, Rice
  • Spices: Turmeric, Jeera

broker​

  • Type: enum
  • Required: No (required for live mode)
  • Values:
    • AngelOne - Angel One (formerly Angel Broking)
    • Zerodha - Zerodha
    • Upstox - Upstox
    • Dhan - Dhan
  • Example: "AngelOne"

Broker Comparison:

AngelOne​

  • API: SmartAPI
  • Rate Limit: 1 request/second
  • Supported: NSE, BSE, MCX, NCDEX
  • Features: Full F&O support, commodity trading
  • Setup: See Broker Integration Guide for details

Zerodha​

  • API: Kite Connect
  • Rate Limit: 3 requests/second
  • Supported: NSE, BSE, MCX, NCDEX
  • Features: Most popular, extensive documentation
  • Setup: See Broker Integration Guide for details

Upstox​

  • API: Upstox API
  • Rate Limit: 2 requests/second
  • Supported: NSE, BSE, MCX
  • Features: Low brokerage, good API
  • Setup: See Broker Integration Guide for details

Dhan​

  • API: Dhan API
  • Rate Limit: 1 request/second
  • Supported: NSE, BSE, MCX
  • Features: Modern platform, good support
  • Setup: See Broker Integration Guide for details

orderType​

  • Type: enum
  • Required: Yes
  • Values:
    • market - Execute at current market price
    • limit - Execute at specified price or better
    • stop - Trigger market order at stop price
    • stop_limit - Trigger limit order at stop price
  • Example: "market"

Order Type Details:

Market Order​

  • Execution: Immediate at best available price
  • Guarantee: Execution guaranteed (in liquid markets)
  • Price: Not guaranteed (subject to slippage)
  • Use Case: Quick entry/exit, liquid instruments

Pros:

  • Fast execution
  • Guaranteed fill (usually)
  • Simple to implement

Cons:

  • Price uncertainty
  • Slippage in volatile markets
  • Gap risk

Example:

{
"orderType": "market"
}

Limit Order​

  • Execution: Only at specified price or better
  • Guarantee: Price guaranteed
  • Fill: Not guaranteed (may not execute)
  • Use Case: Price-sensitive entries, illiquid instruments

Pros:

  • Price control
  • No slippage
  • Better fills possible

Cons:

  • May not execute
  • Requires price monitoring
  • Partial fills possible

Example:

{
"orderType": "limit"
}

Stop Order (Stop-Loss Market)​

  • Trigger: When price reaches stop level
  • Execution: Market order after trigger
  • Use Case: Stop losses, breakout entries

Pros:

  • Automatic trigger
  • Guaranteed execution after trigger
  • Good for stop losses

Cons:

  • Slippage after trigger
  • Gap risk
  • May trigger on spike

Example:

{
"orderType": "stop"
}

Stop-Limit Order​

  • Trigger: When price reaches stop level
  • Execution: Limit order after trigger
  • Use Case: Controlled stop losses, precise breakouts

Pros:

  • Price control after trigger
  • No slippage
  • Precise execution

Cons:

  • May not fill after trigger
  • Complex to manage
  • Requires two price levels

Example:

{
"orderType": "stop_limit"
}

slippage​

  • Type: number
  • Required: Yes
  • Range: 0 to 5
  • Unit: Percentage
  • Description: Expected slippage for backtesting and paper trading
  • Default: 0.1
  • Example: 0.1

Purpose:

  • Realistic backtest results
  • Account for execution costs
  • Simulate real market conditions

Calculation:

Actual Fill Price = Expected Price × (1 ± slippage/100)

Long Entry: Fill = Expected × (1 + slippage/100)
Long Exit: Fill = Expected × (1 - slippage/100)
Short Entry: Fill = Expected × (1 - slippage/100)
Short Exit: Fill = Expected × (1 + slippage/100)

Example:

{
"slippage": 0.1
}

With ₹500 expected price and 0.1% slippage:

  • Long Entry: ₹500.50 (0.1% worse)
  • Long Exit: ₹499.50 (0.1% worse)

Recommended Values:

Market ConditionSlippage
Highly Liquid (Nifty 50)0.05-0.1%
Liquid (Top 200 stocks)0.1-0.2%
Moderate Liquidity0.2-0.5%
Low Liquidity0.5-1.0%
Very Low Liquidity1.0-2.0%

Factors Affecting Slippage:

  • Market volatility
  • Order size
  • Liquidity
  • Time of day
  • Order type

Indian Market Settings​

Optional configuration for India-specific market rules.

interface IndianMarketSettings {
enabled: boolean
autoSquareOff?: AutoSquareOff
productType?: ProductType
circuitBreakerHandling?: 'pause' | 'exit_all' | 'continue'
avoidPreOpen?: boolean
sttCalculation?: boolean
gstCalculation?: boolean
rmsBuffer?: number
}

enabled​

  • Type: boolean
  • Required: Yes
  • Description: Whether Indian market settings are enabled
  • Example: true

Auto Square-Off Configuration​

interface AutoSquareOff {
enabled: boolean
minutesBeforeClose: number // 5 to 60
}

enabled​

  • Type: boolean
  • Required: Yes (if indianMarketSettings is defined)
  • Description: Whether auto square-off is enabled
  • Example: true

minutesBeforeClose​

  • Type: number
  • Required: Yes (if enabled is true)
  • Range: 5 to 60
  • Default: 15
  • Description: Minutes before market close to square off intraday positions
  • Example: 15

Exchange-Specific Times:

  • NSE/BSE: 15:15 IST (15 minutes before 15:30 close)
  • MCX: 23:15 IST (15 minutes before 23:30 close)

Example:

{
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
}
}

Purpose:

  • Prevents overnight positions for intraday products
  • Avoids penalty charges
  • Ensures compliance with broker rules

productType​

  • Type: enum
  • Required: No
  • Values:
    • intraday - Intraday/MIS (Margin Intraday Square-off)
    • delivery - Delivery/CNC (Cash and Carry)
    • BTST - Buy Today Sell Tomorrow
    • futures - Futures contracts
    • options - Options contracts
  • Example: "intraday"

Product Type Details:

Intraday (MIS)​

  • Margin: High leverage (5-20x)
  • Holding: Must square off same day
  • Auto Square-Off: Yes (before market close)
  • Use Case: Day trading, scalping

Delivery (CNC)​

  • Margin: Full capital required
  • Holding: Can hold indefinitely
  • Auto Square-Off: No
  • Use Case: Swing trading, investing

BTST (Buy Today Sell Tomorrow)​

  • Margin: Partial (varies by broker)
  • Holding: T+1 settlement
  • Minimum Hold: 1 day
  • Use Case: Short-term swing trades

Futures​

  • Margin: Based on contract specifications
  • Holding: Until expiry or square-off
  • Auto Square-Off: On expiry day
  • Use Case: Leveraged trading, hedging

Options​

  • Margin: Premium + margin (for sellers)
  • Holding: Until expiry or square-off
  • Auto Square-Off: On expiry day
  • Use Case: Directional bets, hedging

circuitBreakerHandling​

  • Type: enum
  • Required: No
  • Values:
    • pause - Pause algorithm until circuit breaker lifts
    • exit_all - Exit all positions immediately
    • continue - Continue normal operation
  • Default: pause
  • Example: "pause"

Circuit Breaker Triggers:

  • 10% market movement: 15-minute halt
  • 15% market movement: 45-minute halt
  • 20% market movement: Trading suspended for day

Handling Options:

Pause:

  • Algorithm stops generating signals
  • Existing positions remain open
  • Resumes when circuit breaker lifts

Exit All:

  • Immediately exits all open positions
  • Uses market orders
  • May incur slippage

Continue:

  • Algorithm continues normal operation
  • May not be able to execute during halt
  • Resumes when trading resumes

avoidPreOpen​

  • Type: boolean
  • Required: No
  • Default: true
  • Description: Avoid trading during pre-open session (09:00-09:15)
  • Example: true

Pre-Open Session:

  • 09:00-09:08: Order entry
  • 09:08-09:12: Order matching
  • 09:12-09:15: Buffer period

Risks:

  • High volatility
  • Wide spreads
  • Unpredictable fills
  • Gap openings

sttCalculation​

  • Type: boolean
  • Required: No
  • Default: true
  • Description: Include STT (Securities Transaction Tax) in P&L calculations
  • Example: true

STT Rates:

  • Intraday Equity: 0.025% on sell side
  • Delivery Equity: 0.1% on both sides
  • Futures: 0.01% on sell side
  • Options: 0.05% on sell side (premium)

gstCalculation​

  • Type: boolean
  • Required: No
  • Default: true
  • Description: Include GST (18%) on brokerage and charges
  • Example: true

GST Application:

  • 18% on brokerage
  • 18% on transaction charges
  • 18% on SEBI charges

rmsBuffer​

  • Type: number
  • Required: No
  • Range: 0 to 20
  • Unit: Percentage
  • Default: 5
  • Description: Risk Management System buffer for margin calculations
  • Example: 5

Purpose:

  • Prevents margin shortfall
  • Accounts for intraday volatility
  • Ensures sufficient margin

Calculation:

Required Margin = Base Margin × (1 + rmsBuffer/100)

Complete Examples​

Paper Trading Setup​

{
"mode": "paper",
"exchange": "NSE",
"orderType": "market",
"slippage": 0.1,
"indianMarketSettings": {
"enabled": true,
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
},
"productType": "intraday",
"circuitBreakerHandling": "pause",
"avoidPreOpen": true,
"sttCalculation": true,
"gstCalculation": true,
"rmsBuffer": 5
}
}

Live Trading Setup​

{
"mode": "live",
"exchange": "NSE",
"broker": "AngelOne",
"orderType": "market",
"slippage": 0.1,
"indianMarketSettings": {
"enabled": true,
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
},
"productType": "intraday",
"circuitBreakerHandling": "pause",
"avoidPreOpen": true,
"sttCalculation": true,
"gstCalculation": true,
"rmsBuffer": 5
}
}

Backtesting Setup​

{
"mode": "backtest",
"exchange": "NSE",
"orderType": "market",
"slippage": 0.15,
"indianMarketSettings": {
"enabled": true,
"productType": "intraday",
"sttCalculation": true,
"gstCalculation": true
}
}

Commodity Trading Setup​

{
"mode": "live",
"exchange": "MCX",
"broker": "AngelOne",
"orderType": "limit",
"slippage": 0.2,
"indianMarketSettings": {
"enabled": true,
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
},
"productType": "futures",
"circuitBreakerHandling": "pause",
"sttCalculation": true,
"gstCalculation": true,
"rmsBuffer": 10
}
}

Validation Rules​

General Validation​

  • mode is required
  • exchange is required
  • orderType is required
  • slippage must be between 0 and 5
  • broker is required when mode is 'live'

Indian Market Settings Validation​

  • If enabled is true, all required sub-fields must be present
  • autoSquareOff.minutesBeforeClose must be between 5 and 60
  • productType must be valid for selected exchange
  • rmsBuffer must be between 0 and 20

Mode-Specific Validation​

  • live: Requires broker, valid API credentials
  • paper: No broker required
  • backtest: No broker required, slippage recommended