A comprehensive cryptocurrency trading bot implementing the MACD strategy with support for multiple exchanges (OKX, Bybit, MEXC). It features a Telegram bot interface for control and monitoring, and can receive signals via WebHooks or Email.
-
Multi-Exchange Support: OKX, Bybit, MEXC.
-
Trading Strategy: MACD (Moving Average Convergence Divergence).
-
Signal Sources:
- WebHooks: Receive trading signals via HTTP POST requests.
- Email: Parse trading signals from TradingView email alerts.
-
Telegram Bot Interface:
- Start/Stop bot.
- Monitor open positions and PNL.
- Manual trade execution (Long/Short).
- Configuration management (Leverage, Stop-Loss, Take-Profit, etc.).
-
Risk Management:
- Stop-Loss & Take-Profit.
- Trailing Stop (Move-Loss).
- Averaging (DCA) support.
-
Backtesting: Includes a module for backtesting the strategy on historical data.
-
Clone the repository:
git clone https://github.com/yourusername/crypto-trading-bot.git cd crypto-trading-bot -
Install dependencies:
pip install -r requirements.txt
-
Configuration:
- Copy
.env.exampleto.env:cp .env.example .env
- Fill in the
.envfile with your API keys and settings:TELEGRAM_BOT_TOKEN: Your Telegram Bot Token.BOT_PASSWORD: Password to access the bot.ALLOWED_USERS: Comma-separated list of Telegram User IDs allowed to use the bot.OKX_API_KEY,OKX_SECRET_KEY,OKX_PASSPHRASE: Your OKX API credentials.- (Optional) Bybit and MEXC keys if using those exchanges.
- (Optional) Email settings if using Email signals.
- Copy
To start the main Telegram bot with WebHook support:
python main.pyTo start the bot with Email signal processing:
python main_email.py/start: Start the bot and show the main menu./passauth: Authenticate using the password from.env./help: Get help or reset UI.
Configure your TradingView alert to send a POST request to your server's IP/domain:
- URL:
http://your-server-ip:80/signal - Body:
{ "signal": "Buy", "MACD": {{plot("MACD")}}, "Signal": {{plot("Signal Line")}} }
main.py: Entry point for the WebHook-based bot.main_email.py: Entry point for the Email-based bot.Engine/: Core trading logic (WebHook.py,EmailOkx.py).Exchange/: Exchange API wrappers (Okx.py,Bybit.py,Mexc.py).TelBot/: Telegram bot handlers and UI.TehnicalIndicator/: Technical analysis indicators (MACD, EMA, SMA).BackTest/: Backtesting modules.
This software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
MIT License

