Skip to main content
Version: 1.0 (Current)

Risk Parameters Schema

This document provides the complete schema reference for the riskParameters configuration object. Risk parameters define position limits, loss limits, and risk-reward requirements to protect capital.

Overview​

Risk parameters are part of Step 5 of algorithm configuration. They control:

  • Maximum position size per trade
  • Stop loss and take profit percentages
  • Maximum daily loss limits
  • Maximum number of open positions
  • Minimum risk-reward ratio

Schema Structure​

interface RiskParameters {
maxPositionSize: number
stopLoss: number
takeProfit?: number
maxDailyLoss: number
maxOpenPositions: number
riskRewardRatio: number
}

Field Descriptions​

maxPositionSize​

  • Type: number
  • Required: Yes
  • Range: 0.01 to 100
  • Unit: Percentage of account balance
  • Description: Maximum percentage of account that can be allocated to a single position
  • Recommended: 2 to 10
  • Example: 5.0

Purpose: Prevents over-concentration in a single position.

Calculation:

Max Position Value = Account Balance × (maxPositionSize / 100)

Examples:

With ₹100,000 account:

  • maxPositionSize: 5.0 → Maximum ₹5,000 per position
  • maxPositionSize: 10.0 → Maximum ₹10,000 per position

Interaction with Position Sizing:

  • If position sizing method calculates larger size, it's capped at maxPositionSize
  • Acts as a safety limit regardless of sizing method

Risk Profiles:

// Conservative
{
"maxPositionSize": 2.0
}

// Moderate
{
"maxPositionSize": 5.0
}

// Aggressive
{
"maxPositionSize": 10.0
}

stopLoss​

  • Type: number
  • Required: Yes
  • Range: 0.1 to 50
  • Unit: Percentage
  • Description: Required stop loss percentage for risk-based position sizing
  • Recommended: 1 to 5
  • Example: 2.0

Purpose:

  • Used in risk-based position sizing calculations
  • Ensures minimum stop loss is set
  • Validates exit conditions

Usage in Risk-Based Sizing:

Risk Amount = Account Balance × Risk Percentage
Stop Distance = Entry Price × (stopLoss / 100)
Position Size = Risk Amount / Stop Distance

Example:

{
"stopLoss": 2.0
}

With ₹100,000 account, 1.5% risk, ₹500 entry:

  • Risk Amount = ₹100,000 × 1.5% = ₹1,500
  • Stop Distance = ₹500 × 2% = ₹10
  • Position Size = ₹1,500 / ₹10 = 150 shares

Strategy-Specific Recommendations:

  • Scalping: 0.5-1%
  • Day Trading: 1-2%
  • Swing Trading: 2-5%
  • Position Trading: 5-10%

takeProfit​

  • Type: number
  • Required: No
  • Range: 0.1 to 100
  • Unit: Percentage
  • Description: Optional take profit percentage for validation
  • Recommended: 2 to 10
  • Example: 4.0

Purpose:

  • Validates exit conditions have reasonable profit targets
  • Used in risk-reward ratio calculations
  • Ensures profitable strategy design

Example:

{
"takeProfit": 4.0
}

With 2% stop loss and 4% take profit:

  • Risk-Reward Ratio = 4% / 2% = 2:1

Recommended Values:

  • Should be at least equal to stopLoss (1:1 ratio)
  • Typically 2-3x stopLoss for good risk-reward
  • Higher for swing/position trading (5-20%)

maxDailyLoss​

  • Type: number
  • Required: Yes
  • Range: 100 to 10000000
  • Unit: Currency (₹)
  • Description: Maximum loss allowed per day before circuit breaker activates
  • Recommended: 1-5% of account balance
  • Example: 5000

Purpose:

  • Protects against catastrophic losses
  • Prevents emotional trading after losses
  • Implements circuit breaker system

Circuit Breaker Behavior: When daily loss reaches maxDailyLoss:

  1. All active algorithms are paused
  2. No new positions can be opened
  3. Existing positions remain open
  4. Resets at start of next trading day

Calculation:

Daily Loss = Sum of all closed position P&L for the day
If Daily Loss >= maxDailyLoss:
Trigger Circuit Breaker

