1. Fix limit order execution in crypto/trading_bot.py by adding auto-price fallback. 2. Update crypto/qwen_client.py prompt to mandate explicit limit prices and MFE/MAE based SL/TP. 3. Update crypto/deepseek_client.py prompt to include performance stats and position context. |
||
|---|---|---|
| .. | ||
| .env | ||
| .env.example | ||
| __init__.py | ||
| advanced_analysis.py | ||
| ai_client_factory.py | ||
| crypto_trading.db | ||
| database_manager.py | ||
| deepseek_client.py | ||
| okx_data_processor.py | ||
| optimization.py | ||
| qwen_client.py | ||
| README.md | ||
| requirements.txt | ||
| run_bot_watchdog.bat | ||
| run_bot_watchdog.sh | ||
| trading_bot.py | ||
| visualization.py | ||
OKX Crypto Trading Strategy
This project is a quantitative trading strategy designed for OKX cryptocurrency exchange, based on an AI-driven architecture using DeepSeek and Qwen models.
Project Structure
crypto/trading_bot.py: Main entry point for the trading bot. Orchestrates data fetching, AI analysis, and trade execution.crypto/okx_data_processor.py: Handles interaction with OKX API viaccxt. Fetches OHLCV data and calculates technical indicators (EMA, RSI, ATR).crypto/ai_client_factory.py: Factory for creating AI clients.crypto/deepseek_client.py: Client for DeepSeek API (Market Structure Analysis).crypto/qwen_client.py: Client for Qwen API (Strategy Optimization and Decision Making).crypto/database_manager.py: Manages the SQLite database for trade logging.crypto/.env: Configuration file for API keys.crypto/requirements.txt: Python dependencies.
Setup
-
Install Dependencies:
pip install -r crypto/requirements.txt -
Configuration: The
crypto/.envfile has been pre-configured with your provided OKX API keys. Note: You need to add yourSILICONFLOW_API_KEYto the.envfile for the AI models to work. -
Run the Bot: To run a single pass of the strategy:
python crypto/trading_bot.pyOr use the watchdog script to keep it running:
./crypto/run_bot_watchdog.sh
Strategy Logic
- Data Acquisition: Fetches historical candle data from OKX.
- Feature Engineering: Calculates technical indicators (EMA, RSI, ATR, Volatility).
- Market Analysis (DeepSeek): Analyzes market structure, support/resistance, and trends.
- Decision Making (Qwen): Combines market analysis with technical signals to generate trading decisions (Buy/Sell/Hold) and manage risk (Stop Loss/Take Profit).
- Execution: Executes trades on OKX (currently in logging mode, uncomment execution lines in
trading_bot.pyto enable live trading).
Notes
- The bot currently logs actions instead of executing real trades for safety. Review
trading_bot.py'sexecute_trademethod to enable real orders. - Ensure your API keys have the necessary permissions (Trade, Read).