cleitonleonel / pyquotex

Unofficial Quotex Library
Other
69 stars 53 forks source link

USER_AGENT doesn't seem to be taken in consideration in a class #33

Closed bitcoin4cashqc closed 1 month ago

bitcoin4cashqc commented 1 month ago

I get :

File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_connection.py", line 514, in wrap_api_call raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None playwright._impl._errors.Error: Page.evaluate: opts is not defined

Trying to initialize like this :


import time
from quotexapi.stable_api import Quotex
import random

USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"

class QuotexExchange:
    def __init__(self, **kwargs):
        # Initialize the Quotex client using the new library
        self.client = Quotex(
            email=kwargs.get('email'),
            password=kwargs.get('password'),
            lang=kwargs.get('lang', 'pt'),  # Language default set to Portuguese
            email_pass=kwargs.get('email_pass', kwargs.get('password')),  # Optional email pass
            user_data_dir=kwargs.get('user_data_dir', None)  # Optional browser profile path
        )
        self.client.set_session(user_agent=USER_AGENT)
        self.client.debug_ws_enable = True
        self.connected = False
        self.max_retries = int(kwargs.get('retry', 5))  # Retry attempts for connection
        self.practice = kwargs.get('practice', 'yes').lower() == 'yes'  # Practice mode
        self.otc = kwargs.get('otc', 'yes').lower() == 'yes'  # OTC mode
bitcoin4cashqc commented 1 month ago

Per my research, downgrading playwright to 1.37 which also required to downgrade greenlet and other requirements made it work for me on windows 10. Issue that I faced just pip installing

I'm doing a work for someone that would prefer quotex as the exchange but this is such unreliable. I also tried this fork but it's very laggy spamming multiple trades and also sometimes it return LOSS when it's a WIN and vice-versa.

I'm willing to make this work with you guys but we gotta make this more reliable considering the goal is to make real money trading.

bitcoin4cashqc commented 1 month ago

Also in my opinion it should not ask config just by importing from quotexapi.stable_api import Quotex

Because importing it trigger the python test.py Insira o e-mail da conta:

cleitonleonel commented 1 month ago

I get :

File "C:\Users\User\AppData\Local\Programs\Python\Python312\Lib\site-packages\playwright\_impl\_connection.py", line 514, in wrap_api_call raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None playwright._impl._errors.Error: Page.evaluate: opts is not defined

Trying to initialize like this :

import time
from quotexapi.stable_api import Quotex
import random

USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"

class QuotexExchange:
    def __init__(self, **kwargs):
        # Initialize the Quotex client using the new library
        self.client = Quotex(
            email=kwargs.get('email'),
            password=kwargs.get('password'),
            lang=kwargs.get('lang', 'pt'),  # Language default set to Portuguese
            email_pass=kwargs.get('email_pass', kwargs.get('password')),  # Optional email pass
            user_data_dir=kwargs.get('user_data_dir', None)  # Optional browser profile path
        )
        self.client.set_session(user_agent=USER_AGENT)
        self.client.debug_ws_enable = True
        self.connected = False
        self.max_retries = int(kwargs.get('retry', 5))  # Retry attempts for connection
        self.practice = kwargs.get('practice', 'yes').lower() == 'yes'  # Practice mode
        self.otc = kwargs.get('otc', 'yes').lower() == 'yes'  # OTC mode

Is this not working for you ?

import asyncio
from quotexapi.stable_api import Quotex

USER_AGENT = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"

class QuotexExchange:

    def __init__(self, **kwargs):
        # Initialize the Quotex client using the new library
        self.client = Quotex(
            email=kwargs.get('email'),
            password=kwargs.get('password'),
            lang=kwargs.get('lang', 'pt'),  # Language default set to Portuguese
            email_pass=kwargs.get('email_pass', None),  # Optional email pass
            user_data_dir=kwargs.get('user_data_dir', None)  # Optional browser profile path
        )
        self.client.set_session(user_agent=USER_AGENT)
        self.client.debug_ws_enable = True
        self.connected = False
        self.max_retries = int(kwargs.get('retry', 5))  # Retry attempts for connection
        self.practice = kwargs.get('practice', 'yes').lower() == 'yes'  # Practice mode
        self.otc = kwargs.get('otc', 'yes').lower() == 'yes'  # OTC mode

    async def connect(self):
        return await self.client.connect()

    def disconnect(self):
        self.client.close()

    async def check_connect(self):
        return self.client.check_connect()

    async def get_balance(self):
        return await self.client.get_balance()

