cleitonleonel / pyquotex

Unofficial Quotex Library
Other
57 stars 49 forks source link

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

Open bitcoin4cashqc opened 4 days ago

bitcoin4cashqc commented 4 days 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 3 days 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 3 days 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 3 days 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 3 days 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 3 days 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.