Profitable Crypto Futures Bot Development
Budget: $250 – $750 CAD
Advanced WebSocket-Based Position Management Module for KuCoin Futures Bot with Bot-Managed Stop Loss and Take Profit
Description
I am seeking a Python developer to build a WebSocket-based module for managing positions in a KuCoin Futures trading bot. The module will dynamically handle position entries, bot-managed Stop Loss (SL) and Take Profit (TP), and real-time synchronization of wallet and trading data. It will integrate with a Redis database for state management, providing seamless performance. Below are the detailed requirements and expectations.
Key Features and Requirements
1. WebSocket Integration
The module must utilize KuCoin’s WebSocket API to ensure real-time updates and precise control over trading operations:
• Position Monitoring
Subscribe to /contract/position to track and manage active positions. Ensure accurate synchronization of position details such as entry price, quantity, and mark price.
• Order Tracking and Immediate Cancellation
Monitor orders via /contract/order. If an order is detected as pending:
◦ Cancel it immediately to ensure there are no unexecuted or lingering orders.
◦ The bot must exclusively handle active positions; pending orders are not allowed.
◦ This ensures that all trades transition directly into positions without delays.
• Wallet Updates
Synchronize account balances dynamically using /account/balance. This ensures that margin availability and other wallet metrics are always up to date.
• Market Data Validation
Use bid/ask prices streamed from WebSocket feeds to:
◦ Validate trading conditions dynamically.
◦ Manage Stop Loss (SL) and Take Profit (TP) settings effectively.
Position Entry Rules
1. Market Validation with Margin Flexibility
• The bot will apply a ±0.04% margin above and below the target entry price to allow flexibility in fast-moving markets.
• This ensures that positions are entered even when slight price fluctuations occur.
2. Unique Positioning
• The bot must ensure that the same cryptocurrency cannot be added to the portfolio more than once while an existing position for that cryptocurrency is still active.
• Verification Logic:
◦ Before placing a position, the bot will query the wallet directly via WebSocket (/contract/position) to verify if there is already an active position for the cryptocurrency.
◦ If an active position exists, the bot will ignore the corresponding call from Redis DB1.
◦ If no active position is found in the wallet, the bot will proceed to retrieve the relevant entry details from Redis to execute the position.
3. Order Types
• Only use LIMIT orders as the primary entry method.
Wallet Synchronization
1. Real-Time Updates
• Synchronize wallet balances and margin usage dynamically using the /account/balance WebSocket feed.
• Ensure that all wallet metrics, such as total balance and margin availability, are always up to date.
2. Bet Sizing Rule
• Each position (bet) must be exactly 10% of the total wallet balance. (Leverage not include)
• Example:
◦ If the wallet balance is $10,000, the bot will allocate $1,000 to each position.
• Dynamically calculate the trade size for each position based on the real-time wallet balance retrieved via WebSocket.
• If the total balance decreases, the bet size will automatically adjust to remain within 10% of the updated wallet balance.
3. Enforcement
• The bot will validate that the calculated trade size adheres to the 10% rule before placing a position.
• If the required size for a trade cannot meet this rule due to insufficient balance or margin constraints, the bot will:
◦ Skip the trade and log the reason for rejection in Redis and the SQL database.
◦ Reassess potential trades during the next validation cycle.
3. Immediate Margin Check
• Ensure sufficient wallet margin exists before placing a position.
• Cross-check margin data stored in Redis with live wallet data retrieved via WebSocket.
4. Time Constraints
• Position entries must be completed within 2 seconds of validation to avoid latency issues.
5. Dynamic Adjustments
• Cancel and revalidate orders if the market price moves outside the allowed margin during the order placement process.
Bot-Managed Stop Loss (SL) and Take Profit (TP)
1. Dynamic SL and TP Configuration
• Stop Loss: Dynamically calculate as 0.5-1.5% below (for long positions) or above (for short positions) the entry price.
• Take Profit: Dynamically calculate as 1-2% above (for long positions) or below (for short positions) the entry price.
2. Redis Integration
• Store SL and TP levels for each active position in Redis.
• Continuously update SL/TP status and execute closures upon reaching thresholds.
3. Real-Time Monitoring
• The bot will monitor SL and TP thresholds using live market data from WebSocket streams.
• Close positions immediately when thresholds are breached and update Redis accordingly.
4. Error Handling
• Implement safeguards to prevent duplicate SL/TP triggers.
• Log every SL/TP-related action to maintain transparency and aid debugging.
Position Monitoring
• Real-Time Updates: Use WebSocket data to track price changes and dynamically manage SL/TP.
• Redis Integration: Maintain the current state of all active positions and pending orders in Redis for instantaneous access.
Position Tracking and Reporting
1. SQL Database for Position Tracking
• The bot will log all successfully executed positions into a SQL database for comprehensive tracking.
• Each entry will include:
◦ Symbol, Entry Price, Exit Price, Position Type, Entry Time, Exit Time, Outcome, Profit/Loss.
2. Daily Performance Reporting
• At the end of each trading day, the bot will generate a report summarizing:
◦ Total positions entered, wins, losses, and cumulative profit/loss.
3. Database Maintenance
• Archive or clean old data to optimize database performance and ensure long-term usability.
Workflow
1. Fetch and Validate Data
• Retrieve SL/TP, margin, and trading data from Redis DB1 to prepare for position entry.
• Use WebSocket streams to validate market conditions dynamically.
2. Position Entry
• Dynamically validate and execute trades based on live price data within the defined ±0.04% margin.
3. Monitor and Manage Positions
• Continuously monitor price data and update Redis to reflect position states accurately.
4. Wallet Synchronization
• Dynamically update wallet balances and margin usage, ensuring trade feasibility.
5. Daily Loss Limit
• Shut down operations if daily losses exceed 7% of the initial balance.
Developer Responsibilities
1. WebSocket Client Development
2. Redis Integration
3. Dynamic Position Management
4. Testing
Description
I am seeking a Python developer to build a WebSocket-based module for managing positions in a KuCoin Futures trading bot. The module will dynamically handle position entries, bot-managed Stop Loss (SL) and Take Profit (TP), and real-time synchronization of wallet and trading data. It will integrate with a Redis database for state management, providing seamless performance. Below are the detailed requirements and expectations.
Key Features and Requirements
1. WebSocket Integration
The module must utilize KuCoin’s WebSocket API to ensure real-time updates and precise control over trading operations:
• Position Monitoring
Subscribe to /contract/position to track and manage active positions. Ensure accurate synchronization of position details such as entry price, quantity, and mark price.
• Order Tracking and Immediate Cancellation
Monitor orders via /contract/order. If an order is detected as pending:
◦ Cancel it immediately to ensure there are no unexecuted or lingering orders.
◦ The bot must exclusively handle active positions; pending orders are not allowed.
◦ This ensures that all trades transition directly into positions without delays.
• Wallet Updates
Synchronize account balances dynamically using /account/balance. This ensures that margin availability and other wallet metrics are always up to date.
• Market Data Validation
Use bid/ask prices streamed from WebSocket feeds to:
◦ Validate trading conditions dynamically.
◦ Manage Stop Loss (SL) and Take Profit (TP) settings effectively.
Position Entry Rules
1. Market Validation with Margin Flexibility
• The bot will apply a ±0.04% margin above and below the target entry price to allow flexibility in fast-moving markets.
• This ensures that positions are entered even when slight price fluctuations occur.
2. Unique Positioning
• The bot must ensure that the same cryptocurrency cannot be added to the portfolio more than once while an existing position for that cryptocurrency is still active.
• Verification Logic:
◦ Before placing a position, the bot will query the wallet directly via WebSocket (/contract/position) to verify if there is already an active position for the cryptocurrency.
◦ If an active position exists, the bot will ignore the corresponding call from Redis DB1.
◦ If no active position is found in the wallet, the bot will proceed to retrieve the relevant entry details from Redis to execute the position.
3. Order Types
• Only use LIMIT orders as the primary entry method.
Wallet Synchronization
1. Real-Time Updates
• Synchronize wallet balances and margin usage dynamically using the /account/balance WebSocket feed.
• Ensure that all wallet metrics, such as total balance and margin availability, are always up to date.
2. Bet Sizing Rule
• Each position (bet) must be exactly 10% of the total wallet balance. (Leverage not include)
• Example:
◦ If the wallet balance is $10,000, the bot will allocate $1,000 to each position.
• Dynamically calculate the trade size for each position based on the real-time wallet balance retrieved via WebSocket.
• If the total balance decreases, the bet size will automatically adjust to remain within 10% of the updated wallet balance.
3. Enforcement
• The bot will validate that the calculated trade size adheres to the 10% rule before placing a position.
• If the required size for a trade cannot meet this rule due to insufficient balance or margin constraints, the bot will:
◦ Skip the trade and log the reason for rejection in Redis and the SQL database.
◦ Reassess potential trades during the next validation cycle.
3. Immediate Margin Check
• Ensure sufficient wallet margin exists before placing a position.
• Cross-check margin data stored in Redis with live wallet data retrieved via WebSocket.
4. Time Constraints
• Position entries must be completed within 2 seconds of validation to avoid latency issues.
5. Dynamic Adjustments
• Cancel and revalidate orders if the market price moves outside the allowed margin during the order placement process.
Bot-Managed Stop Loss (SL) and Take Profit (TP)
1. Dynamic SL and TP Configuration
• Stop Loss: Dynamically calculate as 0.5-1.5% below (for long positions) or above (for short positions) the entry price.
• Take Profit: Dynamically calculate as 1-2% above (for long positions) or below (for short positions) the entry price.
2. Redis Integration
• Store SL and TP levels for each active position in Redis.
• Continuously update SL/TP status and execute closures upon reaching thresholds.
3. Real-Time Monitoring
• The bot will monitor SL and TP thresholds using live market data from WebSocket streams.
• Close positions immediately when thresholds are breached and update Redis accordingly.
4. Error Handling
• Implement safeguards to prevent duplicate SL/TP triggers.
• Log every SL/TP-related action to maintain transparency and aid debugging.
Position Monitoring
• Real-Time Updates: Use WebSocket data to track price changes and dynamically manage SL/TP.
• Redis Integration: Maintain the current state of all active positions and pending orders in Redis for instantaneous access.
Position Tracking and Reporting
1. SQL Database for Position Tracking
• The bot will log all successfully executed positions into a SQL database for comprehensive tracking.
• Each entry will include:
◦ Symbol, Entry Price, Exit Price, Position Type, Entry Time, Exit Time, Outcome, Profit/Loss.
2. Daily Performance Reporting
• At the end of each trading day, the bot will generate a report summarizing:
◦ Total positions entered, wins, losses, and cumulative profit/loss.
3. Database Maintenance
• Archive or clean old data to optimize database performance and ensure long-term usability.
Workflow
1. Fetch and Validate Data
• Retrieve SL/TP, margin, and trading data from Redis DB1 to prepare for position entry.
• Use WebSocket streams to validate market conditions dynamically.
2. Position Entry
• Dynamically validate and execute trades based on live price data within the defined ±0.04% margin.
3. Monitor and Manage Positions
• Continuously monitor price data and update Redis to reflect position states accurately.
4. Wallet Synchronization
• Dynamically update wallet balances and margin usage, ensuring trade feasibility.
5. Daily Loss Limit
• Shut down operations if daily losses exceed 7% of the initial balance.
Developer Responsibilities
1. WebSocket Client Development
2. Redis Integration
3. Dynamic Position Management
4. Testing