Example:

{
"maxDailyLoss": 5000
}

With ₹100,000 account:

  • maxDailyLoss: ₹5,000 (5% of account)
  • After losing ₹5,000 in a day, all algorithms pause
  • Can resume trading next day

Risk Profiles:

// Conservative (1-2% of account)
{
"maxDailyLoss": 2000 // ₹100k account
}

// Moderate (3-5% of account)
{
"maxDailyLoss": 5000 // ₹100k account
}

// Aggressive (5-10% of account)
{
"maxDailyLoss": 10000 // ₹100k account
}

Best Practices:

  • Set based on account size (1-5%)
  • Consider trading style (scalpers need lower limits)
  • Account for multiple algorithms running simultaneously
  • Review and adjust based on performance

maxOpenPositions​

  • Type: number
  • Required: Yes
  • Range: 1 to 50
  • Description: Maximum number of positions that can be open simultaneously
  • Recommended: 3 to 10
  • Example: 5

Purpose:

  • Prevents over-trading
  • Manages portfolio concentration
  • Controls margin usage
  • Limits exposure

Behavior:

  • When limit is reached, no new positions can be opened
  • Existing positions can still be closed
  • Limit applies per algorithm (not account-wide)

Example:

{
"maxOpenPositions": 5
}

Algorithm can have maximum 5 positions open at once.

Considerations:

Account Size:

  • Small accounts (< ₹1L): 1-3 positions
  • Medium accounts (₹1L-10L): 3-10 positions
  • Large accounts (> ₹10L): 10-50 positions

Strategy Type:

  • Scalping: 1-3 (quick in/out)
  • Day Trading: 3-5 (active management)
  • Swing Trading: 5-10 (longer holds)
  • Position Trading: 10-20 (diversification)

Margin Requirements:

  • Intraday: Higher leverage, can handle more positions
  • Delivery: Full capital required, fewer positions
  • Futures/Options: Margin-based, moderate positions

Risk Profiles:

// Conservative
{
"maxOpenPositions": 3
}

// Moderate
{
"maxOpenPositions": 5
}

// Aggressive
{
"maxOpenPositions": 10
}

riskRewardRatio​

  • Type: number
  • Required: Yes
  • Range: 1.0 to 10.0
  • Description: Minimum risk-reward ratio required for trades
  • Recommended: 2.0 to 3.0
  • Example: 2.0

Purpose:

  • Ensures profitable strategy design
  • Validates exit conditions
  • Enforces disciplined trading

Calculation:

Risk-Reward Ratio = Potential Profit / Potential Loss
= (Take Profit - Entry) / (Entry - Stop Loss)

Example:

{
"riskRewardRatio": 2.0
}

With ₹500 entry:

  • Stop Loss: ₹490 (₹10 risk)
  • Take Profit: ₹520 (₹20 reward)
  • Ratio: ₹20 / ₹10 = 2:1 ✅

Minimum Win Rate Required:

For break-even (after costs):

Win Rate = 1 / (1 + Risk-Reward Ratio)
Risk-RewardMin Win RateExample
1:150%Need to win half the time
2:133%Need to win 1 in 3 trades
3:125%Need to win 1 in 4 trades
5:117%Need to win 1 in 6 trades

Recommended Ratios:

  • Minimum: 1:1 (break-even after costs)
  • Good: 2:1 or 3:1 (profitable with moderate win rate)
  • Excellent: 5:1+ (profitable with low win rate)

Strategy Considerations:

  • High win rate strategies (60%+): Can use 1:1 or 1.5:1
  • Medium win rate strategies (40-60%): Use 2:1 or 3:1
  • Low win rate strategies (<40%): Use 3:1 or higher

Complete Examples​

Conservative Profile​

{
"maxPositionSize": 2.0,
"stopLoss": 1.0,
"takeProfit": 3.0,
"maxDailyLoss": 2000,
"maxOpenPositions": 3,
"riskRewardRatio": 3.0
}

Characteristics:

  • Small position sizes (2% max)
  • Tight stop loss (1%)
  • High risk-reward (3:1)
  • Low daily loss limit (2% of ₹100k account)
  • Few positions (3 max)
  • Suitable for: Beginners, small accounts, volatile markets

