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()
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")
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
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!")
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
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)
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")
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()
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")
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
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)
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
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)
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'
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
def aplicar(e, s, pl, et, m): api = IQ_Option(e, s) api.connect() porcentagem_lucro = float(pl) entrada = float(et) moeda = m # EURUSD tipoConta = "PRACTICE" # PRACTICE / REAL operacao = "put" #put / call timeframe = 1 valor_minimo = round(float(entrada) * (float(porcentagem_lucro / 100)), 2) api.subscribe_strike_list(moeda, timeframe) status, id = api.buy_digital_spot(moeda, entrada, operacao, timeframe) time.sleep(0.3) while api.get_async_order( id)['position-changed']['msg']['status'] == 'open': vpv = round(api.get_digital_spot_profit_after_sale(id), 2) time.sleep(0.3) os.system('cls' if os.name == 'nt' else 'clear') print('Atual: $' + str(vpv) + ' - Minimo para venda: $' + str(valor_minimo)) if vpv > valor_minimo: print('Fechando operação') api.close_digital_option(id) break time.sleep(0.3) status, valor = api.check_win_digital_v2(id) print('Resultado da operação: ' + str('WIN +' if valor > 0 else 'LOSS ') + str(round(valor, 2)))
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
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
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
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')
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
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
class IQ: 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) def getCurrency(self): return self.currency def getBalance(self): return self.api.get_balance() def getEnterValue(self): banca = self.getBalance() bancaFloor = math.floor(banca / 40) return bancaFloor if int(banca) > 40 else 2.0 # Limited to $USD 2 def getServerDatetime(self): serverTime = self.api.get_server_timestamp() hora = datetime.strptime( datetime.utcfromtimestamp(serverTime).strftime( '%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S') return hora.replace(tzinfo=tz.gettz('GMT')) def getCandles(self, rangeTime=60, quant=10): return self.api.get_candles(self.currency, rangeTime, quant, self.api.get_server_timestamp()) def buyDigital(self, direction): return self.api.buy_digital_spot(self.currency, self.getEnterValue(), direction, ARG_DURATION) def checkResult(self, id): return self.api.check_win_digital_v2(id) def shouldEntry(self): serverTime = self.getServerDatetime() # minutes = float(serverTime.strftime('%M.%S')[1:]) # return True if (minutes >= 4.58 and minutes <= 5) or minutes >= 9.58 else False seconds = int(serverTime.strftime('%S')) if seconds < 20: time.sleep(20) elif seconds < 30: time.sleep(10) goTrade = True if (seconds >= 48 and seconds <= 50) or seconds >= 58 else False if goTrade == False: time.sleep(1) return goTrade
from iqoptionapi.stable_api import IQ_Option import logging import time #logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') Iq = IQ_Option("*****@*****.**", "aswdkl;123") Iq.connect() #connect to iqoption # ACTIVES="EURUSD" # duration=1#minute 1 or 5 # amount=1 # action="call"#put # print("__For_Binary_Option__") # _,id=Iq.buy(amount,ACTIVES,action,duration) # while Iq.get_async_order(id)==None: # pass # print(Iq.get_async_order(id)) # print("\n\n") # # print("__For_Digital_Option__spot") # _,id=Iq.buy_digital_spot(ACTIVES,amount,action,duration) # while Iq.get_async_order(id)==None: # pass # order_data=Iq.get_async_order(id) # print(Iq.get_async_order(id)) # print("\n\n") instrumentid_tmp = "BTCUSD" instrumenttype_tmp = "crypto" direction_tmp = "buy" leverage_tmp = 3
import time from iqoptionapi.stable_api import IQ_Option import json import logging # logging level logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s') Iq = IQ_Option("*****@*****.**", "aswdkl;123") # connect to iqoption check, reason = Iq.connect() print(check, reason) # connect to iq option Iq.connect() goal = "EURUSD" print("get candles") iqCandles = Iq.get_candles(goal, 60, 111, time.time()) iqCandles_json = json.dumps(iqCandles) print(type(iqCandles)) print(type(iqCandles_json)) print(iqCandles) print(iqCandles_json)
print('ERRO AO REALIZAR ENTRADA!!') time.sleep(1) except: print('ERRO AO REALIZAR ENTRADA!!') time.sleep(1) if status: print( f'\n INICIANDO OPERAÇÃO {str(id)}..\n {str(horario)} | {par} | OPÇÃO: {opcao.upper()} | DIREÇÃO: {direcao.upper()} | M{timeframe} | PAYOUT: {payout}%\n\n' ) Mensagem( f'INICIANDO OPERAÇÃO {str(id)}..\n {str(horario)} | {par} | OPÇÃO: {opcao.upper()} | DIREÇÃO: {direcao.upper()} | M{timeframe} | PAYOUT: {payout}%' ) API.connect() API.change_balance(config['conta']) while True: if API.check_connect() == False: print('>> Erro ao se conectar!\n') input(' Aperte enter para sair') sys.exit() else: print( f'>> Conectado com sucesso!\n {Fore.RED}VENDA DO BOT PROIBIDA!!!\n' ) banca() config['banca_inicial'] = valor_da_banca print( f"{Fore.LIGHTBLUE_EX}Saldo da conta {'demo' if account_type == 'PRACTICE' else 'real'}: {account_balance}" )
from iqoptionapi.stable_api import IQ_Option import logging import time # logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') Iq = IQ_Option("*****@*****.**", "aswdkl;123") # Iq = IQ_Option(content['email'], content['password']) Iq.connect() Money = [] ACTIVES = [] ACTION = [] expirations_mode = [] res = Iq.get_balance() print(res) print(Iq.check_connect()) Money.append(1) ACTIVES.append("EURUSD") ACTION.append("call") #put expirations_mode.append(1) Money.append(1) ACTIVES.append("EURAUD") ACTION.append("call") #put expirations_mode.append(1) print("buy multi") id_list = Iq.buy_multi(Money, ACTIVES, ACTION, expirations_mode) print("check win only one id (id_list[0])") print(Iq.check_win_v2(id_list[0], 2))
def PrintarResumo(): print('Tipo: ' + TIPO + ' / Par: ' + par) print(Hora()) def PrintLog(msg): print('\n') print('Log [' + str(msg) + ']: ' + Hora()) # ------------------- MAIN system('cls') print('\n\n\n\n') api = IQ_Option(EMAIL, SENHA) api.connect() api.change_balance(BALANCE) par = input('Par: ').upper() entrada_base = float(input('Entrada base: ')) hora_inicio = Hora() banca_inicio = Banca() IniciarThreadChecarConexao() #IniciarThreadAtualizarPayout() IniciarMHI()
ContConct = 0 user = '' password = '' os.system('cls') concx = False matrix() home() login() while (concx == False): banner2() t = controle(user, password) user, password = t logging.disable(level=(logging.DEBUG)) IQ = IQ_Option(user, password) IQ.connect() if IQ.check_connect() == False: banner2() for i in range(42): time.sleep(0.1) sys.stdout.write("\rConectando: %d%%" % i) while (i > 101): os.system('cls') sys.stdout.flush() print('\nErro ao se conectar...') ContConct += 1 time.sleep(2) if (ContConct == 4): banner2() print('Verfique sua conexão com a internet ou seu e-mail/senha...') print('Por questões de segurança o sistema será encerrado!')
from iqoptionapi.stable_api import IQ_Option I_want_money = IQ_Option("username", "password") I_want_money.connect() I_want_money.buy(10, "EURUSD", "call", 10) print('sss', I_want_money.get_balance()) # Follow this url to make trade in iq logic in case of long term forex trading # https://libraries.io/pypi/iqoption-stable-api