async def main():
    params = {
        "email": "email@gmail.com", 
        "password": "password", 
        "lang": "pt"
    }
    trade = QuotexExchange(**params)
    await trade.connect()
    is_connected = await trade.check_connect()
    if is_connected:
        print(f"Connected: {is_connected}")
        balance = await trade.get_balance()
        print(f"Balance: {balance}")
    print("Closing...")
    trade.disconnect()

if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    try:
        loop.run_until_complete(main())
    except KeyboardInterrupt:
        print("Exiting...")
    finally:
        loop.close()
bitcoin4cashqc commented 1 month ago

If you check my other replies you can see downgraded to python 3.11.5 and playwright to 1.37 did solved the issue for me. I forked the changes here

I'll try your code on my original setup to see if it

cleitonleonel commented 1 month ago

If you check my other replies you can see downgraded to python 3.11.5 and playwright to 1.37 did solved the issue for me. I forked the changes here

I'll try your code on my original setup to see if it

  • Not ask email/pass on import
  • Work as expected without the original opts issue

Okay, keep us posted on that.

bitcoin4cashqc commented 1 month ago

running your code on a fresh venv with python 3.12.5 and using the pip install here return :

Traceback (most recent call last): File "C:\Users\User\Desktop\kotex\test.py", line 2, in <module> from quotexapi.stable_api import Quotex File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\stable_api.py", line 7, in <module> from .api import QuotexAPI File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\api.py", line 14, in <module> from .http.login import Login File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\http\login.py", line 1, in <module> from ..http.qxbroker import Browser File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\http\qxbroker.py", line 8, in <module> from playwright_stealth import stealth_async File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\playwright_stealth\__init__.py", line 2, in <module> from playwright_stealth.stealth import stealth_sync, stealth_async, StealthConfig File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\playwright_stealth\stealth.py", line 6, in <module> import pkg_resources ModuleNotFoundError: No module named 'pkg_resources'

bitcoin4cashqc commented 1 month ago

running your code on a fresh venv with python 3.12.5 and using the pip install here return :

Traceback (most recent call last): File "C:\Users\User\Desktop\kotex\test.py", line 2, in <module> from quotexapi.stable_api import Quotex File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\stable_api.py", line 7, in <module> from .api import QuotexAPI File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\api.py", line 14, in <module> from .http.login import Login File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\http\login.py", line 1, in <module> from ..http.qxbroker import Browser File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\quotexapi\http\qxbroker.py", line 8, in <module> from playwright_stealth import stealth_async File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\playwright_stealth\__init__.py", line 2, in <module> from playwright_stealth.stealth import stealth_sync, stealth_async, StealthConfig File "C:\Users\User\Desktop\kotex\.venv\Lib\site-packages\playwright_stealth\stealth.py", line 6, in <module> import pkg_resources ModuleNotFoundError: No module named 'pkg_resources'

To fix : pip install setuptools

BUT, just importing from quotexapi.stable_api import Quotex in the file, not even initializing the client ask me for Insira o e-mail da conta: which doesn't make sense at all.

bitcoin4cashqc commented 1 month ago

Since that issue was opened, maybe Quotex changed the website because I get : waiting for locator("input.input-control-cabinet__input[type=\"email\"]") to be visible , I'm using a Serbia VPN and website available on browser, but I can't find anything related to input-control or cabinet input anywhere inspecting the page.

cleitonleonel commented 1 month ago

Since that issue was opened, maybe Quotex changed the website because I get : waiting for locator("input.input-control-cabinet__input[type=\"email\"]") to be visible , I'm using a Serbia VPN and website available on browser, but I can't find anything related to input-control or cabinet input anywhere inspecting the page.

image

bitcoin4cashqc commented 1 month ago

Upon checking qxbroker.py from your package and setting headless to False, I can see I'm hitting Cloudflare (I do not in my usual browser) so I'm downgrading playwright per #28

bitcoin4cashqc commented 1 month ago

Putting back headless False work :)