Skip to content

Trade Engine is an automated trading engine that integrates with the Zerodha Kite API to execute trades, manage orders, and track positions in real time.

License

Notifications You must be signed in to change notification settings

pdk-dev/trade-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trade Engine

Automated trading system with Zerodha Kite integration and Telegram notifications.

Features

  • 📊 Technical analysis (EMA, RSI, MACD, ATR)
  • 🤖 Automated trade recommendations
  • 📱 Telegram notifications and manual control
  • 💾 Persistent state management
  • 📈 Pyramid buying (configurable entries)
  • 🎯 ATR-based stop loss and targets

Project Structure

trade-engine/
├── config.py              # Configuration and credentials
├── trader.py              # Main entry point
├── setup.sh               # Automated setup script
├── src/
│   ├── state_manager.py   # State persistence
│   ├── broker.py          # Zerodha Kite integration
│   ├── telegram_client.py # Telegram bot
│   └── strategy.py        # Technical analysis
├── tests/                 # Unit tests (future)
├── requirements.txt       # Python dependencies
└── README.md

Quick Setup

Option 1: Automated Setup (Recommended)

./setup.sh

This will:

  • Set Python version to 3.13.1
  • Create virtual environment
  • Install all dependencies

Option 2: Manual Setup

1. Create Virtual Environment

uv venv --python 3.13
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

2. Install Dependencies

uv pip install -r requirements.txt

Configuration

1. Edit Credentials

Edit config.py and add your credentials:

# Zerodha
API_KEY = "your_kite_api_key"
ACCESS_TOKEN = "your_access_token"

# Telegram
TELEGRAM_BOT_TOKEN = "your_bot_token"
TELEGRAM_CHAT_ID = "your_chat_id"

Getting Zerodha Credentials:

  1. Sign up at https://kite.trade/
  2. Create an API app at https://developers.kite.trade/
  3. Generate access token using the API key

Getting Telegram Credentials:

  1. Create a bot via @BotFather
  2. Get your chat ID from @userinfobot

2. Customize Parameters (Optional)

Edit config.py to customize:

  • Trading parameters (max buys, product type)
  • Strategy parameters (EMA, RSI, MACD settings)
  • Timing (check intervals)

Running the Trader

python trader.py RELIANCE

Replace RELIANCE with any NSE stock symbol (e.g., TCS, INFY, HDFCBANK).

Telegram Commands

Send these commands via Telegram during trading:

  • BUY - Execute buy order manually
  • SELL - Execute sell order manually
  • STATUS - Check current position

Safety Features

  • Maximum pyramid buys limit
  • ATR-based stop loss calculation
  • State persistence across restarts
  • Error handling and retry logic
  • Manual override via Telegram

Development

Project Workflow

  1. Clone the repo
   git clone <repo-url>
   cd trade-engine
  1. Run setup
   ./setup.sh
  1. Configure credentials in config.py

  2. Start trading

   python trader.py RELIANCE

Adding New Features

  1. Create a new branch
   git checkout -b feature/your-feature
  1. Make changes and test

  2. Commit and push

   git add .
   git commit -m "Add your feature"
   git push origin feature/your-feature
  1. Create Pull Request on GitHub

Running Tests

pytest tests/

Troubleshooting

Virtual environment not activating?

source .venv/bin/activate

Packages not found?

uv pip install -r requirements.txt

Python version issues?

pyenv local 3.13.1

Disclaimer

This is for educational purposes only. Trading involves substantial risk. Always test with paper trading first. The authors are not responsible for any financial losses.

License

MIT License - See LICENSE file for details

About

Trade Engine is an automated trading engine that integrates with the Zerodha Kite API to execute trades, manage orders, and track positions in real time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published