Skip to content

chandewardnyanesh/nse-momentum-swing-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 NSE Swing Bot v2

A fully automated NSE Breakout + Momentum Swing Trading Bot with:

  • 🔍 5 pattern detectors (VCP, Bull Flag, 52W High, Ascending Triangle, Double Bottom)
  • 📊 100-point momentum scoring (EMA stack, RSI, ADX, Volume, ATR compression)
  • 🛡️ ATR-based SL/T1/T2 with automatic trailing stop
  • 📱 Telegram alerts for every signal, entry, and exit
  • 🌐 Live dashboard at http://localhost:8888
  • 🧪 Walk-forward backtester with full performance stats
  • 📈 NSE Options OI filter (PCR, Max Pain, Delta/Gamma)

🚀 Quick Start

# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/nse-swing-bot.git
cd nse-swing-bot

# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Configure (edit config.py)
#    - Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID (optional)
#    - Adjust CAPITAL, risk params, universe as needed

# 5. Run the bot
python3 trading_bot.py

Open http://localhost:8888 for the live dashboard.


📁 Project Structure

nse-swing-bot/
├── trading_bot.py      # Main bot: scanner + positions + alerts + server
├── backtester.py       # Walk-forward historical backtest engine
├── options_filter.py   # NSE option chain: PCR, Max Pain, greeks
├── config.py           # All configuration in one place
├── dashboard.html      # Live dark-themed dashboard (6 tabs)
├── requirements.txt
├── .gitignore
└── bot_data/           # Auto-created: logs, JSON state, dashboard data
    ├── bot.log
    ├── positions.json
    ├── signals.json
    ├── trades.json
    ├── dashboard.json
    ├── backtest_results.json
    └── options_data.json

⚙️ Configuration (config.py)

Parameter Default Description
CAPITAL ₹5,00,000 Virtual paper capital
RISK_PER_TRADE 1% Risk per trade (position sizing)
MAX_POSITIONS 10 Max concurrent open positions
MIN_SCORE 65 Minimum momentum score to enter
MIN_RSI / MAX_RSI 50 / 78 RSI filter range
MIN_ADX 20 Minimum trend strength
ATR_SL_MULT 1.5× Stop-loss = entry − 1.5×ATR
ATR_T1_MULT 2.5× Target 1 = entry + 2.5×ATR
ATR_T2_MULT 4.0× Target 2 = entry + 4×ATR
TRAIL_TRIGGER 5% Start trailing after +5% gain
TRAIL_FACTOR 60% Trail at 60% of move from entry

📱 Telegram Setup

  1. Create a bot via @BotFather → get BOT_TOKEN
  2. Get your chat ID via @userinfobot
  3. In config.py:
    TELEGRAM_ENABLED   = True
    TELEGRAM_BOT_TOKEN = "7123456789:AAF..."
    TELEGRAM_CHAT_ID   = "123456789"

🧪 Backtester

python3 backtester.py              # 1-year backtest on full universe
python3 backtester.py --period 2y  # extend to 2 years
python3 backtester.py --sym RELIANCE  # single stock

Results are saved to bot_data/backtest_results.json and shown in the dashboard's Backtest tab.


📈 Options Filter

python3 options_filter.py          # NIFTY option chain
python3 options_filter.py --sym BANKNIFTY

Fetches live NSE data (no login), computes PCR, Max Pain, OI buildup and ATM greeks (Delta, Gamma, Theta, Vega). Enable the filter in config.py with OPTIONS_ENABLED = True.


🗓️ Schedule

Time (IST) Action
09:20 Morning scan — detect signals, enter positions
15:25 EOD check — update prices, check exits, Telegram summary

⚠️ Disclaimer

This is a paper trading simulation for educational purposes only. No real orders are placed. Past backtested performance does not guarantee future results. Always do your own research before investing real capital.


📜 License

MIT License — free to use, modify, and distribute.

About

Automated NSE breakout + momentum swing trading bot — 5 patterns, 100-pt scoring, ATR exits, Telegram alerts, live dashboard & backtester. v2→US→Crypto roadmap.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors