Skip to content

akwsa/advanced_crypto_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Advanced Crypto Trading Bot

Python Telegram Indodax AI

Trading bot canggih untuk cryptocurrency exchange Indodax dengan integrasi Machine Learning, AI enhancement (Claude API), dan auto-trading. Bot ini menggunakan analisis teknikal multi-timeframe, ML models V3/V4, dan AI reasoning untuk menghasilkan signal trading berkualitas tinggi.


✨ Fitur Utama

πŸ“Š Signal Generation

  • Technical Analysis: RSI, MACD, Bollinger Bands, ATR, ADX, Volume analysis
  • Multi-Timeframe: 1m, 5m, 15m, 1h untuk analisis komprehensif
  • ML Models: 3 versi ML model (V2, V3 dengan backtesting, V4 trade outcome-based)
  • AI Enhancement: Integrasi Claude API untuk reasoning & confidence adjustment
  • Signal Quality Engine: Scoring 0-100 dengan risk/reward validation
  • Support/Resistance Detection: Automatic S/R level detection

πŸ’Ή Auto-Trading

  • Auto Buy/Sell: Eksekusi otomatis berdasarkan signal berkualitas tinggi
  • Risk Management: Portfolio exposure limit, position sizing, max concurrent positions
  • Market Regime Detection: Trending/Ranging/Volatile/Choppy detection
  • Auto-Sell Monitoring: Take profit, stop loss, trailing stop automation
  • Dry-Run Mode: Simulasi trading tanpa risiko

🎯 Specialized Modules

  • Scalper Module: High-frequency trading untuk profit 0.5-2%
  • Smart Hunter: Momentum hunting untuk low-cap coins (target 3-5%)
  • Ultra Hunter: Aggressive hunting untuk extreme opportunities (target 5-10%)

πŸ€– Telegram Integration

  • 93 Commands: Lengkap untuk monitoring, trading, dan management
  • Inline Keyboards: Interactive UI untuk quick actions
  • Real-time Notifications: Signal alerts, trade confirmations, portfolio updates
  • Notification Filters: BUY-only, SELL-only, actionable, atau all signals

πŸ’Ύ Infrastructure

  • Redis Caching: Price cache, state management, task queue
  • SQLite Database: Signals, trades, positions, performance metrics
  • Background Workers: Async workers, price polling, signal queue
  • WebSocket: Real-time price updates dari Indodax

πŸ“š Dokumentasi Canonical

Untuk navigasi codebase yang efisien, ikuti layered read approach:

Layer 1: System Overview

πŸ“„ SYSTEM_MAP.md - Module index, dependencies, entry points

  • Baca ini PERTAMA untuk memahami arsitektur
  • Indeks lengkap semua modul (core, analysis, autotrade, signals, dll)
  • Dependencies tree & critical paths
  • Quick navigation commands

Layer 2: Operations & Flow

πŸ“„ OPERATIONS_FLOW_ALGORITHMA.md - Runtime flows & algorithms

  • Startup sequence detail
  • Signal generation pipeline (8 steps)
  • Auto-trading flow dengan validation gates
  • Market regime detection
  • Test policy per modul

Layer 3: Command Reference

πŸ“„ COMMAND_REFERENCE.md - Telegram commands & callbacks

  • Complete reference 93 commands
  • Organized by category (signals, trading, portfolio, dll)
  • Callback handlers & inline keyboards
  • Error handling policies

Layer 4: Coding Standards

πŸ“„ DOCUMENTATION_RULES.md - Code quality & best practices

  • Mandatory file header format
  • Docstring standards
  • Naming conventions
  • Error handling & logging
  • Git commit message format
  • Anti-patterns to avoid

Layer 5: Specific Code

Setelah baca 4 layer di atas, baru baca kode spesifik yang dibutuhkan:

# Cari fungsi/class dengan grep
grep -rn "class SignalEnhancementEngine" advanced_crypto_bot/

# Read snippet Β±20 baris di sekitar target
# Jangan read full file besar!

πŸš€ Quick Start

1. Prerequisites

# Python 3.9+
python3 --version

# Redis server
redis-server --version

