Example #1
0
    def Login(self, email, senha):
        self.emailUser = email
        self.senhaUser = senha
        print('senha e email', email, senha)
        logging.disable(level=(logging.DEBUG))
        self.Iq = IQ_Option(email, senha)
        self.check, self.reason = self.Iq.connect()
        self.url = 'http://meubot.me/rest.php'
        self.varResult = 0
        self.resultRequest = requests.post(self.url,
                                           data={
                                               "class":
                                               "SystemUserRestService",
                                               "method": "getUser",
                                               "email": self.emailUser,
                                               "active": "Y"
                                           })
        self.dataRequest = json.loads(self.resultRequest.text)
        print(self.dataRequest)
        self.idUsuario = self.dataRequest['data']['id']

        if self.check == True:
            if self.dataRequest['data']['msg'] == 'ATIVO':
                print('Logou')
                self.varResult = 'ativo'
            else:
                self.varResult = 'desativo'

        time.sleep(0.1)
        return self.varResult
Example #2
0
    def login(self,widget_list,email,password,mode,money,expire,msg_label, button,frame):
        if(button.cget("text") == "Start"):
            self.main_log_frame  = frame;
            self.email = email.get()
            self.password = password.get()
            # [email protected] Dazeface1
            self.api = IQ_Option(self.email, self.password)
            connection_msg  = self.api.connect()
            if connection_msg[0]!=True:
                err_msg = json.loads(connection_msg[1])["message"]
                msg_label.config(text=err_msg,fg="#d90f4f")
                # print(err_msg)
                # print(json.loads(connection_msg[1]))
                return
            else:
                msg_label.config(text="Connected!",fg="#00bf89")
                self.account_type = mode.get()
                self.money = float(str(money.get()).strip())
                self.expire_time = float(str(expire.get()).strip())
            self.api.change_balance(self.account_type)
            #
            self.server_thread = Thread(target=self.start_server)
            self.server_thread.start()

        self.change_button(button, widget_list,msg_label)
        return
Example #3
0
File: bot.py Project: hugovst10/iq
def apiConnect(email, password):
    API = IQ_Option(email, password)
    while_run_time = 10
    check, reason = API.connect()

    API.change_balance("PRACTICE")

    return API, while_run_time, check, reason
Example #4
0
def check_win():
    conta = IQ_Option("*****@*****.**", "Teste123")
    conta.connect()
    descending = Operacoes.query.order_by(Operacoes.id.desc())
    last_item = descending.first()

    print(last_item.operation_id)

    return {"last_operation": last_item.operation_id}, 200
Example #5
0
 def post():
     content = request.get_json(silent=True)
     print(content)
     Database.insert_one(collection="user", data=content)
     print(content['email'])
     Iq = IQ_Option(content['email'], content['password'])
     Iq.connect()
     res = Iq.get_balance()
     print(res)
     return res
Example #6
0
def login():
    _API = IQ_Option(data.email,data.password)
    while True:
        if _API.connect():
            print('Conectado com sucesso')
            break
        else:
            print('Erro ao se conectar')
        time.sleep(1)
    return _API
Example #7
0
def login(verbose=False):

    if verbose:
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(message)s')

    iq = IQ_Option(USERNAME,
                   PASSWORD)  # YOU HAVE TO ADD YOUR USERNAME AND PASSWORD
    iq.change_balance("PRACTICE")  #or real
    return iq
Example #8
0
def login():
    init(autoreset=True)
    API = IQ_Option('*****@*****.**', 'Mohammedd2@')
    API.connect()
    if API.check_connect():
        print(' Conectado com sucesso! \n')
    else:
        print(' Erro ao conectar')
        input('\n\n Aperte enter para sair')
        sys.exit()

    entrada(API)
Example #9
0
def login_iqoption():
    global API
    email = catalogator.lineEmail.text()
    senha = catalogator.lineSenha.text()
    print('Conectando....')
    API = IQ_Option(email, senha)
    API.connect()

    if API.check_connect():
        catalogator.label_6.setText("Logado na Iq Option")
    else:
        catalogator.label_6.setText("Erro ao conecta")