Moderate Profile​

{
"maxPositionSize": 5.0,
"stopLoss": 2.0,
"takeProfit": 4.0,
"maxDailyLoss": 5000,
"maxOpenPositions": 5,
"riskRewardRatio": 2.0
}

Characteristics:

  • Medium position sizes (5% max)
  • Standard stop loss (2%)
  • Good risk-reward (2:1)
  • Moderate daily loss limit (5% of ₹100k account)
  • Moderate positions (5 max)
  • Suitable for: Experienced traders, medium accounts, normal markets

Aggressive Profile​

{
"maxPositionSize": 10.0,
"stopLoss": 3.0,
"takeProfit": 6.0,
"maxDailyLoss": 10000,
"maxOpenPositions": 10,
"riskRewardRatio": 2.0
}

Characteristics:

  • Large position sizes (10% max)
  • Wider stop loss (3%)
  • Standard risk-reward (2:1)
  • High daily loss limit (10% of ₹100k account)
  • Many positions (10 max)
  • Suitable for: Professional traders, large accounts, trending markets

Scalping Profile​

{
"maxPositionSize": 5.0,
"stopLoss": 0.5,
"takeProfit": 1.0,
"maxDailyLoss": 3000,
"maxOpenPositions": 2,
"riskRewardRatio": 2.0
}

Characteristics:

  • Tight stops (0.5%)
  • Quick profits (1%)
  • Low daily loss (3% of ₹100k account)
  • Few positions (2 max, quick turnover)
  • High frequency trading

Swing Trading Profile​

{
"maxPositionSize": 8.0,
"stopLoss": 5.0,
"takeProfit": 15.0,
"maxDailyLoss": 8000,
"maxOpenPositions": 8,
"riskRewardRatio": 3.0
}

Characteristics:

  • Wider stops (5%)
  • Larger profits (15%)
  • Higher daily loss (8% of ₹100k account)
  • More positions (8 max, longer holds)
  • Lower frequency trading

Validation Rules​

General Validation​

  • All required fields must be present
  • All values must be within specified ranges
  • takeProfit should be greater than stopLoss (if specified)

Specific Validations​

maxPositionSize:

  • Must be between 0.01 and 100
  • Should not exceed 20% for most strategies
  • Warning if > 10% (high risk)

stopLoss:

  • Must be between 0.1 and 50
  • Should be appropriate for strategy type
  • Warning if < 0.5% (too tight) or > 10% (too wide)

takeProfit:

  • Must be between 0.1 and 100
  • Should be >= stopLoss for positive risk-reward
  • Warning if < stopLoss (negative risk-reward)

maxDailyLoss:

  • Must be between 100 and 10,000,000
  • Should be 1-10% of account balance
  • Warning if > 10% of account (very aggressive)

maxOpenPositions:

  • Must be between 1 and 50
  • Should consider account size and margin
  • Warning if > 20 (difficult to manage)

riskRewardRatio:

  • Must be between 1.0 and 10.0
  • Should be at least 1.5 for profitability
  • Warning if < 1.5 (requires very high win rate)

Risk Management Best Practices​

1-2% Risk Rule​

Never risk more than 1-2% of account on a single trade:

{
"maxPositionSize": 5.0,
"stopLoss": 2.0
}

With risk-based sizing at 1.5%, actual risk per trade is 1.5%.

Portfolio-Level Risk​

Consider total exposure across all positions:

Total Risk = Number of Positions × Risk Per Position

With 5 positions at 1.5% risk each:

  • Total Risk = 5 × 1.5% = 7.5%

Correlation Considerations​

  • Avoid multiple positions in highly correlated symbols
  • Diversify across sectors and asset classes
  • Monitor portfolio beta and correlation

Circuit Breaker System​

  • maxDailyLoss acts as circuit breaker
  • Prevents emotional trading after losses
  • Allows cool-down period
  • Protects against cascading failures

Position Sizing Hierarchy​

1. Position Sizing Method calculates size
2. maxPositionSize caps the size
3. Risk Parameters validate the trade
4. Margin requirements apply
5. Final position size determined