Skip to content

Rors78/turtle-bot

Repository files navigation

🐒 Turtle Bot - Advanced Turtle Trading System

πŸ‡ΊπŸ‡Έ USA Regulatory Compliant

MADE FOR US TRADERS - HARD TO FIND, FULLY COMPLIANT

This bot is specifically designed to meet US regulatory requirements:

  • βœ… SPOT TRADING ONLY (no futures, no derivatives)
  • βœ… LONG POSITIONS ONLY (no shorting)
  • βœ… NO LEVERAGE (100% compliant with US regulations)
  • βœ… US EXCHANGES ONLY (Binance US, Kraken US, ccxt-compatible US exchanges)
  • βœ… Regulatory Compliant for US retail traders

Why this matters: Most trading bots use leverage, futures, or shorting - which creates regulatory issues for US traders. This bot is built from the ground up for US compliance.


A sophisticated cryptocurrency trading bot implementing the famous Turtle Trading Strategy with modern enhancements, real-time web dashboard, and pyramid position management.

✨ Features

Core Trading System

  • Dual System Implementation: System 1 (20-day breakout) and System 2 (55-day breakout)
  • Pyramid Position Management: Scale into positions with up to 4 units
  • Dynamic Stop Loss: ATR-based stop loss management
  • Risk Management: Position sizing based on account equity and volatility
  • State Persistence: Automatic save/load of bot state for resilience

Web Dashboard

  • Real-Time Updates: Live portfolio tracking via WebSocket
  • Glassmorphism Design: Modern, professional UI with animated backgrounds
  • Position Visualization: See all pyramid units, entry prices, and stop losses
  • Bot Thinking Log: Watch the bot's decision-making process in real-time
  • Performance Metrics: Win rate, profit factor, max drawdown, and more
  • Trade History: Complete record of closed positions

Technical Features

  • Exchange Integration: Built-in support for cryptocurrency exchanges
  • JSON State Export: Export bot state for analysis
  • Diagnostic Reports: Comprehensive system diagnostics
  • Configuration Management: Easy-to-modify config.py
  • Blocked Coins List: Avoid problematic trading pairs

πŸš€ Quick Start

Installation

  1. Clone the repository:
git clone https://github.com/Rors78/turtle-bot.git
cd turtle-bot
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure your settings in config.py:
  • Set your exchange API keys
  • Adjust risk parameters
  • Configure trading systems

Running the Bot

Terminal Mode:

python main.py

Web Dashboard:

./launch_dashboard.sh

The dashboard will automatically open at http://localhost:5001

πŸ“Š The Turtle Trading Strategy

The Turtle Trading System is a legendary trend-following strategy developed by Richard Dennis and William Eckhardt in the 1980s. This bot implements:

  • Breakout Entry: Enter when price breaks above/below N-day high/low
  • Pyramid Scaling: Add to winning positions at predetermined intervals
  • ATR-based Stops: Volatility-adjusted stop losses
  • Position Sizing: Risk-based position calculation using N (ATR)

πŸ“ Project Structure

turtle-bot/
β”œβ”€β”€ main.py                   # Main bot entry point
β”œβ”€β”€ config.py                 # Configuration settings
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ launch_dashboard.sh       # Web dashboard launcher
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ position.py          # Position management
β”‚   └── turtle_engine.py     # Core trading logic
β”œβ”€β”€ exchange/
β”‚   └── base.py              # Exchange integration
β”œβ”€β”€ misc/
β”‚   β”œβ”€β”€ strategies.json      # Strategy configurations
β”‚   └── turtlebot-icon.svg   # Bot icon
β”œβ”€β”€ blocked_coins.json       # Coins to avoid
β”œβ”€β”€ export_state_to_json.py  # State export utility
β”œβ”€β”€ DIAGNOSTIC_REPORT.md     # System diagnostics
β”œβ”€β”€ JSON_STATE_README.md     # State format documentation
└── WEB_DASHBOARD_README.md  # Dashboard documentation

🎨 Web Dashboard Features

Real-Time Monitoring

  • Live portfolio value and P&L
  • Active positions with pyramid visualization
  • System 1 and System 2 status
  • Connection status indicator

Performance Analytics

  • Win rate with visual progress bar
  • Profit factor calculation
  • Total trades counter
  • Maximum drawdown tracking

Trading Insights

  • Bot decision log with color-coded severity
  • Entry/exit reasoning
  • Stop loss hits and adjustments
  • Error messages and warnings

βš™οΈ Configuration

Key settings in config.py:

# Trading Parameters
SYSTEM_1_PERIOD = 20  # Short-term breakout
SYSTEM_2_PERIOD = 55  # Long-term breakout
MAX_PYRAMID_UNITS = 4  # Maximum position size
ATR_MULTIPLIER = 2.0   # Stop loss distance

# Risk Management
RISK_PER_TRADE = 0.01  # 1% risk per trade
MAX_POSITIONS = 5       # Maximum concurrent positions

πŸ“ˆ Performance Tracking

The bot automatically tracks:

  • Total P&L (realized and unrealized)
  • Win/Loss ratio
  • Profit factor
  • Maximum drawdown
  • Average trade duration
  • System 1 vs System 2 performance

πŸ”§ Utilities

Export State to JSON

python export_state_to_json.py

Converts bot state to human-readable JSON format.

View Diagnostics

cat DIAGNOSTIC_REPORT.md

Review system health and performance diagnostics.

πŸ›‘οΈ Risk Management

Built-in risk controls:

  • Position size limits based on account equity
  • Maximum concurrent positions
  • ATR-based stop losses
  • Correlation checks (avoid overexposure)
  • Blocked coins list
  • Emergency stop functionality

πŸ“ Documentation

🀝 Contributing

This is a personal trading bot project. Feel free to fork and modify for your own use.

⚠️ Disclaimer

This bot is for educational and research purposes. Cryptocurrency trading carries significant risk. Always test thoroughly in paper trading mode before using real funds. Past performance does not guarantee future results.

πŸ“„ License

This project is provided as-is for personal use and learning.


Built with the legendary Turtle Trading methodology 🐒

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •