gAIn. Terminal Documentation

Welcome to the official documentation for the gAIn. Stock Market Terminal. This platform provides real-time, mathematically calculated trading targets and news for the Indian Stock Market (NSE/BSE).

The Name "gAIn." & The Pivot to Pure Math

The name gAIn. originally stood for the use of AI in predicting stock market. The initial concept was to build a system that utilized Large Language Models — particularly large-context models like the GLM series — to read vast amounts of financial news, parse historical balance sheets, and output trading predictions.

However, during development, a fundamental decision was made: financial predictions ought to be done via strict calculations, not AI hallucinations. Relying on an AI to determine exact entry and stop-loss prices introduced too much unpredictability. Therefore, the AI component was completely stripped out.

There is absolutely NO AI involved in the current system. Every number, target, and trend you see is calculated deterministically using pure, textbook technical analysis math executed via Python and Pandas.

However, I am too lazy to think of a better name, so the old one stays.

Architecture Overview

The application is split into a decoupled Frontend and Backend architecture, allowing for seamless live updates without relying on heavy processing for every tick.

Input Format

You simply type the ticker (e.g., RELIANCE). The system handles the mapping to the correct Yahoo Finance suffix (e.g., .NS). Position sizing based on user capital has been removed to focus purely on signal generation.

The Mathematics (Explained Simply)

All math is calculated natively in Python using Pandas to ensure 100% accuracy. To ensure timeframe consistency, Trade Setup levels (Entry, Stop, Target) are derived from Daily Data (1d), while Momentum and Charts are derived from Intraday Data (5m).

Intraday Math (5-Minute Intervals)

Daily Math (Trade Setup & Long-Term Levels)

Trade Setup, Trend Filters & Risk Management

This system uses strict trend-following principles and macro-filters to avoid systematic traps.

ATR Volatility Envelope (Projections)

Projections use a dynamic bias multiplier derived from the Technical Score. This is a volatility envelope, not a directional price prediction. The math scales Daily ATR by the exact fraction of the trading day remaining (6.25 hours total).

Relative Volatility Gate

The system calculates the 90-day ATR percentile rank.

Rolling OOS Validation (Walk-Forward Backtest)

The system runs a deterministic backtest using a 5-year Train / 1-year Test rolling window. It uses conservative same-day execution assumptions and deducts realistic costs.

Live Market Scan (Tickers to Watch)

Aside from individual ticker analysis, the terminal runs an automated scan based on current price momentum and market trading activity. This is not a direct buy signal, but a watchlist generator.

Data Sources & Fallbacks

⚙️ How It Works (Step-by-Step)

  1. User types a ticker (e.g., RELIANCE) in the terminal.
  2. The Frontend sends a POST request to the FastAPI backend and starts a 2-second polling loop.
  3. The Backend runs the data engine, fetching 5m intraday data, 2y daily data (or Stooq 10y fallback), and Nifty trend.
  4. The Server fetches raw data, runs the Pandas mathematical calculations, applies the trend-following + macro + R:R + ADX filters, and structures it into JSON.
  5. The Backend formats this JSON into a Markdown string with [CHART:...] tags and sends it back.
  6. The Frontend parses the Markdown, renders the text with yellow/green syntax highlights (using Indian comma formatting), and draws the Plotly charts exactly where the tags are placed without resetting zoom levels or jumping your scroll position.
← Back to Terminal