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)))
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
0 else round(x['close_profit'] - x['invest'], 2)) + ' | INICIO OP: ' + str(timestamp_converter(x['open_time'] / 1000)) + ' / FIM OP: ' + str(timestamp_converter(x['close_time'] / 1000))) print('\n') par = 'EURUSD' entrada = 2 direcao = 'call' timeframe = 1 # Entradas na digital _, id = API.buy_digital_spot(par, entrada, direcao, timeframe) if isinstance(id, int): while True: status, lucro = API.check_win_digital_v2(id) if status: if lucro > 0: print('RESULTADO: WIN / LUCRO: ' + str(round(lucro, 2))) else: print('RESULTADO: LOSS / LUCRO: -' + str(entrada)) break # Entradas na binaria status, id = API.buy(entrada, par, direcao, timeframe) if status: resultado, lucro = API.check_win_v3(id) print('RESULTADO: ' + resultado + ' / LUCRO: ' + str(round(lucro, 2)))
input("\n\n Aperte enter para sair") sys.exit() porcentagem_lucro = 10 entrada = 10.0 par = "EURUSD" timeframe = 1 valor_minimo = round(float(entrada) * (float(porcentagem_lucro / 100)), 2) API.subscribe_strike_list(par, timeframe) status, id = API.buy_digital_spot(par, entrada, "put", timeframe) time.sleep(2) while API.get_async_order(id)["position-changed"]["msg"]["status"] == "open": vpv = round(API.get_digital_spot_profit_after_sale(id), 2) 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: " + ("WIN - " if valor > 0 else "LOSS - ") + str(round(valor, 2)))
dir = ('call' if tipo_mhi == 1 else 'put') if dir: print('Direção:', dir) valor_entrada = valor_entrada_b for i in range(martingale): status, id = API.buy_digital_spot( par, valor_entrada, dir, 1) if operacao == 1 else API.buy( valor_entrada, par, dir, 1) if status: while True: try: status, valor = API.check_win_digital_v2( id) if operacao == 1 else API.check_win_v3(id) except: status = True valor = 0 if status: valor = valor if valor > 0 else float( '-' + str(abs(valor_entrada))) lucro += round(valor, 2) print('Resultado operação: ', end='') print('WIN /' if valor > 0 else 'LOSS /', round(valor, 2), '/', round(lucro, 2), ('/ ' + str(i) + ' GALE' if i > 0 else '')) valor_entrada = Martingale(valor_entrada, payout)
#Compra compra_status, id = API.buy_digital_spot(par, valor, entrada, tempo) print("Status da compra: ", compra_status, id) print("Aguardando resultado...") while compra_status == False: numberRandom = randint(0, 7) par = pares[numberRandom] compra_status, id = API.buy_digital_spot(par, valor, entrada, tempo) if compra_status == True: break #result = API.check_win_v3(id) while True: check, win = API.check_win_digital_v2(id) if check == True: break if win < 0: valor = (valor * 1.05) * 2 erro += 1 if erro > gale: erroCont += 1 numberRandom = randint(0, 7) par = pares[numberRandom] valor = investimento erro = 0 acertividade = (100 * acerto) / (acerto + erroCont) else:
class MHI: def __init__(self, email, password): self.API = IQ_Option(email, password) self.config = configuration.getConfig() self.connection() def connection(self): self.API.connect() self.API.change_balance('PRACTICE') if self.API.check_connect(): print(' Conectado com sucesso!') else: print(' Erro ao conectar') sys.exit() def stop(self, lucro): if lucro <= float(-1 * abs(self.config['stop_loss'])): print('Stop Loss batido!') sys.exit() if lucro >= float(abs(self.config['stop_gain'])): print('Stop Gain Batido!') sys.exit() def Martingale(self, valor, payout): lucro_esperado = valor * payout perca = float(valor) while True: if round(valor * payout, 2) > round( abs(perca) + lucro_esperado, 2): return round(valor, 2) break valor += 0.01 def Payout(self, par=''): if par.strip() != '': self.API.subscribe_strike_list(par, 1) while True: d = self.API.get_digital_current_profit(par, 1) if d != False: d = round(int(d) / 100, 2) break time.sleep(1) self.API.unsubscribe_strike_list(par, 1) return d def isTime(self): minutos = float(((datetime.now()).strftime('%M.%S'))[1:]) return True if (minutos >= 4.58 and minutos <= 5) or minutos >= 9.58 else False def getColors(self): velas = self.API.get_candles(self.config['par'], 60, 3, time.time()) retorno = '' for i in range(len(velas)): if velas[i]['open'] < velas[i]['close']: retorno += 'g' elif velas[i]['open'] > velas[i]['close']: retorno += 'r' else: retorno += 'd' return retorno def getDirection(self, cores): dir = False if cores.count('g') > cores.count('r') and cores.count('d') == 0: dir = ('put' if self.config['tipo_mhi'] == 1 else 'call') if cores.count('r') > cores.count('g') and cores.count('d') == 0: dir = ('call' if self.config['tipo_mhi'] == 1 else 'put') return dir def buyParity(self, dir): if self.config['operacao'] == 1: return self.API.buy_digital_spot(self.config['par'], self.config['valor_entrada'], dir, 1) else: return self.API.buy(self.config['valor_entrada'], self.config['par'], dir, 1) def finishTrade(self, id): finish = (True, 0) if self.config['operacao'] == 1: finish = self.API.check_win_digital_v2(id) else: finish = (True, self.API.check_win_v3(id)) return finish def startTrade(self, dir, payout): lucro = 0 print('iniciando trader') self.config['valor_entrada'] = self.config['valor_entrada_b'] for i in range(self.config['martingale']): if i > 2: dir = 'put' if dir == 'call' else 'call' buy, id = self.buyParity(dir) if buy: print('Compra efetuada') while True: try: finish, valor = self.finishTrade(id) except: finish = True valor = 0 if finish: print('Operaçao Finalizada') valor = valor if valor > 0 else float( -1 * abs(self.config['valor_entrada'])) lucro += round(valor, 2) self.config['valor_entrada'] = self.Martingale( self.config['valor_entrada'], payout) self.stop(lucro) break if valor > 0: break def start(self): self.config['valor_entrada_b'] = self.config['valor_entrada'] print("Aguardando o horario.") while True: horas = self.isTime() payout = self.Payout(self.config['par']) if payout < (self.config['payout'] / 100): print(f'Payout abaixo do minimo permitido: {payout}') break if horas: cores = self.getColors() dir = self.getDirection(cores) if dir: self.startTrade(dir, payout) time.sleep(0.5)
class Gale: 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.entrada = 'put' self.time = tempo self.account = conta self.pares = [ 'EURUSD-OTC', 'AUDCAD-OTC', 'NZDUSD-OTC', 'USDCHF-OTC', 'GBPUSD-OTC', 'EURJPY-OTC' ] self.par = self.pares[self.RandomNumber()] # Conectando na conta. Retorna se foi feito com sucesso ou não def Connection(self): self.API.connect() if self.API.connect(): self.Account() return print('Successfully connected :D') else: return print('Conection Error D:') # Retorna tipo de conta, se é real ou de pratica def Account(self): return self.API.change_balance(self.account) # Gerando um número random def RandomNumber(self): numberRandom = randint(0, len(self.pares) - 1) return numberRandom # Recebe valor, entrada, tempo def Compra(self): print('Make a buy...') compra_status, self.id_compra = self.API.buy_digital_spot( self.par, self.value, self.entrada, self.time) if compra_status == False: print('Buy Again') self.par = self.pares[self.RandomNumber()] self.Compra() else: print('waiting for the result of the order...') check, result = self.API.check_win_digital_v2(self.id_compra) if result > 0: self.winResult() else: self.lossResult() # Retorna se bateu a meta ou não def winResult(self): self.win += 1 self.loss = 0 if self.win == 10: return print("Meta batida ;D") self.par = self.pares[self.RandomNumber()] self.Compra() # Faz o gale e ainda entra novamente até acertar ou falhar def lossResult(self): self.loss += 1 if self.loss == 3: return print("Hit :/") else: newValue = self.galeValue() compra_status, self.id_compra = self.API.buy_digital_spot( self.par, newValue, self.entrada, self.time) check, newResult = self.API.check_win_digital_v2(self.id_compra) if newResult < 0: self.lossResult() else: newValue = self.value self.winResult() # Retorna o novo valor, fazendo o Maringale def galeValue(self): newValue = self.value newValue = (newValue * 1.15) * 2 return newValue # Verificar e retorna o valor do resultado da operação def resultVerification(self, id): self.API.check_win_digital_v2(self.id_compra) return self.API.check_win_v3(self.id_compra)
#mode = "REAL" iqo.change_balance(mode) balance = (iqo.get_balance()) currency = (iqo.get_currency()) print("Balance : " + str(balance)) market = "EURUSD" amount = 1 dur = 1 act = "put" while True: pps, ids = iqo.buy_digital_spot(market, amount, act, dur) print "trade started wait for 60 seconds" if ids != "error": while True: check, win = iqo.check_win_digital_v2(ids) if check == True: break if win < 0: loss = loss + 1 print("lost") if act == "put": act = "call" else: act = "put" else: print("win") profit = profit + win if cntr == 10: print("--------------")
class IQOption: def __init__(self, email, senha): super().__init__() self.email = email self.senha = senha self.api = IQ_Option(self.email, self.senha) def definirConfiguracoes(self, ativo, timeframe, posicao): self.ativo = ativo self.timeframe = int(timeframe) self.posicao = int(posicao) def efetuarLogin(self): self.conectado, erro = self.api.connect() if self.conectado == False: logging.error( "Erro ao tentar entrar na conta IQ Option -> {}".format( str(erro))) return False else: logging.info("Sucesso ao entrar na conta IQ Option") return True def checarAtivo(self, ativo): ativos = self.api.get_all_open_time() if ativos["digital"][ativo]["open"]: logging.info("Ativo encontrado") return True else: logging.error("O ativo {} nao foi encontrado".format(str(ativo))) return False def contaReal(self): self.api.change_balance("REAL") def contaDemo(self): self.api.change_balance("PRACTICE") def pegarSaldo(self): return self.api.get_balance() def pegarMoeda(self): return self.api.get_currency() def setEntrada(self, entrada): try: entrada = float(entrada) except: logging.error("Nao foi possivel definir o preco de entrada") return False if isinstance(entrada, float): self.entrada = entrada return True else: logging.error("Nao foi possivel definir o preco de entrada") return False def copiarEntradas(self): tempo = "PT{}M".format(str(self.timeframe)) self.api.subscribe_live_deal("live-deal-digital-option", self.ativo, tempo, 10) entradas = self.api.get_live_deal("live-deal-digital-option", self.ativo, tempo) while True: time.sleep(3) entradas = self.api.get_live_deal("live-deal-digital-option", self.ativo, tempo) if len(entradas) >= 1: usuario = self.api.pop_live_deal("live-deal-digital-option", self.ativo, tempo) posicao = self.api.request_leaderboard_userinfo_deals_client( usuario["user_id"], usuario["country_id"]) nome = str(usuario["name"]) posicao = posicao["result"]["entries_by_country"]["0"][ "position"] acao = usuario["instrument_dir"] if posicao <= int(self.posicao): print("Abriu ordem: {} ({} mundial) -> {}".format( nome, str(posicao), acao.upper())) _, ordem_id = self.api.buy_digital_spot( self.ativo, self.entrada, acao, self.timeframe) if ordem_id != "error": while True: verificar_ordem, ganhou = self.api.check_win_digital_v2( ordem_id) if verificar_ordem == True: break if ganhou < 0: logging.info("---> Voce perdeu {}{}".format( str(self.pegarMoeda()), str(round(abs(ganhou), 2)))) print("---> Você perdeu {}{}".format( str(self.pegarMoeda()), str(round(abs(ganhou), 2)))) else: logging.info("---> Voce ganhou {}{}".format( str(self.pegarMoeda()), str(round(abs(ganhou), 2)))) print("---> Você ganhou {}{}".format( str(self.pegarMoeda()), str(round(abs(ganhou), 2)))) else: logging.error("Nao foi possivel abrir uma ordem") print("---> Não foi possivel abrir uma ordem") else: logging.info("Deixou passar: {} ({} mundial) -> {}".format( nome, str(posicao), acao.upper())) print("Deixou passar: {} ({} mundial) -> {}".format( nome, str(posicao), acao.upper()))