示例#1
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")
示例#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
示例#3
0
def main():
	if not path.exists("iqdataset.csv"):
		with open("iqdataset.csv", 'w') as esc:
			esc.write("timestamp;varkandle\n")
			esc.close()
	else:
		pass
	iq = IQ_Option("","") # Login do user
	iq.set_max_reconnect(-1)
	if iq.check_connect():
		while True:
			time.sleep(15) #Tempo para coletar, e sim, isso causa no resultado influência!
			try:			
				goal     = "EURUSD" # ATIVO 
				size     = 1
				maxdict  = 10
				iq.start_candles_stream(goal, size, maxdict)
				cc       = iq.get_realtime_candles(goal, 1)
				pp       = pprint.PrettyPrinter(depth = 8)
				inti     = cc
				tim      = time.time()
				end_time = int(tim) - 0.8
				end_cap  = inti[int(end_time)]["min"]
				with open("iqdataset.csv", "a") as file:
					file = file.write(f"{end_time};{end_cap}\n")
					print(file)
			except Exception as e:
				print("ERRO:", e)
				continue
	if not iq.check_connect():
		iq.connect()
		main()
示例#4
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
示例#5
0
文件: bot.py 项目: 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
示例#6
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
示例#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
示例#8
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
示例#9
0
文件: app.py 项目: tgcmv/iqoptionapi
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
示例#10
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!")
示例#11
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
示例#12
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")
示例#13
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)
示例#14
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()]
示例#15
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
示例#16
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")
示例#17
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)
示例#18
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()
示例#19
0
    def connect(self):
        if self.email == "" and self.password == "":
            while True:
                from getpass import getpass

                self.email = input("Email: ")
                self.password = getpass("Password: "******"\n - Erro ao logar: ", reason)
                    return "login error"
        else:
            while True:
                api = IQ_Option(self.email, self.password)
                check, reason = api.connect()
                if check:
                    break
                else:
                    print("\n - Erro ao logar: ", reason)
                    return "login error"
        return api
示例#20
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
示例#21
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)
示例#22
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()))
示例#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
示例#24
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()
示例#25
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'
示例#26
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)
示例#27
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')                           
示例#28
0
    def test_Candle(self):
        #login
        I_want_money = IQ_Option(email, password)
        I_want_money.change_balance("PRACTICE")
        I_want_money.reset_practice_balance()
        self.assertEqual(I_want_money.check_connect(), True)
        #start test binary option
        ALL_Asset = I_want_money.get_all_open_time()
        if ALL_Asset["turbo"]["EURUSD"]["open"]:
            ACTIVES = "EURUSD"
        else:
            ACTIVES = "EURUSD-OTC"

        I_want_money.get_candles(ACTIVES, 60, 1000, time.time())
        #realtime candle
        size = "all"
        I_want_money.start_candles_stream(ACTIVES, size, 10)
        I_want_money.get_realtime_candles(ACTIVES, size)
        I_want_money.stop_candles_stream(ACTIVES, size)
示例#29
0
文件: bot.py 项目: rpuggian/binarybot
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)
示例#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