Closed anjalmorang closed 1 month ago
I haven't tried it, just create a new client for each different one tried to do it,, but ,, its facing errors
raceback (most recent call last):
File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 125, in
raceback (most recent call last): File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 125, in run(main()) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 18, in run z = loop.run_until_complete(y) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 116, in main await trade(action, amount_input, duration_input) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 80, in trade check_connect, message = await prepare_connection.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\my_connection.py", line 17, in connect check, reason = await self.client.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 141, in connect check, reason = await self.connect() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 137, in connect check, reason = await self.api.connect() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 273, in connect ssid, self.cookies = await self.get_ssid() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 196, in get_ssid ssid, cookies = await self.login(self.email, self.password, self.headless) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\login.py", line 25, in call self.ssid, self.cookies = self.get_cookies_and_ssid() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\qxbroker.py", line 23, in get_cookies_and_ssid browser = uc.Chrome(headless=self.headless, use_subprocess=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriverinit.py", line 258, in init self.patcher.auto() File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 178, in auto self.unzip_package(self.fetch_package()) File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 310, in unzip_package os.rename(os.path.join(self.zip_path, exe_path), self.executable_path) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected\chromedriver-win32\chromedriver.exe' -> 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected_chromedriver.exe'
I'm reading this
raceback (most recent call last): File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 125, in run(main()) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 18, in run z = loop.run_until_complete(y) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 116, in main await trade(action, amount_input, duration_input) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 80, in trade check_connect, message = await prepare_connection.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\my_connection.py", line 17, in connect check, reason = await self.client.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 141, in connect check, reason = await self.connect() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 137, in connect check, reason = await self.api.connect() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 273, in connect ssid, self.cookies = await self.get_ssid() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 196, in get_ssid ssid, cookies = await self.login(self.email, self.password, self.headless) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\login.py", line 25, in call self.ssid, self.cookies = self.get_cookies_and_ssid() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\qxbroker.py", line 23, in get_cookies_and_ssid browser = uc.Chrome(headless=self.headless, use_subprocess=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriverinit.py", line 258, in init self.patcher.auto() File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 178, in auto self.unzip_package(self.fetch_package()) File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 310, in unzip_package os.rename(os.path.join(self.zip_path, exe_path), self.executable_path) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected\chromedriver-win32\chromedriver.exe' -> 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected_chromedriver.exe'
Can you show me a piece of your code?
raceback (most recent call last): File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 125, in run(main()) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 18, in run z = loop.run_until_complete(y) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 116, in main await trade(action, amount_input, duration_input) File "C:\Users\ANJAL MORANG\Desktop\new_project\test_time.py", line 80, in trade check_connect, message = await prepare_connection.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Desktop\new_project\my_connection.py", line 17, in connect check, reason = await self.client.connect() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 141, in connect check, reason = await self.connect() ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpyinit.py", line 137, in connect check, reason = await self.api.connect() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 273, in connect ssid, self.cookies = await self.get_ssid() ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\api.py", line 196, in get_ssid ssid, cookies = await self.login(self.email, self.password, self.headless) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\login.py", line 25, in call self.ssid, self.cookies = self.get_cookies_and_ssid() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\quotexpy\http\qxbroker.py", line 23, in get_cookies_and_ssid browser = uc.Chrome(headless=self.headless, use_subprocess=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriverinit.py", line 258, in init self.patcher.auto() File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 178, in auto self.unzip_package(self.fetch_package()) File "C:\Users\ANJAL MORANG\Downloads\python\Lib\site-packages\undetected_chromedriver\patcher.py", line 310, in unzip_package os.rename(os.path.join(self.zip_path, exe_path), self.executable_path) FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected\chromedriver-win32\chromedriver.exe' -> 'C:\Users\ANJAL MORANG\appdata\roaming\undetected_chromedriver\undetected_chromedriver.exe'
Can you show me a piece of your code?
sir, i deleted that,, but currently was experimenting with some code ,, import sys import asyncio from termcolor import colored from quotexpy import Quotex from quotexpy.utils import asset_parse from quotexpy.utils.account_type import AccountType from quotexpy.utils.operation_type import OperationType from my_connection import MyConnection
asset_current = "EURUSD"
def run(y): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) z = loop.run_until_complete(y) return z
async def initialize_client(email, password): client = Quotex(email=email, password=password, headless=False) client.debug_ws_enable = False await asyncio.sleep(1) # Ensure the client has time to initialize return client
def check_asset(client, asset): asset_query = asset_parse(asset) asset_open = client.check_asset_open(asset_query) if not asset_open[2]: print(colored("[WARN]: ", "yellow"), "Asset is closed.") asset = f"{asset}_otc" print(colored("[WARN]: ", "yellow"), "Try OTC Asset -> " + asset) asset_query = asset_parse(asset) asset_open = client.check_asset_open(asset_query) return asset, asset_open
async def get_candle_v2(email, password): client = await initialize_client(email, password) prepare_connection = MyConnection(client) check_connect, message = await prepare_connection.connect() if check_connect: try: global asset_current asset, asset_open = check_asset(client, asset_current) if asset_open[2]: print(colored("[INFO]: ", "blue"), f"Asset is open for {email}.") period = 100 candles = await client.get_candle_v2(asset, period) print(f"{email}: {candles}") else: print(colored("[INFO]: ", "blue"), f"Asset is closed for {email}.") finally: prepare_connection.close()
async def get_realtime_candle(email, password): client = await initialize_client(email, password) prepare_connection = MyConnection(client) check_connect, message = await prepare_connection.connect() if check_connect: try: list_size = 10 global asset_current asset, asset_open = check_asset(client, asset_current) if asset_open[2]: client.start_candles_stream(asset, list_size) while True: if len(client.get_realtime_candles(asset)) == list_size: break print(f"{email}: {client.get_realtime_candles(asset)}") else: print(colored("[INFO]: ", "blue"), f"Asset is closed for {email}.") finally: prepare_connection.close()
async def trade_single_account(email, password, action, amount, duration): client = await initialize_client(email, password) prepare_connection = MyConnection(client) check_connect, message = await prepare_connection.connect() if check_connect: try: client.change_account(AccountType.PRACTICE) global asset_current asset, asset_open = check_asset(client, asset_current) if asset_open[2]: status, trade_info = await client.trade(action, amount, asset, duration) if status: print(colored(f"[INFO]: Trade executed successfully for {email}.", "blue")) else: print(colored(f"[WARN]: Trade not executed for {email}.", "light_red")) else: print(colored(f"[WARN]: Asset is closed for {email}.", "light_red")) balance = await client.get_balance() print(colored(f"[INFO]: Balance for {email}: {balance}", "blue")) finally: prepare_connection.close() else: print(colored(f"[ERROR]: Failed to connect for {email}.", "red"))
async def trade_all_accounts(action, amount, duration): accounts = [ {"email": "salmanthakur54u@gmail.com", "password": "qwertysalmanthakur"}, {"email": "kajukatlicc@gmail.com", "password": "qwertykajukatli"}
]
tasks = [
trade_single_account(account['email'], account['password'], action, amount, duration)
for account in accounts
]
await asyncio.gather(*tasks)
async def main(): accounts = [ {"email": "salmanthakur54u@gmail.com", "password": "qwertysalmanthakur"}, {"email": "kajukatlicc@gmail.com", "password": "qwertykajukatli"} ] while True: user_input = input( "Enter 'candle' for candlestick data, 'realtime' for real-time candle data, or 'trade' to make a trade: ").strip().lower() if user_input == 'candle': tasks = [get_candle_v2(account['email'], account['password']) for account in accounts] await asyncio.gather(tasks) elif user_input == 'realtime': tasks = [get_realtime_candle(account['email'], account['password']) for account in accounts] await asyncio.gather(tasks) elif user_input == 'trade': action_input = input("Enter 'call' for CALL_GREEN or 'put' for PUT_RED: ").strip().lower() amount_input = float(input("Enter the trade amount: ")) duration_input = int(input("Enter the duration in seconds: ")) action = OperationType.CALL_GREEN if action_input == 'call' else OperationType.PUT_RED await trade_all_accounts(action, amount_input, duration_input) else: print("Invalid input. Please try again.")
if name == "main": try: run(main()) except KeyboardInterrupt: print("Aborted!") sys.exit(0)
please, help me,, sir,,
please, help me,, sir,,
import sys
import asyncio
from termcolor import colored
from quotexpy import Quotex
from quotexpy.utils import asset_parse
from quotexpy.utils.account_type import AccountType
from quotexpy.utils.operation_type import OperationType
asset_current = "EURUSD_otc"
def run(y):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
z = loop.run_until_complete(y)
return z
async def initialize_client(email, password):
client = Quotex(email=email, password=password, headless=False)
client.debug_ws_enable = False
await asyncio.sleep(1) # Ensure the client has time to initialize
return client
def check_asset(client, asset):
asset_query = asset_parse(asset)
asset_open = client.check_asset_open(asset_query)
if not asset_open[2]:
print(colored("[WARN]: ", "yellow"), "Asset is closed.")
asset = f"{asset}_otc"
print(colored("[WARN]: ", "yellow"), "Try OTC Asset -> " + asset)
asset_query = asset_parse(asset)
asset_open = client.check_asset_open(asset_query)
return asset, asset_open
async def get_candle_v2(email, password):
client = await initialize_client(email, password)
check_connect = await client.connect()
if check_connect:
try:
global asset_current
asset, asset_open = check_asset(client, asset_current)
if asset_open[2]:
print(colored("[INFO]: ", "blue"), f"Asset is open for {email}.")
period = 100
candles = await client.get_candle_v2(asset, period)
print(f"{email}: {candles}")
else:
print(colored("[INFO]: ", "blue"), f"Asset is closed for {email}.")
finally:
client.close()
async def get_realtime_candle(email, password):
client = await initialize_client(email, password)
check_connect = await client.connect()
if check_connect:
try:
list_size = 10
global asset_current
asset, asset_open = check_asset(client, asset_current)
if asset_open[2]:
client.start_candles_stream(asset, list_size)
while True:
if len(client.get_realtime_candles(asset)) == list_size:
break
print(f"{email}: {client.get_realtime_candles(asset)}")
else:
print(colored("[INFO]: ", "blue"), f"Asset is closed for {email}.")
finally:
client.close()
async def trade_single_account(email, password, action, amount, duration):
client = await initialize_client(email, password)
check_connect = await client.connect()
if check_connect:
try:
client.change_account(AccountType.PRACTICE)
global asset_current
asset, asset_open = check_asset(client, asset_current)
if asset_open[2]:
status, trade_info = await client.trade(action, amount, asset, duration)
if status:
print(colored(f"[INFO]: Trade executed successfully for {email}.", "blue"))
else:
print(colored(f"[WARN]: Trade not executed for {email}.", "light_red"))
else:
print(colored(f"[WARN]: Asset is closed for {email}.", "light_red"))
balance = await client.get_balance()
print(colored(f"[INFO]: Balance for {email}: {balance}", "blue"))
finally:
client.close()
else:
print(colored(f"[ERROR]: Failed to connect for {email}.", "red"))
async def trade_all_accounts(action, amount, duration):
accounts = [
{"email": "salmanthakur54u@gmail.com", "password": "qwertysalmanthakur"},
{"email": "kajukatlicc@gmail.com", "password": "qwertykajukatli"}
]
tasks = [
trade_single_account(account['email'], account['password'], action, amount, duration)
for account in accounts
]
await asyncio.gather(*tasks)
async def main():
accounts = [
{"email": "salmanthakur54u@gmail.com", "password": "qwertysalmanthakur"},
{"email": "kajukatlicc@gmail.com", "password": "qwertykajukatli"}
]
while True:
user_input = input(
"Enter 'candle' for candlestick data, 'realtime' for real-time candle data, or 'trade' to make a trade: ").strip().lower()
if user_input == 'candle':
tasks = [get_candle_v2(account['email'], account['password']) for account in accounts]
await asyncio.gather(*tasks)
elif user_input == 'realtime':
tasks = [get_realtime_candle(account['email'], account['password']) for account in accounts]
await asyncio.gather(*tasks)
elif user_input == 'trade':
action_input = input("Enter 'call' for CALL_GREEN or 'put' for PUT_RED: ").strip().lower()
amount_input = float(input("Enter the trade amount: "))
duration_input = int(input("Enter the duration in seconds: "))
action = OperationType.CALL_GREEN if action_input == 'call' else OperationType.PUT_RED
await trade_all_accounts(action, amount_input, duration_input)
else:
print("Invalid input. Please try again.")
if __name__ == "__main__":
try:
run(main())
except KeyboardInterrupt:
print("Aborted!")
sys.exit(0)
Traceback (most recent call last):
File "C:\Users\ANJAL MORANG\Desktop\new_project\mutiple-3.py", line 142, in
Process finished with exit code 1
You must use the code that I uploaded in the last commits
ok sir,
[ERROR]: Failed to connect for salmanthakur54u@gmail.com. [ERROR]: Failed to connect for kajukatlicc@gmail.com. sir,, can it be an Initialization Issues?
What does the .log file say?
What does the .log file say?
also,, in some executions 403
Upload it to pastebin, I'll look at it and look for the solution.
sir,, i had one more issue
say it
import os import ssl import time import json import certifi import logging import urllib3 import typing import threading
from quotexpy.exceptions import QuotexTimeout from quotexpy.http.login import Login from quotexpy.http.logout import Logout from quotexpy.ws.channels.ssid import Ssid from quotexpy.ws.channels.trade import Trade from quotexpy.ws.channels.candles import GetCandles from quotexpy.ws.channels.sell_option import SellOption from quotexpy.ws.objects.timesync import TimeSync from quotexpy.ws.objects.candles import Candles from quotexpy.ws.objects.profile import Profile from quotexpy.ws.objects.listinfodata import ListInfoData from quotexpy.ws.client import WebsocketClient from collections import defaultdict
urllib3.disable_warnings() logger = logging.getLogger(name)
cert_path = certifi.where() os.environ["SSL_CERT_FILE"] = cert_path os.environ["WEBSOCKET_CLIENT_CA_BUNDLE"] = cert_path cacert = os.environ.get("WEBSOCKET_CLIENT_CA_BUNDLE")
def nested_dict(n, type): if n == 1: return defaultdict(type) return defaultdict(lambda: nested_dict(n - 1, type))
class QuotexAPI(object): """Class for communication with Quotex API"""
socket_option_opened = {}
trade_id = None
trace_ws = False
buy_expiration = None
current_asset = None
trade_successful = None
account_balance = None
last_operation = {}
account_type = None
instruments = None
training_balance_edit_request = None
profit_in_operation = None
sold_options_respond = None
sold_digital_options_respond = None
listinfodata = ListInfoData()
timesync = TimeSync()
candles = Candles()
SSID = None
wss_message = None
check_websocket_if_connect = None
ssl_Mutual_exclusion = False
ssl_Mutual_exclusion_write = False
started_listen_instruments = True
check_rejected_connection = False
check_accepted_connection = False
check_websocket_if_error = False
websocket_error_reason = None
balance_id = None
def __init__(self, email: str, password: str, headless: bool):
"""
:param str host: The hostname or ip address of a Quotex server.
:param str email: The email of a Quotex server.
:param str password: The password of a Quotex server.
:param proxies: The proxies of a Quotex server.
"""
self.email = email
self.password = password
self.headless = headless
self._temp_status = ""
self.settings_list = {}
self.signal_data = nested_dict(2, dict)
self.get_candle_data = {}
self.candle_v2_data = {}
self.cookies = None
self.profile = None
self.websocket_thread = None
self.wss_url = "wss://ws2.qxbroker.com/socket.io/?EIO=3&transport=websocket"
self.websocket_client = None
self.set_ssid = None
self.user_agent = None
self.token_login2fa = None
self.realtime_price = {}
self.realtime_sentiment = {}
self.profile = Profile()
self.logger = logging.getLogger(__name__)
@property
def websocket(self):
"""Property to get websocket.
:returns: The instance of :class:`WebSocket <websocket.WebSocket>`.
"""
return self.websocket_client.wss
def get_candle_v2(self):
payload = {"_placeholder": True, "num": 0}
data = f'451-["history/list/v2", {json.dumps(payload)}]'
return self.send_websocket_request(data)
def subscribe_realtime_candle(self, asset, period):
self.realtime_price[asset] = []
payload = {"asset": asset, "period": period}
data = f'42["instruments/update", {json.dumps(payload)}]'
return self.send_websocket_request(data)
def unsubscribe_realtime_candle(self, asset):
data = f'42["subfor", {json.dumps(asset)}]'
return self.send_websocket_request(data)
async def subscribe_candlestick(self, asset: str, period: int, duration: int):
"""
Subscribes to real-time candlestick data for a given asset and period, retrieving data per second until the given time ends.
:param asset: The asset to subscribe to.
:param period: The period for the candlestick data.
:param duration: The duration in seconds for which to keep the websocket open and retrieve data.
"""
self.subscribe_realtime_candle(asset, period)
end_time = time.time() + duration
while time.time() < end_time:
if asset in self.realtime_price:
if len(self.realtime_price[asset]) > 0:
print(self.realtime_price[asset])
await asyncio.sleep(1)
self.unsubscribe_realtime_candle(asset)
@property
def logout(self):
"""Property for get Quotex http login resource.
:returns: The instance of :class:`Login
<quotexpy.http.login.Login>`.
"""
return Logout(self)
@property
def login(self):
"""Property for get Quotex http login resource.
:returns: The instance of :class:`Login
<quotexpy.http.login.Login>`.
"""
return Login(self)
@property
def ssid(self):
"""Property for get Quotex websocket ssid channel.
:returns: The instance of :class:`Ssid
<quotexpy.ws.channels.ssid.Ssid>`.
"""
return Ssid(self)
@property
def trade(self):
"""Property for get Quotex websocket ssid channel.
:returns: The instance of :class:`Buy
<Quotex.ws.channels.buy.Buy>`.
"""
return Trade(self)
@property
def sell_option(self):
return SellOption(self)
@property
def get_candles(self):
"""Property for get Quotex websocket candles channel.
:returns: The instance of :class:`GetCandles
<quotexpy.ws.channels.candles.GetCandles>`.
"""
return GetCandles(self)
def check_session(self) -> typing.Tuple[str, str]:
data = {}
if os.path.isfile(".session.json"):
with open(".session.json") as file:
data = json.loads(file.read())
self.user_agent = data.get("user_agent")
return data.get("ssid"), data.get("cookies")
def send_websocket_request(self, data, no_force_send=True) -> None:
"""Send websocket request to Quotex server.
:param str data: The websocket request data.
:param bool no_force_send: Default None.
"""
if self.check_websocket_if_connect == 0:
self.logger.info("websocket connection closed")
return
while (self.ssl_Mutual_exclusion or self.ssl_Mutual_exclusion_write) and no_force_send:
pass
self.ssl_Mutual_exclusion_write = True
self.websocket.send('42["tick"]')
self.websocket.send('42["indicator/list"]')
self.websocket.send('42["drawing/load"]')
self.websocket.send('42["pending/list"]')
self.websocket.send('42["instruments/update",{"asset":"%s","period":60}]' % self.current_asset)
self.websocket.send('42["chart_notification/get"]')
self.websocket.send('42["depth/follow","%s"]' % self.current_asset)
self.websocket.send(data)
self.logger.debug(data)
self.ssl_Mutual_exclusion_write = False
def edit_training_balance(self, amount) -> None:
data = f'42["demo/refill",{json.dumps(amount)}]'
self.send_websocket_request(data)
async def get_ssid(self) -> typing.Tuple[str, str]:
self.logger.info("authenticating user")
ssid, cookies = self.check_session()
if not ssid:
ssid, cookies = await self.login(self.email, self.password, self.headless)
self.logger.info("login successful")
return ssid, cookies
def start_websocket(self) -> bool:
self.check_websocket_if_connect = None
self.check_websocket_if_error = False
self.websocket_error_reason = None
self.websocket_client = WebsocketClient(self)
self.websocket_thread = threading.Thread(
target=self.websocket.run_forever,
kwargs={
"ping_interval": 25000,
"ping_timeout": 5000,
"ping_payload": "2",
"origin": "https://qxbroker.com",
"host": "ws2.qxbroker.com",
"sslopt": {
"cert_reqs": ssl.CERT_NONE,
"ca_certs": cacert,
"ssl_version": ssl.PROTOCOL_TLSv1_2,
},
},
)
self.websocket_thread.daemon = True
self.websocket_thread.start()
while True:
try:
if self.check_websocket_if_error:
self.logger.error(self.websocket_error_reason)
return False
if self.check_websocket_if_connect == 0:
self.logger.debug("websocket connection closed")
return False
if self.check_websocket_if_connect == 1:
self.logger.debug("websocket successfully connected")
return True
except:
pass
def send_ssid(self, max_attemps=10) -> bool:
"""
Send ssid to Quotex
max_attemps - time to wait for authorization in seconds
"""
self.profile.msg = None
if not self.SSID:
if os.path.exists(os.path.join(".session.json")):
os.remove(".session.json")
return False
self.ssid(self.SSID)
start_time = time.time()
previous_second = -1
while not self.account_balance:
elapsed_time = time.time() - start_time
current_second = int(elapsed_time)
if current_second != previous_second:
previous_second = current_second
if elapsed_time >= max_attemps:
raise QuotexTimeout(f"sending authorization with SSID {self.SSID} took too long to respond")
return True
async def connect(self) -> bool:
"""Method for connection to Quotex API"""
self.ssl_Mutual_exclusion = False
self.ssl_Mutual_exclusion_write = False
if self.check_websocket_if_connect:
self.close()
ssid, self.cookies = await self.get_ssid()
check_websocket = self.start_websocket()
if not check_websocket:
return check_websocket
if not self.SSID:
self.SSID = ssid
return check_websocket
def close(self) -> None:
if self.websocket_client:
self.websocket.close()
self.websocket_thread.join()
def websocket_alive(self) -> bool:
return self.websocket_thread.is_alive()
actually,, what i wanted to do is,,, get realtime candle,, the price and ohol values and then make an indicator
can you help me out sir?? pleasee
sir,, i gave you an email too, please check
i think it's not possible with this struct, because the program waiting results from de trade operation and needs adjustments in code.
Em qui., 18 de jul. de 2024 Ã s 07:29, anjalmorang @.***> escreveu:
Closed #74 https://github.com/SantiiRepair/quotexpy/issues/74 as completed.
— Reply to this email directly, view it on GitHub https://github.com/SantiiRepair/quotexpy/issues/74#event-13553474316, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDWLQKNCY5AISZTWQWW66DZM6KHZAVCNFSM6AAAAABLANAOV6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGU2TGNBXGQZTCNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- [ ]'s
Ricardo Spinoza @.*** blog: http://ricardospinoza.wordpress.com LinkedIn: http://br.linkedin.com/in/ricardospinoza
I haven't tried it, just create a new client for each different one