Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Trade नीति - AI Powered Backtesting for NEPSE

Tradeनीति is an AI-powered backtesting platform for NEPSE retail traders. Users describe strategies in plain language, and Tradeनीति converts them into executable Python code to run secure, sandboxed backtests on NEPSE historical OHLCV data.

🎥 Demo Video

hackathon.final.demo.1.mp4

✨ Key Highlights

  • 📝 Plain-language strategy input — no coding required
  • 🤖 LLM-driven Python strategy generation and parsing
  • 🐳 Secure sandboxed execution using Docker (network-disabled, resource-limited)
  • 📊 NEPSE-specific cleaned OHLCV historical data
  • 📈 Standard performance metrics: Total Return, Sharpe Ratio, Max Drawdown, Equity Curve

❓ Why Tradeनीति

Retail traders often rely on intuition for strategy evaluation. Tradeनीति replaces guesswork with data-driven validation, providing:

  • An accessible frontend for strategy description
  • AI-generated, executable trading logic
  • Safe, NEPSE-tailored backtesting

🏗 System Overview

High-level flow:

  1. Frontend: user inputs a plain-language strategy.
  2. Backend: sends the prompt to an LLM/graph workflow to generate Python code.
  3. Executor: AI-generated code runs inside an isolated Docker container with strict resource and network restrictions.
  4. Backtest: Backtrader (with Pandas) executes the strategy on cleaned NEPSE CSV data.
  5. Results: metrics and equity curve are returned to the frontend.

🛠 Tech Stack

Python FastAPI React Vite Docker Pandas Backtrader


📂 Important Files

  • Backend entry: backend/app/main.py
  • AI & executor endpoints: backend/app/routers/ai_services.py
  • Prompts & generation helpers: backend/app/routers/prompts.py
  • Executor Docker image: backend/Dockerfile.executor
  • Build scripts: build_executor.sh, build_executor.bat
  • NEPSE data: data/cleaned_data/
  • Frontend entry: frontend/src/main.jsx
  • UI components: frontend/src/App.jsx, ChatAssistant.jsx, CodeTab.jsx, ResultsTab.jsx

🔒 Security & Sandboxing

  • All AI-generated code runs inside Docker containers, never on host.
  • Containers are network-disabled and resource-limited.
  • Processes run as non-root, with read-only mounts where possible.
  • No access to host environment variables.

This ensures safe and auditable experimentation.


⚡ Getting Started (Local Development)

Prerequisites

  • Python 3.10+
  • Docker
  • Node.js (LTS)
  • Git

Clone Repository

git clone https://github.com/Uknowme-h/TradeSight
cd tradeSight

Backend Setup

Create and activate virtual environment

python -m venv .venv
source .venv/bin/activate

Install dependencies

pip install -r backend/requirements.txt
Run FastAPI (development)
uvicorn app.main:app --reload --app-dir backend/app
API docs: http://127.0.0.1:8000/docs

Build Executor Image

./build_executor.sh    # Linux/macOS
build_executor.bat     # Windows

Frontend Setup

cd frontend
npm install
npm run dev

Open the dev server URL printed by Vite (usually http://localhost:5173).

🧩 Example Workflow

User input: “Buy when price closes above the 50‑day SMA; sell when it closes below.”

Tradeनीति: Converts the text into Python strategy code → Runs sandboxed backtest → Returns metrics + equity curve.

📊 Metrics Explained

Total Return — net portfolio growth over backtest

Sharpe Ratio — risk-adjusted performance

Maximum Drawdown — largest peak-to-trough loss

Equity Curve — portfolio value over time

🏆 Tradeनीति Flow

Plain-language → executable code conversion (AI workflow)

Safe, sandboxed execution

NEPSE-tailored dataset usage

Interactive UI for strategy refinement

🔮 Roadmap / Future Enhancements

Parameter optimization & grid search

Walk-forward analysis & paper trading

Portfolio-level backtesting & multi-asset strategies

Visual strategy builder

Live market integration

📄 License

This repository is a hackathon project....

About

TradeSight (Tradeनीति) is an AI-powered backtesting platform for NEPSE retail traders that converts plain-language trading strategies into executable Python, runs them in a secure, sandboxed Docker environment, and returns performance metrics and equity curves using NEPSE historical OHLCV data.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages