NoobMaster1999/AlgoGPT

AlgoGPT is an open-source LLM model train on Indian Derivative and Equity market data.

Python

1

63 commits

updated Oct 15, 2026

See the code

README

image

AlgoGPT: Open-Source AI Model for Indian Derivatives and Equity Market Data

Python 3.10+ PyTorch 2.0+ Hugging Face pandas 2.0+ scikit-learn Matplotlib License: MIT

AlgoGPT is the first open-source model for financial candlesticks (K-lines). Built with Kronos open-source foundation model. Trained on data from NSE & BSE.

Core Algorithem:

Model Performace:

  • [Version 1.0] April, 2024: Base Model Model Accuracy: 0.43
  • [Version 2.0] October, 2026: Kronos Foundation Engine (NeoQuasar/Kronos-small & Kronos-Tokenizer-base) with continuous BSQ candlestick tokenization, multi-step autoregressive price path generation, and systematic options derivative backtesting with risk metrics (Sharpe Ratio, Alpha, Max Drawdown).

Architecture

algogpt/
├── model/           # Kronos foundation model (tokenizer, model, predictor)
├── data/            # Data fetching & dataset creation for Indian derivatives
├── training/        # Finetuning pipelines (tokenizer + predictor)
├── trading/         # Feature engineering, signals, backtesting
├── main.py          # Main trading pipeline entry point
├── quickstart.py    # Quick test with Yahoo Finance
└── requirements.txt # Dependencies

Quick Start

# Install dependencies
pip install -r requirements.txt

# Run quick test (uses Yahoo Finance for NIFTY daily data)
python quickstart.py

Data Sources

SourceDescriptionSetup
csvLocal CSV files in ./data/Place {SYMBOL}_5min.csv files
yahooYahoo Finance (free, daily/intraday)No setup needed
upstoxUpstox API (live + historical)Requires API credentials
nseNSE via nsepython (daily only)pip install nsepython

Finetuning on Indian Derivatives

1. Prepare Data

# Download NIFTY/BANKNIFTY 5min data to ./data/
# Or use Upstox API with credentials

2. Configure Training

Edit training/config.py or use environment variables:

export SYMBOLS="NIFTY,BANKNIFTY"
export DATA_SOURCE="csv"
export DATA_DIR="./data"
export INTERVAL="5min"
export START_DATE="2020-01-01"
export END_DATE="2024-12-31"
export PREDICTOR_EPOCHS=30
export BATCH_SIZE=50

3. Run Distributed Finetuning

# Tokenizer finetuning (run first)
torchrun --standalone --nproc_per_node=1 training/train_tokenizer.py

# Predictor finetuning (uses finetuned tokenizer)
torchrun --standalone --nproc_per_node=1 training/train_predictor.py

For multi-GPU:

torchrun --standalone --nproc_per_node=4 training/train_predictor.py

4. Use Finetuned Models

from algogpt.model import KronosPredictor

predictor = KronosPredictor.from_local(
    model_path="./outputs/models/finetune_predictor_indian/checkpoints/best_model",
    tokenizer_path="./outputs/models/finetune_tokenizer_indian/checkpoints/best_model",
)

Trading Pipeline

# Basic backtest on NIFTY
python main.py --symbol NIFTY --start 2023-01-01 --end 2024-06-01

# With Upstox data
python main.py --symbol BANKNIFTY --data-source upstox \
  --upstox-api-key YOUR_KEY --upstox-api-secret YOUR_SECRET \
  --upstox-access-token YOUR_TOKEN

# Using finetuned model
python main.py --model ./outputs/models/finetune_predictor_indian/checkpoints/best_model \
  --tokenizer ./outputs/models/finetune_tokenizer_indian/checkpoints/best_model

Key Components

Model (algogpt/model/)

  • KronosTokenizer: Hybrid quantization (BSQ) encoder-decoder
  • Kronos: Autoregressive transformer with hierarchical tokens (s1+s2)
  • KronosPredictor: High-level inference with normalization, sampling, batch prediction

Data (algogpt/data/)

  • DataFetcher: Abstract base + Upstox/NSE/Yahoo/CSV implementations
  • IndianDerivativesDataset: Sliding window dataset with proper normalization
  • create_train_val_datasets: Time-aware train/val split (no lookahead bias)

Training (algogpt/training/)

  • FinetuneConfig: Centralized dataclass config with env overrides
  • train_tokenizer.py: DDP tokenizer finetuning (BSQ loss)
  • train_predictor.py: DDP predictor finetuning (next-token CE loss)
  • utils.py: DDP setup, seeding, checkpointing, Comet logging

Trading (algogpt/trading/)

  • FeatureEngineer: 30+ technical indicators (RSI, MACD, BB, candles, etc.)
  • SignalGenerator: Kronos + TA weighted ensemble with MACD filter
  • KronosBacktester: Walk-forward with realistic execution (next-bar open, slippage, commission)

Indian Derivatives Specifics

SymbolLot SizeExpiryTick Size
NIFTY50Thursday0.05
BANKNIFTY15Wednesday0.05
FINNIFTY40Tuesday0.05
MIDCPNIFTY75Monday0.05

Time features: minute, hour, weekday, day, month (IST timezone)

Configuration

All configs use Python dataclasses with:

  • Type hints and defaults
  • Environment variable overrides (export PARAM=value)
  • Validation in __post_init__
  • Dict-like access for backward compatibility

Requirements

  • Python 3.10+
  • PyTorch 2.0+ (CUDA recommended)
  • 8GB+ VRAM for finetuning (batch_size=50)
  • 16GB+ RAM for data processing

License

MIT License - See LICENSE file for details.

