A trading bot for the EdgeX exchange, built using the official EdgeX Python SDK. The bot implements an automated strategy that places orders and automatically closes them at a profit.
Sample commands: ETH: python runbot.py --quantity 0.1 --take-profit 0.9 --max-orders 40 --wait-time 450
BTC: python runbot.py --contract-id 10000001 --quantity 0.05 --take-profit 30 --max-orders 40 --wait-time 450
The bot is built using the official EdgeX Python SDK and consists of:
- REST API client for EdgeX using the official SDK
- Handles authentication and API requests
- Manages order placement, cancellation, and status queries
- Position and account information retrieval
- WebSocket connection management using the official SDK
- Real-time market data streaming
- Order update notifications
- Automatic connection handling
- Core scalping logic
- Order placement and monitoring
- Position management
- Main trading loop
-
Clone the repository:
git clone <repository-url> cd edgex
-
Create and activate virtual environment:
python3 -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Use the env_example.txt to create a
.envfile in the project root.
EDGEX_ACCOUNT_ID: Your EdgeX account IDEDGEX_STARK_PRIVATE_KEY: Your EdgeX api private keyEDGEX_BASE_URL: EdgeX API base URL (default: https://pro.edgex.exchange)EDGEX_WS_URL: EdgeX WebSocket URL (default: wss://quote.edgex.exchange)
--contract-id: EdgeX contract ID (default: 10000002 for ETH-USDT)--quantity: Order quantity (default: 0.1)--take-profit: Take profit in USDT (default: 0.9)--direction: Trading direction: 'buy' or 'sell' (default: buy)--max-orders: Maximum number of active orders (default: 40)--wait-time: Wait time between orders in seconds (default: 450)
python runbot.pypython runbot.py \
--contract-id 10000001 \
--quantity 0.001 \
--take-profit 0.5 \
--direction buy \
--max-orders 5 \
--wait-time 60The bot implements a simple scalping strategy:
- Order Placement: Places a limit order slightly above/below market price
- Order Monitoring: Waits for the order to be filled
- Close Order: Automatically places a close order at the take profit level
- Position Management: Monitors positions and active orders
- Risk Management: Limits maximum number of concurrent orders
The bot provides comprehensive logging:
- Transaction Logs: CSV files with order details
- Debug Logs: Detailed activity logs with timestamps
- Console Output: Real-time status updates
- Error Handling: Comprehensive error logging and handling
- Order Limits: Configurable maximum order count
- Timeout Handling: Automatic order cancellation on timeouts
- Position Monitoring: Continuous position and order status checking
- Error Recovery: Graceful handling of API errors and disconnections
edgex-python-sdk: Official EdgeX Python SDKpython-dotenv: Environment variable managementpytz: Timezone handlingasyncio: Asynchronous programming supportaiohttp: HTTP client for async operationswebsocket-client: WebSocket support
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This software is for educational and research purposes only. Trading cryptocurrencies involves significant risk and can result in substantial financial losses. Use at your own risk and never trade with money you cannot afford to lose.
For issues related to:
- EdgeX API: Check the EdgeX API documentation
- EdgeX SDK: Check the EdgeX Python SDK documentation
- This Bot: Open an issue in this repository