pyquotex is a Python library designed to easily integrate with the Quotex API, enabling automated trading operations. Fully open-source and licensed under MIT, the library provides features like order execution, balance checking, real-time market data collection, and more. Perfect for traders and developers looking to build efficient and customized solutions.
The project follows a modular structure organized as follows:
π¦ pyquotex/
β£ π docs/ # Documentation
β£ π examples/ # Usage examples
β β£ π custom_config.py # Custom configuration
β β£ π monitoring_assets.py # Asset monitoring
β β£ π trade_bot.py # Trading bot
β β π user_test.py # User tests
β£ π pyquotex/ # API Core
β β£ π network/ # Network modules (Authentication, Settings)
β β β£ π login.py
β β β£ π logout.py
β β β π settings.py
β β£ π utils/ # Utilities
β β£ π ws/ # WebSocket
β β β£ π channels/ # WS channels
β β β π objects/ # WS objects
β β£ π api.py # Main API
β β π stable_api.py # Stable API
The API is built on a client-server architecture using WebSocket as the main communication protocol. The main components are:
The API implements various WebSocket channels for different functionalities:
The system implements sophisticated session handling including:
async def authenticate(self):
logger.info("Connecting User Account...")
async with self.login as login:
status, message = await login(
self.username,
self.password,
self.user_data_dir
)
if status:
self.state.SSID = self.session_data.get("token")
self.is_logged = True
return status, message
session.json file# Unified SSL context for all network operations
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
ssl_context.maximum_version = ssl.TLSVersion.TLSv1_3
ssl_context.set_ciphers('ECDHE-ECDSA-AES128-GCM-SHA256:...')
try:
await self.connect()
except Exception as e:
logger.error(f"Connection error: {e}")
await self.reconnect()
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(message)s'
)
To prevent Memory Leaks during long-running execution, the API uses collections.deque with strict limits (maxlen).
This ensures that real-time price history does not grow indefinitely.
Technical indicator processing is now fully event-driven. The system only recalculates indicators when the
candle_generated signal is received, drastically reducing CPU usage.
We use httpx.AsyncClient with connection pooling to speed up network requests and reduce overhead.