TradingAI transforms any YouTube trading video into a structured, actionable strategy report β and executable trading code β in minutes. Paste a URL: TradingAI downloads the audio, transcribes it locally using OpenAI Whisper (your data never leaves your machine), uses GPT-4o to extract every trading strategy, indicator, risk rule, and algorithm discussed, then automatically generates ready-to-use Pine Script v6 (TradingView) and MetaTrader 5 Python code from the extracted strategies.
Built for traders, analysts, and quant researchers who want to capture insights from hours of trading content β without watching every video.
- π₯ YouTube to report in one click β paste any YouTube URL and get a full strategy report
- ποΈ Local transcription β Whisper runs on your machine, no audio sent to third parties
- π Live transcription progress β real-time progress bar shows % complete while Whisper processes
- π§ AI strategy extraction β GPT-4o extracts strategies, indicators, risk rules and algorithms
- π§© Code generation β auto-generates Pine Script v6 (TradingView) and MT5 Python from every report
- π Export anywhere β download as PDF, Markdown, plain text, Pine Script (.pine) or MT5 (.py)
- π Handles long videos β automatic token-aware chunking for videos of any length
- π Beautiful web UI β React frontend with live progress, GPU/CPU selector, and code tabs
- π₯οΈ CLI support β full pipeline available as a command-line tool
- π³ Docker ready β CPU variant, one command to run on any machine
- π Flexible LLM β works with Azure OpenAI or standard OpenAI API
| Layer | Technology |
|---|---|
| Transcription | OpenAI Whisper (local, GPU or CPU) |
| LLM | Azure OpenAI GPT-4o / OpenAI GPT-4o |
| Audio download | yt-dlp + ffmpeg |
| Backend | FastAPI + Python 3.9+ |
| Frontend | React 18 + Vite |
| Containerisation | Docker + docker-compose |
| Token counting | tiktoken |
| Code generation | Pine Script v6 + MetaTrader 5 Python |
| Progress tracking | Chunked Whisper transcription with callbacks |
YouTube URL
β
βΌ
βββββββββββββββββββ
β downloader.py β Downloads audio-only via yt-dlp + ffmpeg
ββββββββββ¬βββββββββ
β
βΌ
ββββββββββββββββββββ
β transcriber.py β Transcribes locally with Whisper (GPU/CPU)
β β Live progress bar β shows % complete in UI + logs
ββββββββββ¬ββββββββββ
β
βΌ
βββββββββββββββββββ
β chunker.py β Counts tokens β splits into chunks if too long
ββββββββββ¬βββββββββ
β
βΌ
ββββββββββββββββββββββββββββ
β strategy_extractor.py β Sends to GPT-4o β extracts strategies,
β β indicators, risk rules, algorithms
ββββββββββ¬ββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββ
β code_generator.py β Generates Pine Script v6 (TradingView)
β β and Python MT5 code from strategies
ββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β reporter.py β Formats and saves the final report
βββββββββββββββββββ
trading_app/
βββ backend/
β βββ app.py # FastAPI server + SSE streaming
β βββ main.py # CLI entry point
β βββ config.py # Config loader (.env β constants)
β βββ logger.py # Logging setup (console + file)
β βββ requirements.txt # Core dependencies
β βββ requirements_web.txt # Web/API dependencies
β βββ modules/
β βββ downloader.py # yt-dlp audio download
β βββ transcriber.py # Whisper transcription (with live progress %)
β βββ chunker.py # Token counting + smart chunking
β βββ strategy_extractor.py # GPT-4o strategy extraction
β βββ code_generator.py # Pine Script v6 + MT5 Python generation
β βββ reporter.py # Report formatting + saving
βββ frontend/
β βββ src/ # React 18 + Vite source
βββ docker/
β βββ Dockerfile # CPU Docker image
β βββ docker-compose.yml # CPU compose config
βββ start.py # One-command launcher (builds frontend + starts server)
βββ .env.example # Environment variable template
βββ README.md
TradingAI supports two LLM providers. Set LLM_PROVIDER in your .env to choose:
LLM_PROVIDER=azure
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your_azure_key_here
AZURE_OPENAI_API_VERSION=2024-02-01
AZURE_DEPLOYMENT_NAME=gpt-4oLLM_PROVIDER=openai
OPENAI_API_KEY=sk-your-openai-key-here
OPENAI_MODEL=gpt-4oNot sure which to use? Standard OpenAI is simpler to set up. Azure OpenAI is better for enterprise/team use with compliance requirements.
No Python, Node.js, or ffmpeg setup needed. Just Docker.
- Docker Desktop installed and running
- Your LLM credentials (Azure OpenAI or standard OpenAI)
git clone https://github.com/your-username/trading_strategy_extractor.git
cd trading_strategy_extractor
cp .env.example .env
# Open .env and fill in your credentialsdocker compose -f docker/docker-compose.yml up --buildhttp://localhost:8000
First build takes 3β5 minutes. Subsequent starts are instant.
| Command | Description |
|---|---|
docker compose -f docker/docker-compose.yml up --build |
First run |
docker compose -f docker/docker-compose.yml up |
Start (no rebuild) |
docker compose -f docker/docker-compose.yml down |
Stop the app |
docker compose -f docker/docker-compose.yml logs -f |
View live logs |
- Python 3.9+
- FFmpeg
- CUDA GPU (optional but recommended for Whisper speed)
- Azure OpenAI or OpenAI API credentials
# 1. Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS / Linux
# 2. Install PyTorch (with CUDA β check your version with nvidia-smi)
pip install torch --index-url https://download.pytorch.org/whl/cu118 # CUDA 11.8
pip install torch --index-url https://download.pytorch.org/whl/cu121 # CUDA 12.1
pip install torch # CPU only
# 3. Install dependencies
pip install -r backend/requirements.txt
# 4. Set up environment
cp .env.example .env
# Fill in your credentialspip install -r backend/requirements_web.txt
python start.py
# Open http://localhost:8000| Variable | Required | Default | Description |
|---|---|---|---|
LLM_PROVIDER |
Yes | azure |
azure or openai |
AZURE_OPENAI_ENDPOINT |
If azure | β | Azure OpenAI endpoint URL |
AZURE_OPENAI_API_KEY |
If azure | β | Azure OpenAI API key |
AZURE_OPENAI_API_VERSION |
If azure | 2024-02-01 |
Azure API version |
AZURE_DEPLOYMENT_NAME |
If azure | gpt-4o |
GPT-4o deployment name |
OPENAI_API_KEY |
If openai | β | OpenAI API key (sk-...) |
OPENAI_MODEL |
If openai | gpt-4o |
OpenAI model name |
WHISPER_MODEL |
No | small |
tiny / base / small / medium / large |
WHISPER_DEVICE |
No | cpu |
cuda or cpu |
LOG_LEVEL |
No | DEBUG |
DEBUG / INFO / WARNING / ERROR |
MAX_TOKENS_SAFE |
No | 60000 |
Token limit before chunking kicks in |
CHUNK_OVERLAP_WORDS |
No | 200 |
Overlap words between chunks |
YTDLP_COOKIES_FILE |
No | β | Path to cookies.txt for authenticated downloads |
YouTube may require authentication to download some videos. If you see a "Sign in to confirm you're not a bot" error:
- Install the "Get cookies.txt LOCALLY" Chrome extension
- Go to youtube.com while logged in to your Google account
- Click the extension and export cookies as
cookies.txt - Place
cookies.txtin the project root folder - Add to your
.envfile:YTDLP_COOKIES_FILE=cookies.txt
Note:
cookies.txtis gitignored and should never be committed to version control as it contains your session credentials.
| Model | Size | VRAM | Speed | Recommended for |
|---|---|---|---|---|
| tiny | 75 MB | ~1 GB | fastest | quick tests |
| base | 145 MB | ~1 GB | fast | short videos |
| small | 465 MB | ~2 GB | good | default (4 GB GPU) |
| medium | 1.5 GB | ~5 GB | better | longer/complex content |
| large | 3 GB | ~10 GB | best | maximum accuracy |
Docker CPU mode uses
smallby default. Change viaWHISPER_MODELin.env.
Token checking and chunking happen automatically β no manual steps needed.
| Video length | Approx tokens | Behaviour |
|---|---|---|
| Under ~5 hours | Under 60,000 | Single pass β full transcript sent to GPT-4o |
| Over ~5 hours | Over 60,000 | Auto-split β MAP phase β REDUCE phase β merged report |
chunker.pycounts tokens usingtiktokenwith GPT-4o'scl100k_baseencoding- If within limit β single pass, normal flow
- If over limit β split into overlapping chunks β extract strategies per chunk (MAP) β merge and deduplicate (REDUCE)
# Test the chunker on any saved transcript
python backend/modules/chunker.py ./outputs/test_transcript.txtAfter extracting strategies, TradingAI automatically generates executable trading code in three formats β ready to use in real trading platforms.
- Ready to paste directly into TradingView's Pine Script Editor
- Implements entry/exit conditions, indicators, stop loss and take profit
- Uses Pine Script v6 syntax with built-in
ta.*functions - How to use:
- Open TradingView
- Go to Pine Script Editor
- Click "New Script"
- Paste the generated code
- Click "Add to chart"
- Runs natively inside MetaTrader 5 β no Python or external software needed
- Complete Expert Advisor (.mq5) with
OnInit(),OnDeinit(),OnTick()handlers - Uses MT5's built-in indicator functions (
iMA,iRSI,iATR, etc.) - Input parameters configurable directly from the MT5 interface
- How to use:
- Download the .mq5 file
- Open MetaTrader 5 β File β Open Data Folder
- Place file in
MQL5/Experts/folder - In MT5 Navigator β Expert Advisors β right-click β Refresh
- Double-click the EA to attach to a chart
- Enable "Allow Algo Trading" in MT5 settings
- Python script that connects to MT5 externally via the
MetaTrader5library - MT5 must be open and running on your machine
- More flexible for custom data processing and ML integration
- Prerequisite:
pip install MetaTrader5
| MQL5 | Python MT5 | |
|---|---|---|
| Runs inside MT5 | β Native | β External |
| Requires Python | β No | β Yes |
| Best for | Pure trading automation | Custom logic + ML |
| Recommended for | Most traders | Quant developers |
All three formats are available in the web UI as tabs:
[ Strategy Report ] [ Pine Script ] [ MQL5 (MT5) ] [ MT5 Python ]
Each tab has:
- Syntax-highlighted code block (github-dark theme)
- Copy button β copies code to clipboard instantly
- Download button β saves as
.pine,.mq5, or.pyfile
python backend/modules/code_generator.py ./outputs/test_transcript.txtThis generates and saves:
./outputs/test_pine_script.pine./outputs/test_expert_advisor.mq5./outputs/test_mt5_strategy.py
- URL bar β paste any YouTube URL, select CPU or GPU (CUDA), click Generate
- Left panel β live pipeline steps with animated status indicators, real-time transcription progress bar (updates every ~10% as Whisper processes), then video info card, token consumption card with progress bar, and stats grid (words, tokens, API calls, total time)
- Right panel β four tabs when report is ready:
- Strategy Report β fully formatted markdown report with section headers
- Pine Script β syntax-highlighted Pine Script v6 code with Copy + Download
- MQL5 (MT5) β Native MetaTrader 5 Expert Advisor with Copy + Download
- MT5 Python β syntax-highlighted MetaTrader 5 Python code with Copy + Download
- Download buttons β TXT Β· MD Β· PDF Β· Pine Script (.pine) Β· MQL5 (.mq5) Β· MT5 Python (.py)
# Full pipeline
python backend/main.py "https://www.youtube.com/watch?v=EXAMPLE"
# Transcription only (skip LLM)
python backend/main.py "https://youtube.com/watch?v=EXAMPLE" --transcript-only
# Override Whisper model
python backend/main.py "https://youtube.com/watch?v=EXAMPLE" --whisper-model base
# Verbose debug logging
python backend/main.py "https://youtube.com/watch?v=EXAMPLE" --log-level DEBUG
# Test individual modules
python backend/modules/downloader.py "https://youtube.com/watch?v=EXAMPLE"
python backend/modules/transcriber.py ./temp/audio.mp3
python backend/modules/strategy_extractor.py ./outputs/test_transcript.txt
python backend/modules/reporter.py
# Test code generator independently
python backend/modules/code_generator.py ./outputs/test_transcript.txt
# Test strategy extractor independently
python backend/modules/strategy_extractor.py ./outputs/test_transcript.txtReports saved to ./outputs/ as {title}_{timestamp}.txt:
================================================
TRADING STRATEGY REPORT
================================================
Source Video : Video Title Here
Channel : Channel Name
Duration : 28m 24s
Transcript : 6,732 words
Generated : 2026-04-06 14:22:00
Tokens Used : 8,738
================================================
[extracted strategies]
================================================
END OF REPORT
================================================
CUDA / GPU issues
- "CUDA not available" β Whisper falls back to CPU automatically. Check CUDA with
nvidia-smi. - GPU out of memory β Use a smaller model:
--whisper-model tinyorbase - torch not found β Use the CUDA-specific pip install command above
yt-dlp / ffmpeg errors
- "Video unavailable" β Video may be private, age-restricted, or region-blocked
- "ffmpeg not found" β Install FFmpeg and add its
bin/folder to your system PATH - "Sign in to confirm you're not a bot" β See the YouTube Authentication section above
Token / chunking issues
- A
WARNINGis logged automatically when transcript exceeds safe token limit - Chunking is fully automatic β no manual steps needed
- Use
python backend/modules/chunker.py ./outputs/transcript.txtto inspect token counts
Missing .env values
- A clear
ValueErroris raised if required credentials are missing - Check your
.envfile is in the project root (not inside a subfolder) - Make sure
LLM_PROVIDERmatches the credentials you have filled in
Pine Script or MT5 code not generating
- Check that your LLM API key is valid and has remaining quota
- Code generation makes 2 additional API calls after strategy extraction
- If code tabs appear empty, check the logs for
code_generatorerrors - Test independently:
python backend/modules/code_generator.py ./outputs/test_transcript.txt
- If the transcript is very short (under 100 words), the LLM may not generate meaningful code β try with a longer video
MQL5 Expert Advisor not compiling in MetaTrader 5
- Open MetaTrader 5 β Tools β MetaEditor (or press F4)
- Open the .mq5 file in MetaEditor
- Press F7 to compile β check the Errors tab for issues
- Common fix: make sure
#include <Trade\Trade.mqh>is available (comes with standard MT5 installation) - If you see "CTrade" errors, the Trade library may need to be enabled in MetaEditor's Include paths
- The generated EA is a starting template β you may need to adjust lot sizes and broker-specific settings
Transcription progress shows 0% or does not update
- Progress updates every ~10% as each audio chunk is processed
- Short videos (under 2 minutes) may complete too fast to see progress
- Check logs for
[DEBUG] Transcription progress:lines to confirm it is working - If using GPU (CUDA), transcription is faster and progress updates may flash briefly
- Try with a longer video (5+ minutes) to see progress updates clearly
Pull requests are welcome! For major changes please open an issue first.
- Fork the repo
- Create a feature branch:
git checkout -b feature/your-feature - Commit:
git commit -m "add your feature" - Push:
git push origin feature/your-feature - Open a Pull Request
