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.
This documentation details the account management functionalities in the PyQuotex API.
from quotexapi.stable_api import Quotex
# Initialize client
client = Quotex(
email="youremail@gmail.com",
password="yourpassword",
lang="en" # Default language: Portuguese(pt)
)
# Connect to API
await client.connect()
To get user profile information:
async def get_profile():
profile = await client.get_profile()
# Available information
print(f"User: {profile.nick_name}")
print(f"Demo Balance: {profile.demo_balance}")
print(f"Real Balance: {profile.live_balance}")
print(f"ID: {profile.profile_id}")
print(f"Avatar: {profile.avatar}")
print(f"Country: {profile.country_name}")
print(f"Timezone: {profile.offset}")
To check the current account balance:
async def check_balance():
balance = await client.get_balance()
print(f"Current Balance: {balance}")
The displayed balance corresponds to the active account (demo or real).
To reload the balance in the demo account:
async def reload_demo_balance():
# Reload 5000 in demo account
result = await client.edit_practice_balance(5000)
print(result)
To get the operation history:
async def get_history():
# Gets history of active account
history = await client.get_history()
for operation in history:
print(f"ID: {operation.get('ticket')}")
print(f"Profit: {operation.get('profitAmount')}")
# Other available data in history
You can also check the result of a specific operation:
async def check_operation(operation_id):
status, details = await client.get_result(operation_id)
# status can be "win" or "loss"
print(f"Result: {status}")
print(f"Details: {details}")
To switch between demo and real accounts:
# Switch to real account
client.set_account_mode("REAL")
# Switch to demo account
client.set_account_mode("PRACTICE")
# You can also use the alternative method
client.change_account("REAL") # or "PRACTICE"
It’s recommended to implement error handling in operations:
async def safe_operation():
try:
check_connect, message = await client.connect()
if check_connect:
# Perform operations
pass
else:
print(f"Connection error: {message}")
except Exception as e:
print(f"Error: {str(e)}")
finally:
client.close()