Example #10
0
 def __init__(self, user, password, valor, tempo, conta):
     self.API = IQ_Option(user, password)
     self.id_compra = ''
     self.loss = 0
     self.win = 0
     self.value = valor
     self.gale = valor
     self.entrada = 'put'
     self.time = tempo
     self.account = conta
     self.pares = ['EURUSD-OTC', 'EURGBP-OTC', 'AUDCAD-OTC', 'EURJPY-OTC']
     self.par = self.pares[self.RandomNumber()]
Example #11
0
def login_iqoption():

    global API
    email_iq = catalogador.lineEmail.text()
    senha_iq = catalogador.lineSenha.text()
    API = IQ_Option(email_iq, senha_iq)
    print('Conectando....')

    API.connect()

    if API.check_connect():
        print("Conectado")
    else:
        print("conectado")
Example #12
0
def Conexao():
    global API
    email = config['email']
    senha = config['senha']
    print('Conectando....')
    API = IQ_Option(email, senha)
    API.connect()

    if API.check_connect():
        Clear_Screen()
        print('Conectado com sucesso!')
    else:
        print('Erro ao conectar')
        sys.exit()
Example #13
0
    def __init__(self):
        self.api = IQ_Option(os.environ["IQU"], os.environ["IQP"])
        self.api.connect()
        self.api.change_balance(ARG_BALANCE)
        self.currency = ARG_CURRENCY

        while True:
            if self.api.check_connect() == False:
                print('Erro ao conectar')
                self.api.connect
            else:
                print('Conectado com Sucesso')
                break
            time.sleep(3)
Example #14
0
def iqoption_connection():
    MODE = 'PRACTICE'  # TODO: Where to set PRACTICE / REAL?
    user = os.environ.get('IQOPTIONAPI_USER', None)
    password = os.environ.get('IQOPTIONAPI_PASS', None)
    if not user:
        sys.exit(
            "Missing environment variables IQOPTIONAPI_USER or IQOPTIONAPI_PASS !"
        )
    connection = IQ_Option(user, password)
    check, reason = connection.connect()
    if not check:
        raise Exception(reason)
    connection.change_balance(MODE)
    return connection
Example #15
0
	def logar(self):
		self.email=str(self.lineEdit_email.text())
		self.senha=str(self.lineEdit_senha.text())
		self.API = IQ_Option(self.email, self.senha)
		self.API.connect()
		if not self.API.check_connect():
			print('Erro na conexão. Tente novamente.')
			self.label_13.setText("Erro na conexão")
			self.label_13.setStyleSheet("color: #FF0000;")
		else:
			print('Conectado com sucesso!')
			self.label_13.setText("Conectado")
			self.label_13.setStyleSheet("color: #08F26E;")
			self.comboBox_chooseMode.setCurrentIndex(0)
			self.API.change_balance('PRACTICE')
			self.label_banca.setText(str(self.API.get_balance()))
Example #16
0
    def __init__(self,
                 goal,
                 size,
                 maxdict,
                 money,
                 expiration_mode,
                 account='PRACTICE'):
        '''
        account : ['REAL', 'PRACTICE']
        '''
        import json
        from iqoptionapi.stable_api import IQ_Option
        data = json.load(open('credentials.json'))
        username = data['email']
        password = data['password']
        self.Iq = IQ_Option(username, password)
        print()
        print('logging in...')
        check, reason = self.Iq.connect()  #connect to iqoption
        print('login:'******'SUCCESSFUL' if check else 'FAILED')
        print()
        assert check, True
        self.login_time = datetime.datetime.now()
        #self.Iq.reset_practice_balance()
        self.Iq.change_balance(account)
        ALL_Asset = self.Iq.get_all_open_time()
        if ALL_Asset["turbo"][goal]["open"]:
            goal = goal
        else:
            goal = goal + '-OTC'
        print('goal =', goal)

        self.goal = goal
        self.size = size
        self.maxdict = maxdict
        self.money = money
        self.expirations_mode = expiration_mode
        self.consecutive_error = 0
        self.forex_order_id = []
        instrument_type = 'forex'
        instrument_id = self.goal
        print('forex: leverage:',
              self.Iq.get_available_leverages(instrument_type, instrument_id))

        print()