# TA-Lib (for technical indicators)
# Install dari source atau package manager

2. Installation

# Clone repository
git clone https://github.com/akwsa/advanced_crypto_bot.git
cd advanced_crypto_bot

# Install dependencies
pip install -r requirements.txt

# Setup TA-Lib (jika belum)
# Ubuntu/Debian:
sudo apt-get install ta-lib
# macOS:
brew install ta-lib

3. Configuration

# Copy .env.example ke .env
cp .env.example .env

# Edit .env dengan API keys Anda:
# - TELEGRAM_BOT_TOKEN (dari @BotFather)
# - INDODAX_API_KEY & INDODAX_SECRET_KEY
# - ANTHROPIC_API_KEY (Claude API)
# - REDIS_HOST & REDIS_PORT

4. Run Bot

# Start Redis (terminal 1)
redis-server

# Start bot (terminal 2)
cd advanced_crypto_bot
python3 bot.py

5. Telegram Setup

1. Buka Telegram, cari bot Anda
2. /start - Mulai bot
3. /watch btcidr - Watch Bitcoin
4. /signal btcidr - Generate signal
5. /help - Lihat semua commands

πŸ“– Usage Examples

Basic Signal Generation

/watch btcidr ethidr dogebidr
/signals
β†’ Bot akan generate signals untuk semua watched pairs

Auto-Trading Setup

/add_autotrade btcidr
/list_autotrade
/start_trading
β†’ Bot akan auto-trade untuk pairs yang ditambahkan

Notification Filters

/notif_buy
β†’ Hanya notif BUY signals (filter SELL & HOLD)

/notif_status
β†’ Cek notification settings

Portfolio & Performance

/balance
β†’ Cek saldo Indodax

/portfolio
β†’ Lihat holdings

/performance
β†’ P&L, win rate, total trades

Scalper Module

/s_menu
β†’ Scalper main menu

/s_analisa btcidr
β†’ Analisa scalping opportunity

/s_posisi
β†’ Lihat scalp positions

πŸ—οΈ Architecture

advanced_crypto_bot/
β”œβ”€β”€ πŸ”§ core/              # Config, Database, Logger, Utils
β”œβ”€β”€ πŸ“Š analysis/          # Technical Analysis, ML Models (V2/V3/V4)
β”œβ”€β”€ πŸ’Ή autotrade/         # Trading Engine, Risk Manager, Portfolio
β”œβ”€β”€ 🎯 autohunter/        # Smart & Ultra Profit Hunters
β”œβ”€β”€ ⚑ scalper/           # Scalping Module
β”œβ”€β”€ πŸ“‘ signals/           # Signal Pipeline, Quality Engine, Formatter
β”œβ”€β”€ πŸ”Œ api/               # Indodax API, WebSocket
β”œβ”€β”€ πŸ’Ύ cache/             # Redis Price Cache, State Manager
β”œβ”€β”€ πŸ‘· workers/           # Background Workers, Price Poller
β”œβ”€β”€ πŸ€– bot_parts/         # Telegram UI, Charts, Formatting
β”œβ”€β”€ πŸ§ͺ tests/             # Unit & Integration Tests
└── πŸ“ˆ monitoring/        # Runtime Observers

Entry Point: bot.py (AdvancedCryptoBot class)

Key Flows:

  1. Signal: Price Update β†’ Signal Pipeline β†’ TA + ML + AI β†’ Quality Check β†’ Telegram
  2. Trading: Signal β†’ Risk Validation β†’ Market Regime Check β†’ Order Execution β†’ Portfolio Update
  3. Auto-Sell: Position Monitor β†’ P&L Check β†’ TP/SL Trigger β†’ Sell Order β†’ DB Update

πŸ§ͺ Testing

# Test specific module
pytest tests/test_scalper_dryrun_positions.py -v

# Test signal pipeline
pytest tests/test_v4_integration.py -v

# Test safety
pytest tests/test_dryrun_safety.py -v

# Full test suite
pytest tests/ -v --cov=advanced_crypto_bot

Test Policy: Lihat OPERATIONS_FLOW_ALGORITHMA.md β†’ Test Policy section


βš™οΈ Configuration