NoobMaster1999/AlgoGPT

AlgoGPT is an open-source LLM model train on Indian Derivative and Equity market data.

Python

1

63 commits

updated Oct 15, 2026

See the code

README

image

AlgoGPT: Open-Source AI Model for Indian Derivatives and Equity Market Data

Python 3.10+ PyTorch 2.0+ Hugging Face pandas 2.0+ scikit-learn Matplotlib License: MIT

AlgoGPT is the first open-source model for financial candlesticks (K-lines). Built with Kronos open-source foundation model. Trained on data from NSE & BSE.

Core Algorithem:

Model Performace:

  • [Version 1.0] April, 2024: Base Model Model Accuracy: 0.43
  • [Version 2.0] October, 2026: Kronos Foundation Engine (NeoQuasar/Kronos-small & Kronos-Tokenizer-base) with continuous BSQ candlestick tokenization, multi-step autoregressive price path generation, and systematic options derivative backtesting with risk metrics (Sharpe Ratio, Alpha, Max Drawdown).

Architecture

algogpt/
├── model/           # Kronos foundation model (tokenizer, model, predictor)
├── data/            # Data fetching & dataset creation for Indian derivatives
├── training/        # Finetuning pipelines (tokenizer + predictor)
├── trading/         # Feature engineering, signals, backtesting
├── main.py          # Main trading pipeline entry point
├── quickstart.py    # Quick test with Yahoo Finance
└── requirements.txt # Dependencies

Quick Start

# Install dependencies
pip install -r requirements.txt

# Run quick test (uses Yahoo Finance for NIFTY daily data)
python quickstart.py

Data Sources

SourceDescriptionSetup
csvLocal CSV files in ./data/Place {SYMBOL}_5min.csv files
yahooYahoo Finance (free, daily/intraday)No setup needed
upstoxUpstox API (live + historical)Requires API credentials
nseNSE via nsepython (daily only)pip install nsepython

Finetuning on Indian Derivatives

1. Prepare Data

# Download NIFTY/BANKNIFTY 5min data to ./data/
# Or use Upstox API with credentials

2. Configure Training

Edit training/config.py or use environment variables:

export SYMBOLS="NIFTY,BANKNIFTY"
export DATA_SOURCE="csv"
export DATA_DIR="./data"
export INTERVAL="5min"
export START_DATE="2020-01-01"
export END_DATE="2024-12-31"
export PREDICTOR_EPOCHS=30
export BATCH_SIZE=50

3. Run Distributed Finetuning

# Tokenizer finetuning (run first)
torchrun --standalone --nproc_per_node=1 training/train_tokenizer.py

# Predictor finetuning (uses finetuned tokenizer)
torchrun --standalone --nproc_per_node=1 training/train_predictor.py

For multi-GPU:

torchrun --standalone --nproc_per_node=4 training/train_predictor.py

4. Use Finetuned Models

from algogpt.model import KronosPredictor

predictor = KronosPredictor.from_local(
    model_path="./outputs/models/finetune_predictor_indian/checkpoints/best_model",
    tokenizer_path="./outputs/models/finetune_tokenizer_indian/checkpoints/best_model",
)

Trading Pipeline

# Basic backtest on NIFTY
python main.py --symbol NIFTY --start 2023-01-01 --end 2024-06-01

# With Upstox data
python main.py --symbol BANKNIFTY --data-source upstox \
  --upstox-api-key YOUR_KEY --upstox-api-secret YOUR_SECRET \
  --upstox-access-token YOUR_TOKEN

# Using finetuned model
python main.py --model ./outputs/models/finetune_predictor_indian/checkpoints/best_model \
  --tokenizer ./outputs/models/finetune_tokenizer_indian/checkpoints/best_model

Key Components

Model (algogpt/model/)

  • KronosTokenizer: Hybrid quantization (BSQ) encoder-decoder
  • Kronos: Autoregressive transformer with hierarchical tokens (s1+s2)
  • KronosPredictor: High-level inference with normalization, sampling, batch prediction

Data (algogpt/data/)

  • DataFetcher: Abstract base + Upstox/NSE/Yahoo/CSV implementations
  • IndianDerivativesDataset: Sliding window dataset with proper normalization
  • create_train_val_datasets: Time-aware train/val split (no lookahead bias)

Training (algogpt/training/)

  • FinetuneConfig: Centralized dataclass config with env overrides
  • train_tokenizer.py: DDP tokenizer finetuning (BSQ loss)
  • train_predictor.py: DDP predictor finetuning (next-token CE loss)
  • utils.py: DDP setup, seeding, checkpointing, Comet logging

Trading (algogpt/trading/)

  • FeatureEngineer: 30+ technical indicators (RSI, MACD, BB, candles, etc.)
  • SignalGenerator: Kronos + TA weighted ensemble with MACD filter
  • KronosBacktester: Walk-forward with realistic execution (next-bar open, slippage, commission)

Indian Derivatives Specifics

SymbolLot SizeExpiryTick Size
NIFTY50Thursday0.05
BANKNIFTY15Wednesday0.05
FINNIFTY40Tuesday0.05
MIDCPNIFTY75Monday0.05

Time features: minute, hour, weekday, day, month (IST timezone)

Configuration

All configs use Python dataclasses with:

  • Type hints and defaults
  • Environment variable overrides (export PARAM=value)
  • Validation in __post_init__
  • Dict-like access for backward compatibility

Requirements

  • Python 3.10+
  • PyTorch 2.0+ (CUDA recommended)
  • 8GB+ VRAM for finetuning (batch_size=50)
  • 16GB+ RAM for data processing

License

MIT License - See LICENSE file for details.