Example #17
0
def sign(email, password):
    error_password = """{"code":"invalid_credentials","message":"You entered the wrong credentials. Please check that the login/password is correct."}"""
    iqoption = IQ_Option(email, password)
    check, reason = iqoption.connect()
    MODE = 'PRACTICE'
    if check:
        print('\n')
        print("user " + email + " connected ")
        iqoption.change_balance(MODE)
        return iqoption

        #if see this you can close network for test
    elif iqoption.check_connect() == False:  #detect the websocket is close
        print("try reconnect")
        check, reason = iqoption.connect()
        if check:
            print("Reconnect successfully")
        else:
            if reason == error_password:
                print("Error Password")
            else:
                print("No Network")
    else:

        if reason == "[Errno -2] Name or service not known":
            print("No Network")
        elif reason == error_password:
            print("Error Password")
Example #18
0
    def conectar(self):
        global API
        try:
            API = IQ_Option(self.central.usuario, self.central.senha)
            API.connect()
            print('Conectou OK')
            #API.change_balance(self.central.tipoConta)

            while True:
                if API.check_connect() == False:
                    return Mensagem().erroConectar
                    #sys.exit()
                else:
                    self.atualizaBanca()
                    return Mensagem.sucessoConectar
                    break
        except Exception as e:
            print(e)
Example #19
0
def conn():
    try:
        file = open('chaves.json', 'r')
    except NameError:
        print(NameError)

    dados = json.loads(file.read())

    connObj = IQ_Option(dados['USUARIO']['EMAIL'], dados['USUARIO']['SENHA'])
    return connObj
Example #20
0
def entrar(editEmail, editSenha):
    #print(editSenha.get())
    API = IQ_Option(editEmail, editSenha)
    API.connect()
    API.change_balance("PRACTICE")
    #API.set_max_reconnect(5)

    while True:
        if API.check_connect() == False:
            print("Erro ao Conectar")
            API.reconnect()
        else:
            print("Conectado com sucesso!")
            tela_operacional(editEmail, editSenha)
            break
        time.sleep(5)
Example #21
0
def main():
    logs.print_message("Bot Started!")

    #login
    logs.print_message("Login Credentials IQ Option:")
    email = input("Email:")
    password = input("Pass:"******"Error on try to login. Check iq option credentials on environment variables.")
        exit()
    logs.print_message("Conected: IQ Option!")

    #stops
    #REAL / PRACTICE
    account_type = input("Set the account type (REAL or PRACTICE):")
    api.change_balance(account_type)
    original_balance = api.get_balance()
    logs.print_message("Original balance: $ {}".format(original_balance))
    stop_loss = input("Set a stop loss value:")
    stop_win = input("Set a stop win value:")

    #read trades
    f = open("trades.csv")
    csv_f = csv.reader(f)
    counter = 0
    for row in csv_f:
        if counter == 0:
            logs.print_message("Programming Orders...")
        else:
            start_time = datetime.datetime.strptime(row[1], '%H:%M')
            time_result = start_time - datetime.timedelta(seconds=15)
            add_option(row[0].replace('/', ''), time_result.strftime("%H:%M:%S"), row[2], row[3], stop_loss, stop_win, api, original_balance)
        counter = counter + 1

    logs.print_message("\nProcessing Orders...")

    while True:
        schedule.run_pending()
        time.sleep(1)
