Skip to main content
This section documents price performance metrics that track returns across various timeframes and measure distance from key price levels.

Period Returns

1 Day Returns(%)
number
Percentage change in price over the past 1 trading day.Example: 2.30Source: Dhan API technical snapshotExtraction:
stock_analysis["1 Day Returns(%)"] = get_float(tech.get("PPerchange", 0))
Location: bulk_market_analyzer.py:334Interpretation:
  • Positive: Stock gained today
  • Negative: Stock declined today
  • Large moves (>5%) may indicate news/events
1 Week Returns(%)
number
Percentage change in price over the past 1 week (5 trading days).Example: 5.80Source: Dhan API technical snapshotExtraction:
stock_analysis["1 Week Returns(%)"] = get_float(tech.get("PricePerchng1week", 0))
Location: bulk_market_analyzer.py:335Use Case: Short-term momentum screening
1 Month Returns(%)
number
Percentage change in price over the past 1 month (~22 trading days).Example: 12.40Source: Dhan API technical snapshotExtraction:
stock_analysis["1 Month Returns(%)"] = get_float(tech.get("PricePerchng1mon", 0))
Location: bulk_market_analyzer.py:336Use Case: Medium-term trend identification
3 Month Returns(%)
number
Percentage change in price over the past 3 months (~63 trading days).Example: 28.60Source: Dhan API technical snapshotExtraction:
stock_analysis["3 Month Returns(%)"] = get_float(tech.get("PricePerchng3mon", 0))
Location: bulk_market_analyzer.py:337Use Case: Quarterly performance tracking
6 Month Returns(%)
number
Percentage change in price over the past 6 months (~126 trading days).Example: 45.20Source: Calculated from OHLCV historical dataCalculation:
price_6m_ago = df['Close'].iloc[-126] if len(df) >= 126 else df['Close'].iloc[0]
returns_6m = ((latest['Close'] - price_6m_ago) / price_6m_ago) * 100
Location: advanced_metrics_processor.py:53-55, 96Precision: Rounded to 2 decimal placesNote: Requires OHLCV data; defaults to 0.0 if unavailable
1 Year Returns(%)
number
Percentage change in price over the past 1 year (~252 trading days).Example: 78.90Source: Dhan API technical snapshotExtraction:
stock_analysis["1 Year Returns(%)"] = get_float(tech.get("PricePerchng1year", 0))
Location: bulk_market_analyzer.py:338Use Case: Annual performance comparison

52-Week Benchmarks

% from 52W High
number
Percentage distance from 52-week high.Calculation:
high_52w = get_float(tech.get("High1Yr", 0))
pct_from_52w_high = 0.0
if high_52w > 0 and ltp > 0:
    pct_from_52w_high = ((ltp - high_52w) / high_52w) * 100
Example: -8.50 (stock is 8.5% below its 52-week high)Location: bulk_market_analyzer.py:198-201, 254Precision: Rounded to 2 decimal placesInterpretation:
  • 0%: Stock at 52-week high (potential breakout or resistance)
  • -5% to -10%: Near highs (strong momentum)
  • -20% to -30%: Moderate correction
  • < -40%: Deep correction (potential value opportunity or structural issue)
% from 52W Low
number
Percentage distance from 52-week low.Calculation:
low_52w = df['Low'].tail(252).min()
pct_from_52w_low = ((latest['Close'] - low_52w) / low_52w) * 100 if low_52w > 0 else 0
Example: 85.30 (stock is 85.3% above its 52-week low)Source: Calculated from OHLCV historical dataLocation: advanced_metrics_processor.py:57-59, 97Precision: Rounded to 2 decimal placesInterpretation:
  • 0% to 10%: Near lows (potential reversal or further downside)
  • 10% to 30%: Recovery phase
  • 50%+: Strong recovery from lows
  • > 100%: More than doubled from 52-week low

All-Time High Benchmark

% from ATH
number
Percentage distance from All-Time High.Calculation:
ath = df['High'].max()
pct_from_ath = ((ath - latest['Close']) / ath) * 100 if ath > 0 else 0

# Hybrid fix: Use live LTP if available
live_ltp = pd.to_numeric(stock.get("Ltp"), errors='coerce')
if pd.notnull(live_ltp) and live_ltp > 0:
    ath = metrics.get("ATH_Value", 0)
    if ath > 0:
        metrics["% from ATH"] = round(((ath - live_ltp) / ath) * 100, 2)
Example: 12.80 (stock is 12.8% below its all-time high)Source: Calculated from complete OHLCV historical dataLocation: advanced_metrics_processor.py:37-39, 92, 146-151Precision: Rounded to 2 decimal placesNote: Uses live LTP to eliminate 1-day lag when availableInterpretation:
  • 0%: Stock at all-time high (momentum/breakout)
  • < 10%: Near ATH (strong long-term trend)
  • 10% to 30%: Moderate pullback from peak
  • > 50%: Significant decline from peak

Intraday Metrics

Gap Up %
number
Percentage gap between today’s open and previous day’s close.Calculation:
gap_up_pct = ((latest['Open'] - prev['Close']) / prev['Close']) * 100 if prev['Close'] > 0 else 0
Example: 2.80 (stock opened 2.8% higher than yesterday’s close)Source: Calculated from OHLCV dataLocation: advanced_metrics_processor.py:42, 94Precision: Rounded to 2 decimal placesInterpretation:
  • Positive: Gap up (bullish opening, possible news/results)
  • Negative: Gap down (bearish opening)
  • > 5%: Significant gap (investigate catalyst)
Note: Initially set to 0.0 in bulk_market_analyzer.py:340, later updated by advanced_metrics_processor.py
Day Range(%)
number
Intraday high-low spread as a percentage of the low.Calculation:
day_range_pct = ((latest['High'] - latest['Low']) / latest['Low']) * 100 if latest['Low'] > 0 else 0
Example: 3.50 (today’s high is 3.5% above today’s low)Source: Calculated from OHLCV dataLocation: advanced_metrics_processor.py:43, 95Precision: Rounded to 2 decimal placesInterpretation:
  • < 2%: Low volatility day
  • 2% to 5%: Normal range
  • 5% to 10%: High volatility
  • > 10%: Extreme volatility (possible news/event)
Related Fields: Compare with ADR (Average Daily Range) fields for context

Data Sources

  1. Dhan API Technical Snapshot (tech): 1D/1W/1M/3M/1Y returns, 52W high
  2. OHLCV CSV Data (ohlcv_data/*.csv): 6M returns, % from 52W low, % from ATH, Gap Up %, Day Range %
  3. Hybrid Approach: Live LTP from master data used to eliminate lag in ATH calculation

Calculation Notes

  • All percentage calculations use the formula: ((current - base) / base) * 100
  • Negative values for ”% from High/ATH” indicate price is below the benchmark
  • Positive values for ”% from Low” indicate price is above the benchmark
  • OHLCV-dependent fields default to 0.0 if historical data is unavailable
  • Safe division with zero-check prevents calculation errors

Source Code Reference

  • Dhan API fields: bulk_market_analyzer.py:198-201, 334-340
  • OHLCV calculations: advanced_metrics_processor.py:37-59, 92-97
  • Hybrid ATH fix: advanced_metrics_processor.py:146-151
  • Output schema: all_stocks_fundamental_analysis.json

Build docs developers (and LLMs) love