This plan outlines the steps to enhance the functionality, reliability, and profitability of the Polymarket copytrading bot.
- Goal: Copy trades from multiple successful wallets instead of just one.
- Action: Update
config.pyto supportTRADER_WALLETS(comma-separated list). - Action: Update
main.pylisteners to handle multiple addresses.
- Goal: Protect the bankroll from excessive losses.
- Action: Create
scripts/constraints/risk_manager.py. - Features:
MAX_TOTAL_EXPOSURE: Cap the total USDC in active positions.MAX_PER_TRADER_EXPOSURE: Limit how much can be allocated to a single trader's picks.MAX_PER_MARKET_EXPOSURE: Avoid being over-leveraged in one market.SLIPPAGE_LIMIT: Reject trades if the price moves too far.
- Goal: Ensure orders are filled and handle API failures gracefully.
- Action: Refactor
scripts/make_orders.py. - Features:
- Retry Logic: Exponential backoff for transient network/API errors.
- Slippage Protection: Add a
max_slippageparameter tomake_order. - Order Tracking: Log all order IDs and their status.
- Goal: Align trade sizes with the bot's bankroll and strategy.
- Action: Update
scripts/constraints/sizing.py. - Features:
PROPORTIONAL_SIZING: Copy the same percentage of the bankroll that the target trader used.FIXED_SIZING: Use a fixed USDC amount regardless of the trader's size.- Enforce
STAKE_MINandSTAKE_MAXconsistently.
- Goal: Better visibility into the bot's decisions and errors.
- Action: Use Python's
loggingmodule to save logs tobot.log. - Action: Include timestamps, trader address, and market details in every log.
- Goal: Real-time alerts on mobile.
- Action: Add a Telegram notification handler.
- Alerts: New trades, filled orders, errors, and daily PnL summaries.
- Goal: Prevent bugs through better code structure.
- Action: Add type hints to all functions.
- Action: Create a
tests/directory and add unit tests for sizing and risk logic.
- Goal: Keep the environment clean.
- Action: Update
requirements.txtwith any new necessary libraries.
- Phase 1 (Reliability): Refactor
make_orders.pyand implement structured logging. - Phase 2 (Strategy): Enhance
sizing.pyand implement theRiskManager. - Phase 3 (Scaling): Support multiple traders and add Telegram notifications.
- Phase 4 (Testing): Add unit tests and type hints.