Example #22
0
    def __init__(self):
        self.api = IQ_Option(config.USERNAME, config.PASSWORD)
        self.dispacher = Dispacher(self.api.api)
        self.api.change_balance(config.MODE)
        self.timesync = TimeSync(self.api, self.dispacher)
        self.bots = []
        self.actives = []
        
        self.generate_actives()
        self.create_bots()

        while True:
            if self.timesync.is_desconected():
                self.stop_bots()
                print('disconnected trying to reconnect in {} seconds'.format(config.TIME_RECONNECT))
                time.sleep(config.TIME_RECONNECT)

                if(self.reconnect()):
                    print('successfully reconnected')
                    self.create_bots()

            time.sleep(.3)
Example #23
0
    def getConnection(self):
        API = IQ_Option('login', 'senha')

        check, reason = API.connect()
        API.change_balance('PRACTICE')  # PRACTICE / REAL

        while True:
            if API.check_connect() == False:
                print('Erro ao se conectar')
                API.connect()
            else:
                print('Conectado com sucesso')
                break

            time.sleep(1)
        return API
Example #24
0
    def __init__(self):
        self.api = IQ_Option(config.USERNAME, config.PASSWORD)
        self.dispacher = Dispacher(self.api.api)
        self.api.change_balance(config.MODE)
        self.timesync = TimeSync(self.api, self.dispacher)
        self.actives = []
        
        self.generate_actives()

        acts: list = self.get_operable_actives()

        for index, active in enumerate(acts):
            candles: list = list(reversed(self.api.api.getcandles(active.code, 1, 10000, time.time())))

            for index, candle in candles:
                if index < len(candles) - 10:
                    candle: Candle = candle
                    
                    win = 0
                    losses = 0

                    if candles[index + 1].direction + candles[index + 2].direction + candles[index + 3].direction
                        pass
Example #25
0
def apiconnect(user: str, passw: str):
    error_password = '******'
    apiconn = IQ_Option(user, passw)
    check, reason = apiconn.connect()
    if check == False:
        if reason == '[Errno -2] Name or service not known':
            log.error(
                Idioma.traducao(
                    'Problema na conexão, verifique sua internet.'))
            print(
                Idioma.traducao(
                    'Problema na conexão, verifique sua internet.'))
            roboCtrl.instance().view.janela['-status-'].update(
                Idioma.traducao(
                    'Problema na conexão, verifique sua internet.'))
            roboCtrl.instance().view.janela.Refresh()
        elif reason == error_password:
            log.error(Idioma.traducao('Login/Senha inválido.'))
            print(Idioma.traducao('Login/Senha inválido.'))
            roboCtrl.instance().view.janela['-status-'].update(
                Idioma.traducao('Login/Senha inválido.'))
            roboCtrl.instance().view.janela.Refresh()
        return
    return apiconn
Example #26
0
 def get_connection(self):
     user = os.environ.get('IQOPTIONAPI_USER', None)
     password = os.environ.get('IQOPTIONAPI_PASS', None)
     if user:
         connection = IQ_Option(user, password)
         connection.connect()
         connection.change_balance(self.MODE)
         return connection
     else:
         sys.exit("Missing environment variables!")
Example #27
0
def buy_thread(email, senha, paridade, tipo, expiracao, action, valor):
    conta = IQ_Option(email, senha)
    conta.connect()
    conta.change_balance("PRACTICE")

    if (tipo == 'BINÁRIA'):
        check, id = conta.buy(valor, paridade, action, expiracao)
        if check:
            time.sleep(1)
            return check
    if (tipo == 'DIGITAL'):
        check, id = conta.buy_digital_spot(paridade, valor, action, expiracao)
        if check:
            time.sleep(1)
            return check
    print(check, id)

    return 'error check'
