Skip to main content
Glama

Luno MCP Server

README.md12.9 kB
# 🚀 XBTMYR Trading Bot **Advanced Cryptocurrency Trading Automation for Bitcoin/Malaysian Ringgit (XBTMYR) on Luno Exchange** This is a standalone, production-ready trading bot that uses sophisticated technical analysis and risk management to automate XBTMYR trading decisions. Built with comprehensive safety features and a beautiful web dashboard for real-time monitoring. ## 🌟 Why This Bot? Based on comprehensive market analysis showing XBTMYR in a consolidation phase (455K-465K MYR), this bot implements: - **Smart Signal Detection** - Waits for clear breakout signals rather than trading in uncertainty - **Risk-First Approach** - Maximum 2% position sizes with automatic stop losses - **Professional Grade** - Enterprise-level code quality with comprehensive monitoring - **Safety Focused** - Defaults to simulation mode with multiple protection layers ## ⚡ Quick Start (30 seconds) ```bash # 1. Setup everything automatically ./setup.sh # 2. Add your Luno API credentials nano .env # 3. Test the installation python3 test_bot.py # 4. Run in simulation mode python3 run_bot.py --dry-run # 5. View dashboard open http://localhost:5000 ``` ## ✨ Key Features ### 🔍 Advanced Technical Analysis - **RSI (14-period)** - Momentum analysis for entry/exit timing - **EMA 9/21 Crossover** - Trend direction and momentum signals - **MACD Analysis** - Convergence/divergence for trend confirmation - **Bollinger Bands** - Volatility measurement and price levels - **Volume Confirmation** - Ensures price moves are backed by volume - **Support/Resistance** - Key levels: 455K/465K/475K MYR ### 💼 Professional Risk Management - **Position Sizing** - Maximum 2% of portfolio per trade - **Stop Loss Orders** - Automatic 1.5% stop loss protection - **Take Profit Targets** - 3% profit-taking levels - **Daily Trade Limits** - Maximum 3 trades per day - **Portfolio Monitoring** - Real-time balance and P&L tracking ### 🌐 Beautiful Web Dashboard - **Real-time Monitoring** - Live price feeds and bot status - **Interactive Charts** - 7-day price history with technical indicators - **Trade History** - Complete log of all bot decisions and rationale - **Portfolio Overview** - Current balances and performance metrics - **Performance Analytics** - Win rate, P&L, and risk metrics ### 🛡️ Multiple Safety Layers - **Dry Run Default** - Always starts in simulation mode - **API Security** - Secure credential management - **Error Recovery** - Robust error handling and auto-recovery - **Emergency Stop** - Manual override and graceful shutdown - **Comprehensive Logging** - Complete audit trail of all activities ## 📊 Current Market Analysis Integration The bot implements trading signals based on real XBTMYR market analysis: ### Current Conditions (Live Integration) - **Price Range**: 455,000 - 465,000 MYR (consolidation) - **Signal**: WAIT (mixed technical indicators) - **Volume**: Above average (28.99 BTC vs 25.63 average) - **Trend**: Bearish bias with 60% probability ### Signal Triggers - **STRONG BUY**: Break above 465K with volume + bullish convergence - **STRONG SELL**: Break below 455K with volume + bearish convergence - **WAIT**: Current consolidation phase (recommended approach) ## 🎯 Trading Strategy ### Entry Conditions (All must be met) **Buy Signals:** - Price breaks resistance (465K+) with strong volume - RSI not overbought (< 70) - EMA bullish crossover (9 > 21) - MACD bullish (line > signal) - Volume > 120% of average **Sell Signals:** - Price breaks support (455K-) with strong volume - RSI not oversold (> 30) - EMA bearish crossover (9 < 21) - MACD bearish (line < signal) - Volume > 120% of average ### Risk Management (Automatic) - **Stop Loss**: 1.5% from entry price - **Take Profit**: 3% from entry price - **Position Size**: 2% of total portfolio - **Max Daily Trades**: 3 trades - **Cool-down Period**: 1 hour between trades ## 🚀 Installation & Setup ### System Requirements - **Python**: 3.8 or higher - **Memory**: 2GB RAM minimum - **Network**: Stable internet connection - **Account**: Luno account with API access ### Automated Setup ```bash # Clone or download the bot files cd xbtmyr-trading-bot # Run automated setup ./setup.sh # This will: # - Check Python installation # - Install all dependencies # - Create configuration files # - Set up the environment # - Run tests to verify installation ``` ### Manual Setup ```bash # Install dependencies pip3 install -r requirements.txt # Copy environment template cp .env.example .env # Edit with your API credentials nano .env ``` ### Configuration Add your Luno API credentials to `.env`: ```env LUNO_API_KEY=your_api_key_here LUNO_API_SECRET=your_api_secret_here DRY_RUN=true MAX_POSITION_SIZE_PERCENT=2.0 STOP_LOSS_PERCENT=1.5 TAKE_PROFIT_PERCENT=3.0 ``` ## 🎮 Usage Examples ### Basic Commands ```bash # Test installation python3 test_bot.py # Run in simulation mode (recommended) python3 run_bot.py --dry-run # Run bot only (no dashboard) python3 run_bot.py --bot-only --dry-run # Run dashboard only (monitoring) python3 run_bot.py --dashboard-only # Live trading (REAL MONEY - use carefully!) python3 run_bot.py --live ``` ### Advanced Configuration ```bash # Custom position size (1% instead of 2%) python3 run_bot.py --dry-run --max-position-size 1.0 # Tighter stop loss (1% instead of 1.5%) python3 run_bot.py --dry-run --stop-loss 1.0 # More aggressive take profit (5% instead of 3%) python3 run_bot.py --dry-run --take-profit 5.0 # Different check interval (30 seconds instead of 60) python3 run_bot.py --dry-run --check-interval 30 # Custom dashboard port python3 run_bot.py --dashboard-port 8080 ``` ## 📊 Monitoring & Performance ### Web Dashboard (http://localhost:5000) - **Bot Status**: Real-time operational status - **Market Data**: Live XBTMYR price and volume - **Technical Indicators**: RSI, EMA, MACD, Bollinger Bands - **Trade History**: All bot decisions with rationale - **Portfolio Performance**: P&L, win rate, risk metrics - **Interactive Charts**: Price movements with indicator overlays ### Log Files - **trading_bot.log**: Complete bot activity log - **trading_report_*.json**: Detailed performance reports - **Error logs**: Automatic error tracking and recovery ### Key Metrics to Monitor - **Win Rate**: Aim for >60% success rate - **Risk per Trade**: Should never exceed configured % - **Daily Activity**: Monitor trade frequency - **Drawdown**: Maximum loss from peak - **Sharpe Ratio**: Risk-adjusted returns ## ⚠️ Safety & Risk Management ### Pre-Trading Checklist - [ ] ✅ Tested in dry-run mode for at least 1 week - [ ] ✅ Verified API credentials work correctly - [ ] ✅ Understood all risk management settings - [ ] ✅ Set appropriate position sizes (start with 0.5-1%) - [ ] ✅ Monitored bot behavior and signals - [ ] ✅ Have emergency stop procedure ready - [ ] ✅ Only using money you can afford to lose ### Risk Warnings **🚨 IMPORTANT DISCLAIMERS:** - **High Risk**: Cryptocurrency trading involves substantial risk of loss - **No Guarantees**: Past performance does not predict future results - **Educational Purpose**: This bot is provided for learning and research - **User Responsibility**: You are responsible for all trading decisions - **Start Small**: Begin with tiny positions and scale gradually ### Emergency Procedures ```bash # Stop the bot immediately Ctrl+C (in terminal) # Cancel all open orders (if live trading) # The bot automatically cancels orders on shutdown # Check current positions python3 -c "from luno_client import LunoAPIClient; print('Check Luno web interface')" ``` ## 🔧 Customization & Development ### Adding New Indicators 1. Modify `technical_analysis.py` 2. Add calculation method to `TechnicalAnalyzer` class 3. Update signal generation in `generate_signals()` 4. Test with dry run mode ### Modifying Trading Strategy 1. Edit signal conditions in `TechnicalAnalyzer.generate_signals()` 2. Adjust confidence thresholds and requirements 3. Update risk management parameters in `config.py` 4. Test thoroughly in simulation mode ### Dashboard Customization 1. Modify HTML template in `templates/dashboard.html` 2. Add new API endpoints in `web_dashboard.py` 3. Update chart configurations and styling 4. Add new monitoring widgets or metrics ## 📁 Project Structure ``` xbtmyr-trading-bot/ ├── 📄 README.md # This comprehensive guide ├── 📄 QUICK_START.md # 30-second setup guide ├── ⚙️ config.py # Trading configuration and settings ├── 📊 technical_analysis.py # Advanced technical analysis engine ├── 🔌 luno_client.py # Luno API client and portfolio management ├── 🤖 trading_bot.py # Main trading bot engine (410 lines) ├── 🌐 web_dashboard.py # Flask web dashboard with real-time monitoring ├── 🚀 run_bot.py # Intelligent launcher with multiple run modes ├── 🧪 test_bot.py # Comprehensive test suite ├── 🔧 setup.sh # Automated setup script ├── 📦 requirements.txt # Python dependencies ├── ⚙️ .env.example # Environment configuration template └── 📁 templates/ # Dashboard HTML templates └── 🎨 dashboard.html # Beautiful responsive dashboard ``` ## 🆘 Troubleshooting ### Common Issues #### Bot Won't Start ```bash # Check Python version python3 --version # Reinstall dependencies pip3 install -r requirements.txt # Check API credentials grep LUNO_API .env # View error logs tail -f trading_bot.log ``` #### Dashboard Not Loading ```bash # Check if port is in use lsof -i :5000 # Try different port python3 run_bot.py --dashboard-port 5001 # Check for errors python3 web_dashboard.py ``` #### API Connection Issues - Verify Luno API credentials in dashboard - Check API key permissions (needs trading access) - Ensure stable internet connection - Check Luno API status page #### No Trading Signals - Market may be in consolidation (this is normal) - Check technical indicators in dashboard - Verify volume requirements are met - Consider adjusting confidence thresholds ### Getting Help 1. **Read the logs**: Most issues are explained in `trading_bot.log` 2. **Check the dashboard**: Visual indicators show bot status 3. **Run tests**: `python3 test_bot.py` diagnoses setup issues 4. **Start simple**: Use dry-run mode to isolate problems 5. **Verify config**: Ensure all settings are appropriate ## 📈 Performance Expectations ### Realistic Expectations - **Win Rate**: 55-70% in favorable market conditions - **Monthly Returns**: 2-8% in typical markets (highly variable) - **Drawdown**: Expect 5-15% temporary losses - **Trade Frequency**: 1-5 trades per week depending on volatility ### Factors Affecting Performance - **Market Conditions**: Trending markets vs sideways consolidation - **Volatility**: Higher volatility = more opportunities but higher risk - **Volume**: Low volume periods may have fewer signals - **Configuration**: Position sizes and risk settings impact returns ## 🔮 Future Enhancements ### Planned Features - **Multiple Timeframes**: 5m, 15m, 1h, 4h analysis - **Additional Pairs**: ETHZAR, ADAZAR support - **Advanced Orders**: OCO (One-Cancels-Other) orders - **Backtesting**: Historical strategy validation - **Mobile App**: iOS/Android monitoring app - **Telegram Bot**: Real-time notifications - **Machine Learning**: AI-enhanced signal generation ### Contributing This is currently a standalone educational project. Feedback and suggestions are welcome for improving the bot's educational value and safety features. ## 📄 License & Disclaimer ### Educational Use This software is provided for educational and research purposes only. It demonstrates cryptocurrency trading concepts and technical analysis implementation. ### Risk Acknowledgment - **No Financial Advice**: This bot does not provide financial advice - **Use at Own Risk**: All trading decisions and consequences are your responsibility - **No Warranties**: Software provided "as-is" without guarantees - **Educational Purpose**: Intended for learning about trading automation ### Legal Notice Users are responsible for compliance with local financial regulations and tax obligations. Cryptocurrency trading may be restricted or regulated in your jurisdiction. --- ## 🎯 Ready to Start? 1. **🔧 Setup**: Run `./setup.sh` 2. **⚙️ Configure**: Edit `.env` with your API credentials 3. **🧪 Test**: Run `python3 test_bot.py` 4. **🚀 Launch**: Run `python3 run_bot.py --dry-run` 5. **📊 Monitor**: Open http://localhost:5000 **Remember: Start with simulation mode and small positions. Trade responsibly!** 💰🛡️ --- *Built with ❤️ for the cryptocurrency trading community. Trade smart, trade safe!*

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/amanasmuei/mcp-luno'

If you have feedback or need assistance with the MCP directory API, please join our Discord server