How to Setup Execution Settings
Problem
You need to configure how your algorithm interacts with the market, including execution mode, exchange selection, broker integration, order types, and market-specific settings.
Prerequisites
- Basic algorithm configuration completed (Step 1)
- Position sizing configured (Step 2)
- Entry and exit conditions configured (Steps 3-4)
- Risk parameters configured (Step 5)
Execution Modes
Live Trading
Execute real trades with actual capital through broker integration.
{
"executionSettings": {
"mode": "live"
}
}
Characteristics:
- Real money at risk
- Actual broker orders
- Real market impact
- Transaction costs apply
- Requires broker connection
When to Use:
- After successful paper trading
- Strategy is profitable
- Risk parameters are tested
- Comfortable with capital at risk
Prerequisites:
- Broker account connected
- Sufficient capital
- Strategy backtested
- Paper trading successful
- Risk management in place
Paper Trading
Simulated trading with real market data but no real money.
{
"executionSettings": {
"mode": "paper"
}
}
Characteristics:
- No real money at risk
- Simulated order execution
- Real market data
- No transaction costs (optional)
- No broker required
When to Use:
- Testing new strategies
- Learning the platform
- Validating algorithm logic
- Before going live
- Practicing risk management
Advantages:
- Risk-free testing
- Unlimited capital
- Fast iteration
- No emotional pressure
Limitations:
- No slippage (unless simulated)
- Perfect fills
- No market impact
- May not reflect live conditions
Backtest Mode
Test strategy against historical data.
{
"executionSettings": {
"mode": "backtest"
}
}
Characteristics:
- Historical data only
- Fast execution
- No real-time data
- Statistical analysis
- Performance metrics
When to Use:
- Initial strategy validation
- Parameter optimization
- Historical performance analysis
- Strategy comparison
See How to Run a Backtest for details.
Mode Transition Guidelines
Recommended Path:
-
Backtest (1-2 weeks)
- Validate strategy logic
- Optimize parameters
- Check historical performance
-
Paper Trading (2-4 weeks)
- Test with real-time data
- Verify order execution
- Monitor performance
- Adjust parameters
-
Live Trading (Start small)
- Begin with minimum position sizes
- Gradually increase exposure
- Monitor closely
- Scale up slowly
Exchange Selection
Choose which exchange to trade on.
NSE (National Stock Exchange)
{
"executionSettings": {
"exchange": "NSE"
}
}
Trading Hours:
- Pre-Open: 09:00 - 09:15
- Regular: 09:15 - 15:30
- Post-Close: 15:40 - 16:00
Instruments:
- Equities (stocks)
- Equity derivatives (futures, options)
- Currency derivatives
- Debt securities
Symbol Format:
NSE:RELIANCE
NSE:TCS
NSE:INFY
NSE:NIFTY24DEC24500CE // Options
NSE:NIFTY24DECFUT // Futures
Characteristics:
- Largest exchange in India
- High liquidity
- Wide range of instruments
- Electronic trading
BSE (Bombay Stock Exchange)
{
"executionSettings": {
"exchange": "BSE"
}
}
Trading Hours:
- Pre-Open: 09:00 - 09:15
- Regular: 09:15 - 15:30
- Post-Close: 15:40 - 16:00
Instruments:
- Equities (stocks)
- Equity derivatives
- Currency derivatives
- Debt securities
Symbol Format:
BSE:RELIANCE
BSE:TCS
BSE:SENSEX30
Characteristics:
- Oldest exchange in Asia
- More listed companies than NSE
- Lower liquidity than NSE
- Good for small/mid caps
MCX (Multi Commodity Exchange)
{
"executionSettings": {
"exchange": "MCX"
}
}
Trading Hours:
- Morning: 09:00 - 17:00
- Evening: 17:00 - 23:30 (select commodities)
- Overnight: 23:30 - 11:30 (crude oil)
Instruments:
- Crude oil
- Natural gas
- Gold, silver
- Base metals (copper, zinc, etc.)
- Agricultural commodities
Symbol Format:
MCX:CRUDEOIL25JANFUT
MCX:GOLD25FEBFUT
MCX:SILVER25MARFUT
MCX:NATURALGAS25JANFUT
Characteristics:
- Commodity trading
- Extended hours
- High leverage
- Global price correlation
NCDEX (National Commodity & Derivatives Exchange)
{
"executionSettings": {
"exchange": "NCDEX"
}
}
Trading Hours:
- Regular: 10:00 - 17:00 (most commodities)
- Varies by commodity
Instruments:
- Agricultural commodities
- Spices
- Oilseeds
- Pulses
- Metals
Symbol Format:
NCDEX:SOYBEAN25JANFUT
NCDEX:GUARSEED25FEBFUT
NCDEX:TURMERIC25MARFUT
Characteristics:
- Agricultural focus
- Seasonal patterns
- Weather-dependent
- Lower liquidity than MCX
Broker Selection
Choose which broker to use for order execution.
AngelOne
{
"executionSettings": {
"broker": "AngelOne"
}
}
Features:
- SmartAPI integration
- Real-time market data
- Multiple order types
- Good API documentation
Rate Limits:
- 1 request per second per user
- Burst: 5 requests
- See AngelOne Troubleshooting
Connection Requirements:
- AngelOne account
- API key
- Client ID
- MPIN/Password
Supported Exchanges:
- NSE, BSE, MCX, NCDEX
Zerodha
{
"executionSettings": {
"broker": "Zerodha"
}
}
Features:
- Kite Connect API
- Excellent documentation
- WebSocket support
- Large user base
Rate Limits:
- 3 requests per second
- 200 requests per minute
Connection Requirements:
- Zerodha account
- API key
- API secret
- Request token
Supported Exchanges:
- NSE, BSE, MCX, NCDEX
Upstox
{
"executionSettings": {
"broker": "Upstox"
}
}
Features:
- Modern API
- Good performance
- Competitive pricing
- Mobile-first
Rate Limits:
- 10 requests per second
- 500 requests per minute
Connection Requirements:
- Upstox account
- API key
- API secret
- Access token
Supported Exchanges:
- NSE, BSE, MCX
Dhan
{
"executionSettings": {
"broker": "Dhan"
}
}
Features:
- Modern platform
- Good API
- Options analytics
- Forever free
Rate Limits:
- 5 requests per second
- 300 requests per minute
Connection Requirements:
- Dhan account
- API key
- Client ID
- Access token
Supported Exchanges:
- NSE, BSE, MCX
Broker Comparison
| Feature | AngelOne | Zerodha | Upstox | Dhan |
|---|---|---|---|---|
| Rate Limit | 1/sec | 3/sec | 10/sec | 5/sec |
| API Quality | Good | Excellent | Good | Good |
| Documentation | Good | Excellent | Good | Good |
| Market Share | High | Highest | High | Growing |
| Pricing | Low | Low | Low | Free |
Order Types
Configure how orders are placed in the market.
Market Order
Execute immediately at best available price.
{
"executionSettings": {
"orderType": "market"
}
}
Characteristics:
- Immediate execution
- No price guarantee
- Subject to slippage
- Best for liquid stocks
When to Use:
- High liquidity stocks
- Need immediate execution
- Scalping strategies
- Stop loss exits
Example:
Buy 100 shares of RELIANCE at market price
Current Ask: ₹2,500
Execution: ₹2,500 (or close to it)
Slippage:
- Low liquidity: 0.5-2%
- Medium liquidity: 0.1-0.5%
- High liquidity: 0.01-0.1%
Limit Order
Execute only at specified price or better.
{
"executionSettings": {
"orderType": "limit"
}
}
Characteristics:
- Price guarantee
- May not execute
- No slippage
- Better for illiquid stocks
When to Use:
- Illiquid stocks
- Want specific price
- Swing trading
- Take profit exits
Example:
Buy 100 shares of TCS at ₹3,500 or lower
Current Ask: ₹3,510
Order Status: Pending (waiting for ₹3,500)
Execution Risk:
- May never execute
- Price may move away
- Opportunity cost
Stop Order
Trigger market order when price reaches stop level.
{
"executionSettings": {
"orderType": "stop"
}
}
Characteristics:
- Triggers at stop price
- Executes as market order
- Subject to slippage
- Used for stop losses
When to Use:
- Stop loss orders
- Breakout entries
- Momentum strategies
Example:
Stop Loss: Sell 100 shares if price drops to ₹2,450
Current Price: ₹2,500
Price drops to: ₹2,450
Trigger: Market sell order
Execution: ₹2,448 (slippage)
Stop-Limit Order
Trigger limit order when price reaches stop level.
{
"executionSettings": {
"orderType": "stop_limit"
}
}
Characteristics:
- Triggers at stop price
- Executes as limit order
- Price protection
- May not execute
When to Use:
- Stop loss with price protection
- Volatile markets
- Want to avoid slippage
Example:
Stop: ₹2,450
Limit: ₹2,445
Current Price: ₹2,500
Price drops to: ₹2,450
Trigger: Limit sell order at ₹2,445
Execution: Only if price >= ₹2,445
Risk:
- May not execute if price gaps down
- Could result in larger loss
Order Type Recommendations
| Strategy | Entry | Exit (Profit) | Exit (Loss) |
|---|---|---|---|
| Scalping | Market | Limit | Market |
| Day Trading | Limit | Limit | Stop |
| Swing Trading | Limit | Limit | Stop-Limit |
| Position Trading | Limit | Limit | Stop-Limit |
Slippage Configuration
Estimate slippage for backtesting accuracy.
{
"executionSettings": {
"slippage": 0.1 // 0.1% slippage
}
}
What is Slippage?
Difference between expected price and actual execution price.
Example:
- Expected: ₹500
- Slippage: 0.1%
- Actual: ₹500.50 (buy) or ₹499.50 (sell)
Slippage by Liquidity
| Liquidity | Slippage % | Examples |
|---|---|---|
| Very High | 0.01-0.05% | RELIANCE, TCS, INFY |
| High | 0.05-0.1% | Large caps |
| Medium | 0.1-0.3% | Mid caps |
| Low | 0.3-1% | Small caps |
| Very Low | 1-5% | Penny stocks |
Slippage by Order Type
Market Orders:
{
"slippage": 0.1 // Higher slippage
}
Limit Orders:
{
"slippage": 0.0 // No slippage (price guaranteed)
}
Impact on Backtesting
Without Slippage:
- Unrealistic results
- Over-optimistic performance
- May not work live
With Slippage:
- Realistic results
- Conservative estimates
- Better live performance prediction
Indian Market Settings
Configure India-specific features and regulations.
Enable Indian Market Settings
{
"executionSettings": {
"indianMarketSettings": {
"enabled": true
}
}
}
Auto Square-Off
Mandatory square-off for intraday positions.
{
"executionSettings": {
"indianMarketSettings": {
"enabled": true,
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
}
}
}
}
How It Works:
NSE/BSE:
- Market Close: 15:30
- Square-off Time: 15:15 (15 minutes before)
- All intraday positions closed automatically
MCX:
- Market Close: 23:30
- Square-off Time: 23:15 (15 minutes before)
Example:
Time: 15:10
Open Positions: 3 intraday positions
Action: System starts closing positions
Time: 15:15
Status: All positions closed
Configuration Options:
{
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15, // 5-30 minutes
"orderType": "market" // or "limit"
}
}
Product Type
Specify the type of trading product.
{
"executionSettings": {
"indianMarketSettings": {
"productType": "intraday"
}
}
}
Product Types:
1. Intraday (MIS - Margin Intraday Square-off)
{
"productType": "intraday"
}
Characteristics:
- Higher leverage (5-20x)
- Must close by EOD
- Auto square-off
- Lower margin requirements
Margin:
- Equities: 5-10x leverage
- Futures: 1.5-2x leverage
Use Case:
- Day trading
- Scalping
- Quick profits
2. Delivery (CNC - Cash and Carry)
{
"productType": "delivery"
}
Characteristics:
- Full payment required
- No leverage
- Can hold overnight
- Delivery to demat account
Margin:
- 100% of trade value
Use Case:
- Long-term investing
- Swing trading
- Holding positions
3. BTST (Buy Today Sell Tomorrow)
{
"productType": "btst"
}
Characteristics:
- Buy today, sell next day
- T+1 settlement
- Partial leverage
- No delivery to demat
Margin:
- 50-80% of trade value
Use Case:
- Short-term trading
- Overnight positions
- Quick swings
Rules:
- Minimum holding: 1 day
- Maximum holding: T+1 settlement
- Cannot sell before T+1
4. Futures (NRML - Normal)
{
"productType": "futures"
}
Characteristics:
- Futures contracts
- Leverage (5-10x)
- Can hold till expiry
- Mark-to-market daily
Margin:
- SPAN + Exposure margin
- Typically 10-20% of contract value
Use Case:
- Hedging
- Speculation
- Leverage trading
5. Options (NRML - Normal)
{
"productType": "options"
}
Characteristics:
- Options contracts
- Premium payment (buying)
- Margin requirement (selling)
- Can hold till expiry
Margin:
- Buying: Premium amount
- Selling: SPAN + Exposure margin
Use Case:
- Hedging
- Income generation
- Speculation
Circuit Breaker Handling
Configure behavior during circuit breaker halts.
{
"executionSettings": {
"indianMarketSettings": {
"circuitBreakerHandling": "pause"
}
}
}
Options:
1. Pause
{
"circuitBreakerHandling": "pause"
}
- Pause algorithm
- Keep positions open
- Resume when trading resumes
2. Exit All
{
"circuitBreakerHandling": "exit_all"
}
- Close all positions
- Exit at market price
- Pause algorithm
3. Continue
{
"circuitBreakerHandling": "continue"
}
- Keep algorithm running
- Wait for trading to resume
- Continue normal operation
Circuit Breaker Levels:
| Level | Trigger | Action | Duration |
|---|---|---|---|
| 10% | Index drops 10% | Halt 45 min | Before 1:00 PM |
| 15% | Index drops 15% | Halt 1h 45min | Before 1:00 PM |
| 20% | Index drops 20% | Halt rest of day | Any time |
Avoid Pre-Open Session
Skip the pre-open session (9:00-9:15 AM).
{
"executionSettings": {
"indianMarketSettings": {
"avoidPreOpen": true
}
}
}
Why Avoid:
- High volatility
- Price discovery
- Unpredictable moves
- Wide spreads
Recommendation:
- Enable for most strategies
- Disable for opening range breakouts
STT/GST Calculation
Include Securities Transaction Tax and GST in calculations.
{
"executionSettings": {
"indianMarketSettings": {
"includeTaxes": true,
"sttRate": {
"intraday": 0.025, // 0.025% on sell side
"delivery": 0.1 // 0.1% on both sides
},
"gstRate": 18.0 // 18% on brokerage
}
}
}
STT Rates:
| Product | Buy | Sell |
|---|---|---|
| Intraday Equity | 0% | 0.025% |
| Delivery Equity | 0.1% | 0.1% |
| Futures | 0% | 0.0125% |
| Options (Buy) | 0% | 0% |
| Options (Sell) | 0.05% | 0.05% |
GST:
- 18% on brokerage
- 18% on transaction charges
Example Calculation:
Intraday Trade:
- Buy: ₹1,00,000
- Sell: ₹1,02,000
- Profit: ₹2,000
- STT (0.025% on sell): ₹25.50
- Brokerage: ₹40
- GST (18% on brokerage): ₹7.20
- Net Profit: ₹2,000 - ₹25.50 - ₹40 - ₹7.20 = ₹1,927.30
Complete Execution Settings Examples
Example 1: Paper Trading Setup
{
"executionSettings": {
"mode": "paper",
"exchange": "NSE",
"orderType": "market",
"slippage": 0.1
}
}
Use Case: Testing new strategy risk-free
Example 2: Live Day Trading (NSE)
{
"executionSettings": {
"mode": "live",
"exchange": "NSE",
"broker": "AngelOne",
"orderType": "limit",
"slippage": 0.05,
"indianMarketSettings": {
"enabled": true,
"productType": "intraday",
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
},
"avoidPreOpen": true,
"circuitBreakerHandling": "pause",
"includeTaxes": true
}
}
}
Use Case: Intraday trading on NSE with auto square-off
Example 3: Commodity Trading (MCX)
{
"executionSettings": {
"mode": "live",
"exchange": "MCX",
"broker": "Zerodha",
"orderType": "market",
"slippage": 0.2,
"indianMarketSettings": {
"enabled": true,
"productType": "futures",
"autoSquareOff": {
"enabled": true,
"minutesBeforeClose": 15
},
"circuitBreakerHandling": "exit_all"
}
}
}
Use Case: Commodity futures trading with evening session
Example 4: Swing Trading (Delivery)
{
"executionSettings": {
"mode": "live",
"exchange": "NSE",
"broker": "Upstox",
"orderType": "limit",
"slippage": 0.1,
"indianMarketSettings": {
"enabled": true,
"productType": "delivery",
"autoSquareOff": {
"enabled": false // Can hold overnight
},
"avoidPreOpen": true,
"circuitBreakerHandling": "pause",
"includeTaxes": true
}
}
}
Use Case: Multi-day swing trading with delivery
Verification
After configuring execution settings, verify:
-
Mode is appropriate
- Paper for testing
- Live only after validation
- Backtest for historical analysis
-
Exchange is correct
- Matches your instruments
- Trading hours are suitable
- Liquidity is adequate
-
Broker is connected
- API credentials are valid
- Rate limits are understood
- Connection is stable
-
Order type matches strategy
- Market for speed
- Limit for price control
- Stop for risk management
-
Indian market settings are configured
- Product type is correct
- Auto square-off is enabled (if intraday)
- Taxes are included
Troubleshooting
Broker Connection Failed
Problem: Cannot connect to broker.
Solutions:
- Verify API credentials
- Check broker account status
- Ensure API is enabled
- Check rate limits
- Review broker documentation
Orders Not Executing
Problem: Orders are placed but not executing.
Solutions:
- Check order type (limit may not execute)
- Verify exchange trading hours
- Check circuit breaker status
- Ensure sufficient margin
- Review broker logs
Auto Square-Off Not Working
Problem: Intraday positions not closing.
Solutions:
- Verify autoSquareOff is enabled
- Check minutesBeforeClose setting
- Ensure product type is "intraday"
- Check exchange trading hours
- Review system logs
High Slippage in Live Trading
Problem: Actual slippage exceeds configured value.
Solutions:
- Trade more liquid stocks
- Use limit orders
- Avoid market orders in illiquid stocks
- Trade during high volume periods
- Reduce position sizes
Circuit Breaker Triggered
Problem: Trading halted due to circuit breaker.
Solutions:
- Wait for trading to resume
- Check circuitBreakerHandling setting
- Review positions
- Adjust strategy if needed
- Monitor market conditions