Example #28
0
def get_CandleResults(lista):
    returnedList = []
    init(autoreset=True)
    API = IQ_Option('*****@*****.**', 'Fh006131__')
    check, reason=API.connect()#connect to iqoption
    API.change_balance('PRACTICE')

    # while True:

    if API.check_connect() == False:
        print('Erro ao se conectar')
    else:
        for l in lista:
            l = l.split(',') 
            horario = datetime.strptime(l[0] + ":00", "%Y-%m-%dT%H:%M:%S")
            horario = datetime.timestamp(horario)
            if l[3] == "M5":
                velas = API.get_candles(l[1],300,3,int(horario))
            elif l[3] == "M15":
                velas = API.get_candles(l[1],900,3,int(horario))
            else:
                print ('Dado não lido. Incompatível!')    

            for v in range(len(velas)):
                if int(velas[v]['from']) == int(horario):
                    dir = 'call' if velas[v]['open'] < velas[v]['close'] else 'put' if velas[v]['open'] > velas[v]['close'] else 'doji'
                    if dir == l[2].lower():
                        returnedList.append(l[0]+','+l[1]+','+l[2]+','+l[3]+'-✅')
                        print(l[0],l[1],l[2],l[3],'|', Fore.GREEN + 'WIN')
                    else:
                        if int(velas[v]['from']) == int(horario):
                            dir = 'call' if velas[v]['open'] < velas[v]['close'] else 'put' if velas[v]['open'] > velas[v]['close'] else 'doji'
                            if dir == l[2].lower():
                                returnedList.append(l[0]+','+l[1]+','+l[2]+','+l[3]+'-✅1️⃣')
                                print(l[0],l[1],l[2],l[3],'|', Fore.GREEN + 'WIN')
                            else:
                                if int(velas[v]['from']) == int(horario):
                                    dir = 'call' if velas[v]['open'] < velas[v]['close'] else 'put' if velas[v]['open'] > velas[v]['close'] else 'doji'
                                    if dir == l[2].lower():
                                        returnedList.append(l[0]+','+l[1]+','+l[2]+','+l[3]+'-✅2️⃣')
                                        print(l[0],l[1],l[2],l[3],'|', Fore.GREEN + 'WIN')
                                    else:
                                        returnedList.append(l[0]+','+l[1]+','+l[2]+','+l[3]+'-❌')
                                        print(l[0],l[1],l[2],l[3],'|', Fore.RED + 'LOSS')                           
Example #29
0
def CreateAndManageLoginWindow():
    telaLogin = TelaLogin()
    if telaLogin.event == sg.WIN_CLOSED:
        telaLogin.window.close()
        exit()
    api = IQ_Option(str(telaLogin.values[0]), str(telaLogin.values[1]))
    #api = IQ_Option("*****@*****.**", "*****@*****.**")
    api.connect()
    telaLogin.window.close()

    while api.check_connect() == False:
        layout = [[
            sg.Text(
                'Login falhou, verifique se colocou o email/senha corretos')
        ], [sg.Text('Login'), sg.Input()],
                  [sg.Text('Senha'),
                   sg.Input(password_char="*")], [sg.Submit("logar")]]
        telaLogin.window = sg.Window("iqOption Bot").layout(layout)
        telaLogin.event, telaLogin.values = telaLogin.window.Read()
        api = IQ_Option(str(telaLogin.values[0]), str(telaLogin.values[1]))
        api.connect()
        telaLogin.window.close()

    return api
Example #30
0
    def connect_and_buy(self, email, senha, paridade, price, direcao,
                        expiracao, tipo):
        conta = IQ_Option(email, senha)
        check, reason = conta.connect()
        conta.change_balance("PRACTICE")
        print(check, reason)

        action = 'call' if direcao == 'CIMA' else 'put'
        valor = int(price)
        expiracao = int(expiracao)

        if (tipo == 'BINÁRIA'):
            check, id = conta.buy(valor, paridade, action, expiracao)
            if check:
                print('ordem aberta')
        if (tipo == 'DIGITAL'):
            print('digital')
            check, id = conta.buy_digital_spot(paridade, valor, action,
                                               expiracao)
            if check:
                print("ordem aberta")
        return check