Environment Variables (.env)

# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token

# Indodax API
INDODAX_API_KEY=your_api_key
INDODAX_SECRET_KEY=your_secret_key

# Claude API (AI Enhancement)
ANTHROPIC_API_KEY=your_anthropic_key

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# Trading Parameters
MIN_CONFIDENCE=0.55
MIN_QUALITY_SCORE=60
MAX_POSITIONS=3
RISK_PER_TRADE=0.10

Trading Rules (Phases)

  • Phase 1: Baseline rules & reject filters β†’ PHASE1_BASELINE_AND_REJECT_RULES.md
  • Phase 2: Advanced rule implementation β†’ PHASE2_RULE_IMPLEMENTATION_SPEC.md

πŸ”’ Security

⚠️ PENTING:

  • JANGAN commit .env ke Git (sudah ada di .gitignore)
  • JANGAN share API keys di public
  • Gunakan dry-run mode untuk testing sebelum live trading
  • Set position limits sesuai risk tolerance
  • Monitor portfolio secara berkala

πŸ“Š Performance

Signal Quality:

  • Confidence threshold: 55%+
  • Quality score: 60-100
  • Risk/Reward ratio: >1.5
  • AI enhancement: Claude API reasoning

Auto-Trading:

  • Max exposure: 30% per trade
  • Max concurrent positions: 3
  • Default risk: 10% of capital
  • Take profit: Dynamic based on volatility
  • Stop loss: Based on S/R levels

Scalper:

  • Target profit: 0.5-2%
  • Stop loss: <0.5%
  • Timeframe: <5 min
  • High volume requirement

πŸ› οΈ Development

Code Navigation Workflow

# 1. Baca SYSTEM_MAP.md
cat SYSTEM_MAP.md

# 2. Grep untuk lokasi kode
grep -rn "class TradingEngine" advanced_crypto_bot/

# 3. Read snippet (jangan full file!)
# Gunakan offset untuk read Β±20 baris saja

# 4. Edit dengan patch kecil
# Gunakan edit tool, jangan rewrite full file

# 5. Test fokus (bukan full suite)
pytest tests/test_<module>.py

# 6. Update docs canonical jika perlu

Git Workflow

# Format commit message (lihat DOCUMENTATION_RULES.md)
git commit -m "feat: add new feature

Description...

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"

πŸ“ˆ Roadmap

  • Technical Analysis (TA-Lib)
  • ML Models V2/V3/V4
  • AI Enhancement (Claude API)
  • Auto-Trading Engine
  • Risk Management
  • Scalper Module
  • Hunter Modules (Smart & Ultra)
  • Telegram Bot (93 commands)
  • Redis Caching
  • Signal Quality Engine
  • Web Dashboard (TMA)
  • Backtesting UI
  • Multi-exchange support
  • Advanced ML models (V5 dengan deep learning)
  • Portfolio rebalancing automation

🀝 Contributing

Contributions welcome! Please:

  1. Read DOCUMENTATION_RULES.md untuk coding standards
  2. Buat branch: git checkout -b feature/nama-fitur
  3. Commit dengan format yang benar
  4. Update docs canonical jika perlu
  5. Submit PR dengan deskripsi jelas

πŸ“„ License

MIT License - See LICENSE file


πŸ™ Credits

  • TA-Lib: Technical analysis library
  • Python Telegram Bot: Telegram bot framework
  • Anthropic Claude: AI enhancement
  • Indodax: Indonesian crypto exchange
  • Redis: Caching & state management

⚠️ Disclaimer

TRADING CRYPTOCURRENCY MEMILIKI RISIKO TINGGI!

Bot ini disediakan "as-is" tanpa warranty. Gunakan dengan risiko Anda sendiri:

  • Hanya trade dengan uang yang sanggup Anda kehilangan
  • Selalu gunakan dry-run mode untuk testing
  • Set position limits yang konservatif
  • Monitor portfolio secara aktif
  • Pahami risiko market volatility

Author tidak bertanggung jawab atas kerugian trading.


πŸ“ž Support


Happy Trading! πŸš€πŸ“ˆ

Built with ❀️ using Python, ML, and AI

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors