{"id":51042240,"url":"https://github.com/iyeque/traider","last_synced_at":"2026-06-22T11:32:58.997Z","repository":{"id":297826001,"uuid":"989401884","full_name":"iyeque/traider","owner":"iyeque","description":"AI-Powered Crypto Trading Bot for Binance — Combines RSI, breakout detection, grid laddering, and real-time news sentiment filtering. Includes a backtester and live Streamlit dashboard.","archived":false,"fork":false,"pushed_at":"2025-07-30T01:36:14.000Z","size":65,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-30T03:53:00.357Z","etag":null,"topics":["ai-trading","algorithmic-trading","backtesting","binance-api","crypto-trading-bot","python-bot","quantitative-trading","streamlit-dashboard"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iyeque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T03:04:05.000Z","updated_at":"2025-07-30T01:36:17.000Z","dependencies_parsed_at":"2025-08-04T10:18:19.538Z","dependency_job_id":null,"html_url":"https://github.com/iyeque/traider","commit_stats":null,"previous_names":["iyeque/traider"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iyeque/traider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyeque%2Ftraider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyeque%2Ftraider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyeque%2Ftraider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyeque%2Ftraider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iyeque","download_url":"https://codeload.github.com/iyeque/traider/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyeque%2Ftraider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34647748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-trading","algorithmic-trading","backtesting","binance-api","crypto-trading-bot","python-bot","quantitative-trading","streamlit-dashboard"],"created_at":"2026-06-22T11:32:58.844Z","updated_at":"2026-06-22T11:32:58.989Z","avatar_url":"https://github.com/iyeque.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Traider\n\n## 🧠 Overview\n\nTraider is an automated crypto trading bot for Binance, built around a dynamic, risk-managed hybrid strategy. It features a robust PnL tracking system, persistent trade logging, and a powerful analysis toolkit.\n\n- **Dynamic Strategy Selection:** Switches between breakout and grid trading based on market volatility (ATR).\n- **Active Position Monitoring:** A background service actively monitors placed orders to track the entire lifecycle of a trade.\n- **Automated PnL Calculation:** Automatically calculates and logs the realized Profit \u0026 Loss for every completed trade.\n- **Persistent Trade Logging:** Saves a detailed history of all live and testnet trades to `live_trades.csv` and `testnet_trades.csv`.\n- **In-depth Analysis:** Comes with a script to analyze your trade logs and generate detailed performance reports.\n- **Multi-Currency Support:** The provided Docker Compose setup allows for running separate, optimized bot instances for multiple trading pairs simultaneously.\n- **Enhanced Backtesting:** Features realistic backtesting with dynamic slippage, latency simulation, and exchange constraints.\n- **Parameter Optimization:** Automated parameter optimization using Optuna to find the most profitable strategy configurations.\n- **Sentiment Analysis Integration:** Deep sentiment integration for more informed trading decisions based on market sentiment.\n - **Live Sentiment \u0026 Safety Gate:** Real-time sentiment from CryptoPanic, NewsAPI, RSS, plus Fear \u0026 Greed Index to gate trades.\n\n---\n\n## 📦 Features\n\n- Binance API live and testnet trading support\n- **Persistent CSV Trade Logging**\n- **Automated PnL Calculation \u0026 Performance Analysis**\n- **Active Order Monitoring \u0026 Position Management**\n- Dynamic strategy selection using ATR\n- Breakout and grid trading strategies\n- **Advanced Sentiment Analysis** for risk management and position sizing\n- **Realistic Backtesting Engine** with dynamic slippage, latency simulation, and exchange constraints\n- **Parameter Optimization** with Optuna, including walk-forward validation\n- **Historical Data Acquisition** for sentiment and price data\n- **Bollinger Bands** integration for enhanced signal generation\n- **Comprehensive Performance Metrics** for strategy evaluation\n\n---\n\n## ⚙️ Installation\n\n1.  Clone the repo:\n    ```bash\n    git clone https://github.com/iyeque/Traider.git\n    cd Traider\n    ```\n2.  Install dependencies:\n    ```bash\n    pip install -r requirements.txt\n    ```\n3.  Create your .env file:\n    ```bash\n    cp .env.example .env\n    ```\n4.  Add your API keys and configure your strategy in the `.env` file. Set `BINANCE_ENV` to `TESTNET` to use the testnet.\n\n### Environment variables for live sentiment\n- `CRYPTOPANIC_API_KEY` (optional, recommended)\n- `NEWSAPI_KEY` (optional)\nIf not provided or sources return no data, the bot falls back to RSS feeds and a neutral score.\n\n---\n\n## 💻 Running the Bot\n\n### With Docker (Recommended for Multi-Currency)\nThe `docker-compose.yml` is pre-configured to run four bot instances, one for each currency (BNB, BTC, ETH, SOL), with individually tuned parameters.\n```bash\ndocker-compose up -d\n```\nView logs for a specific bot:\n```bash\ndocker-compose logs -f traider-bot-btc\n```\n\n### Natively\nWhen you run the bot natively, it starts the main trading logic and the background `OrderMonitor` to track trade executions and PnL.\n```bash\npython main.py\n```\nThe bot evaluates market safety each cycle using live sentiment and the Fear \u0026 Greed Index (see below). Tune thresholds in `config`.\n\n---\n\n## 📊 Monitoring and Analysis\n\nThis project provides several tools to monitor your bot's activity and analyze its performance.\n\n### 1. Trade Log Analysis (Recommended)\n\nThe most powerful analysis tool is the `analyze_trades.py` script. It reads your CSV trade logs and generates a comprehensive performance report with key metrics like Net Profit, Win Rate, and Profit Factor, along with a PnL distribution chart.\n\n-   **Live Trades:** `live_trades.csv`\n-   **Testnet Trades:** `testnet_trades.csv`\n\n**How to run the analysis:**\n```bash\n# To analyze your live trades\npy backtest/analyze_trades.py live_trades.csv\n\n# To analyze your testnet trades\npy backtest/analyze_trades.py testnet_trades.csv\n```\n\n### 2. Enhanced Backtesting\n\nThe backtesting engine (`backtest/backtest.py`) now provides more realistic simulations with:\n\n- **Dynamic Slippage:** Slippage calculated based on trade quantity\n- **Latency Simulation:** Realistic execution delays\n- **Exchange Constraints:** MIN_NOTIONAL and LOT_SIZE checks\n- **Global Drawdown Control:** Stops trading if maximum drawdown is hit\n- **Trade Count Limit:** Limits the number of trades in a backtest\n- **Sentiment Integration:** Uses historical sentiment data\n- **Comprehensive Metrics:** Detailed performance metrics\n\n### 3. Live Sentiment Integration\n\nLive sentiment is fetched by `data_acquisition/fetch_live_sentiment.py` (CryptoPanic, NewsAPI, RSS) and the Fear \u0026 Greed Index. It is consumed by `bot/sentiment_engine.is_market_safe()` which updates `LiveTradingStats`. \n\n- Safety gate: `main.py` calls `is_market_safe(min_sentiment, min_fear_greed)` before running strategies.\n- Signal context: `breakout_strategy` pulls the latest value via `LiveTradingStats().get_sentiment()`.\n- Configuration: tune `SENTIMENT_THRESHOLD_POSITIVE`, `SENTIMENT_THRESHOLD_NEGATIVE`, and `FEAR_GREED_THRESHOLD` in `config`.\n\n### 3. Real-time Dashboard\n\nThe dashboard provides a simple, real-time web interface to see high-level stats of a single running bot instance.\n\n**How to run it:**\n```bash\n# Run this in a separate terminal\npy manual_dashboard.py\n```\nThen open your browser to `http://127.0.0.1:8181`.\n\n### 3. Raw Account Data Check\n\nFor a quick, on-demand check of your raw testnet account data (all balances and full trade history from the exchange), use the `check_testnet.py` script.\n```bash\npy check_testnet.py\n```\n\n---\n\n## 🧪 Automated Testing\n\nUnit tests are provided for core modules to ensure reliability and correctness:\n- `bot/test_strategy.py`: Tests the signal generation logic in `strategy.py`.\n\nRun all tests before deploying or running the bot to catch bugs early:\n```bash\npython -m unittest discover bot\n```\n\n---\n\n## 📁 Project Structure\n\n```bash\ntraider/\n├── bot/\n│   ├── strategy.py        # Signal generator \u0026 indicators\n│   ├── trading.py         # Executes trades with SL/TP\n│   ├── grid.py            # Grid ladder logic\n│   ├── sentiment_engine.py# Live sentiment \u0026 market safety gate\n│   ├── position_manager.py# Singleton to manage open positions\n│   ├── order_monitor.py   # Background service to track fills and PnL\n│   ├── trade_logger.py    # Handles writing trades to CSV\n│   ├── news_utils.py      # News data processing\n│   ├── rss_utils.py       # RSS feed processing\n│   └── ...\n├── backtest/\n│   ├── backtest.py        # Enhanced backtesting engine\n│   ├── optimize_params.py # Parameter optimization with Optuna\n│   ├── analyze_trades.py  # Trade analysis script\n│   ├── optimization_results/ # Stores optimization results\n├── data_acquisition/      # Scripts for fetching market data\n│   ├── fetch_historical_data.py # Fetches historical price/sentiment data\n│   ├── fetch_live_sentiment.py  # Fetches live sentiment \u0026 Fear \u0026 Greed Index\n├── .env.example           # Example environment variables\n├── config.py              # Configuration management\n├── live_trades.csv        # Auto-generated log for live trades\n├── testnet_trades.csv     # Auto-generated log for testnet trades\n├── check_testnet.py       # Utility to check testnet account\n├── main.py                # Main bot runner\n├── manual_dashboard.py    # Real-time monitoring dashboard\n├── CHANGELOG.md           # Detailed change history\n└── README.md\n```\n\n---\n\n## 🔐 Security Notes\n\n-   Never commit your `.env` file or API keys.\n-   Always use IP whitelisting on the Binance API.\n-   Start with small amounts for live testing or use the Binance testnet.\n\n---\n\n## 🛡️ Disclaimer\n\nThis is NOT financial advice. You are fully responsible for your own trades, wins, and losses. Use it at your own risk.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyeque%2Ftraider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiyeque%2Ftraider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyeque%2Ftraider/lists"}