Overview
This prompt aims to create a comprehensive Python script for an AI Trading Bot, emphasizing technical indicators and risk management. Programmers and traders will benefit from a clear, modular code structure that facilitates understanding and customization.
Prompt Overview
Purpose: This script aims to create an AI Trading Bot for automated trading using technical indicators.
Audience: It is designed for programmers and traders interested in algorithmic trading strategies.
Distinctive Feature: The bot integrates with the IQ Option API for real-time trading and includes backtesting capabilities.
Outcome: Users will have a modular, well-documented Python script for trading automation and strategy evaluation.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Consulting (Management, Strategy), Development Tools & DevOps, Productivity & Workflow
- Techniques: Role/Persona Prompting, Self-Critique / Reflection, Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
You are to generate a detailed, fully commented Python script for an AI Trading Bot that includes the following components:
– Technical indicator definitions:
– moving average
– MACD
– parabolic SAR
– fractals
– Signal generation logic using those indicators to decide when to ‘buy’, ‘sell’, or ‘hold’.
– Risk management elements embedded in the logic (where applicable).
– Integration with the IQ Option API to:
– connect
– fetch candle data
– place trades
– Backtesting functionality to evaluate the strategy’s win/loss rate with realistic assumptions.
The code should be clear and modular, utilizing classes and methods, with detailed comments explaining each step and parameter. Additionally, the implementation should include appropriate error handling, especially for the API connection and trading execution.
Ensure the final code is in Python, structured neatly for readability and maintenance.
# Steps
1. Define a class for indicator calculation with static methods for each indicator.
2. Implement the IQOptionBot class that uses the IQ Option API for connectivity and trading.
3. Include methods to:
– retrieve market data
– generate signals from technical analysis
– place trades
– backtest the strategy
4. Use pandas and numpy for data manipulation; include all necessary imports.
5. Incorporate informative print statements to indicate:
– connection status
– trade execution
– backtest results
6. Save the entire bot code as a Python (.py) file on disk and provide the file path.
# Output Format
– Provide a complete Python script as a string, fully ready to run after installing dependencies.
– The script should be saved to a file; output only the file path as the final response.
# Notes
– The bot uses the ‘iqoptionapi’ package; assume the environment has this installed.
– Backtesting uses simple price movement assumptions for wins/losses.
– Code must have thorough, clear comments to assist understanding and modification.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Paste the prompt into your coding environment.
- Run the prompt to generate the Python script.
- Save the output script as a .py file.
- Ensure all dependencies are installed before running the script.
- Execute the script to start the AI Trading Bot.
Tips for Best Results
- Modular Design: Structure your code into classes and methods for better readability and maintenance.
- Error Handling: Implement try-except blocks to manage API connection issues and trade execution errors.
- Signal Generation: Use technical indicators to create clear buy, sell, or hold signals based on market conditions.
- Backtesting: Simulate trades using historical data to evaluate the effectiveness of your strategy before live trading.
FAQ
- What is a moving average in trading?
A moving average smooths price data to identify trends over a specific period. - How does MACD help in trading decisions?
MACD indicates momentum by showing the relationship between two moving averages of a security's price. - What is the purpose of risk management in trading?
Risk management minimizes potential losses and protects trading capital through strategies like stop-loss orders. - What is backtesting in trading strategies?
Backtesting evaluates a trading strategy's effectiveness using historical data to simulate performance.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


