Paper‑first, AI‑powered, production‑ready.
Clone, configure, and trade — in paper or live — within minutes.
git clone https://github.com/HTANC-AI/htanc-ai-hft.git
cd htanc-ai-hft
cp .env.example .env
docker compose up --buildOpen http://localhost:8000/health – you should see:
{"status": "ok", "mode": "paper", "uptime_seconds": 12}Place your first paper trade:
curl -X POST http://localhost:8000/trade \
-H "Content-Type: application/json" \
-d '{"symbol": "RELIANCE", "qty": 10, "price": 2500}'| Capability | Description | Status |
|---|---|---|
| Paper Trading | Built‑in simulator with configurable slippage, fees, latency, partial fills | ✅ Active |
| Live Trading | Broker adapters for Angel One (primary) and Groww (secondary) | 🔧 Configure |
| Risk Engine | F&O‑aware: position limits, margin checks, drawdown guard, circuit breaker | ✅ Active |
| AI Signals | Pluggable agent framework for technical, ML, and sentiment signals | 🚧 Building |
| Telegram Approvals | Human‑in‑the‑loop trade confirmation via Telegram bot | 🚧 Building |
| Returns Dashboard | REST API for P&L, position heat‑maps, performance metrics | 📊 API Ready |
| MCP Integration | Model Context Protocol servers for AI‑tool interaction | ✅ Configured |
| Backtesting | Historical replay and performance reporting | 🚧 Building |
┌──────────────┐ ┌────────────────┐ ┌──────────────┐
│ Telegram Bot │────▶│ FastAPI App │◀────│ AI Agents │
│ (Approvals) │ │ (Trading API) │ │ (Signals) │
└──────────────┘ └───────┬─────────┘ └──────────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ Paper │ │ Broker │ │ PostgreSQL │
│Simulator │ │ Adapters │ │ + Redis │
│ (Default)│ │(AngelOne)│ │ (Persistence)│
└──────────┘ │ (Groww) │ └──────────────┘
└──────────┘
Trading Modes (set via TRADE_MODE env var):
paper– All orders routed through the built‑in simulator. Default & safest.live– Orders sent to real broker APIs. Requires configured broker credentials.
| Variable | Required | Default | Description |
|---|---|---|---|
TRADE_MODE |
No | paper |
paper or live |
DATABASE_URL |
Yes | – | PostgreSQL connection string |
REDIS_URL |
No | redis://localhost:6379/0 |
Redis for cache/queues |
TELEGRAM_BOT_TOKEN |
No | – | Telegram bot token (approvals) |
TELEGRAM_CHAT_ID |
No | – | Your Telegram chat ID |
ANGELONE_CLIENT_ID |
No* | – | Angel One client ID |
ANGELONE_API_KEY |
No* | – | Angel One API key |
ANGELONE_PASSWORD |
No* | – | Angel One trading password |
ANGELONE_TOTP_KEY |
No* | – | Angel One TOTP secret |
GROWW_CLIENT_ID |
No* | – | Groww client ID |
GROWW_API_KEY |
No* | – | Groww API key |
API_KEY |
No | – | API key for MCP endpoints |
LOG_LEVEL |
No | INFO |
DEBUG, INFO, WARNING, ERROR |
* Required only for live trading with that broker.
- Register at Angel One Smart API
- Generate API key from the developer dashboard
- Fill
ANGELONE_CLIENT_ID,ANGELONE_API_KEY,ANGELONE_PASSWORD,ANGELONE_TOTP_KEYin.env - Set
TRADE_MODE=liveand restart
- Register at Groww API
- Generate API key
- Fill
GROWW_CLIENT_ID,GROWW_API_KEYin.env - Set
TRADE_MODE=liveand restart
This repository ships with pre‑configured MCP servers that let AI coding tools
interact directly with your trading system. See mcp/README.md.
Available MCP endpoints:
/mcp/trade– Place, cancel, query orders/mcp/market– Real‑time & historical market data/mcp/portfolio– Positions, P&L, balances/mcp/signals– AI trading signals/mcp/backtest– Backtest execution & reports
Supported AI tools:
- opencode
- Claude Code (
claude mcp add ...) - Cursor (Settings → MCP Servers)
- VS Code + GitHub Copilot
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Service health & mode |
POST |
/trade |
Place an order |
GET |
/portfolio |
Current positions & P&L |
GET |
/signals |
Latest AI trading signals |
POST |
/backtest |
Run a backtest |
GET |
/backtest/{id} |
Get backtest results |
- Python 3.11+
- Docker & Docker Compose
- uv (recommended) or pip
# Install uv (optional but faster)
pip install uv
# Create virtualenv and install deps
uv venv
uv pip install -r requirements.txt
# Copy env and configure
cp .env.example .env
# Start Postgres & Redis (or use docker for just infra)
docker compose up postgres redis -d
# Run the app
uvicorn app.main:app --reloadpytest -v --cov=appruff check app/ tests/
ruff format app/ tests/ --checkhtanc-ai-hft/
├── app/
│ ├── api/ # HTTP endpoints (trade, health, portfolio)
│ ├── brokers/ # Broker adapters (Angel One, Groww)
│ ├── risk/ # F&O-aware risk engine
│ ├── sim/ # Paper simulator
│ ├── services/ # Orchestrator, Telegram, promotion gate
│ ├── schemas/ # Pydantic request/response models
│ ├── db/ # SQLAlchemy models + migrations
│ ├── agents/ # AI signal agents
│ └── main.py # FastAPI entry point
├── mcp/ # MCP server configurations
├── scripts/ # Helper scripts
├── tests/ # Test suite
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
└── .env.example
MIT – see LICENSE.
Trading involves financial risk. This software is provided for educational and research purposes. Past performance does not guarantee future results. Always test thoroughly in paper mode before using with real funds.