Python Forum
Create bot to automate operations in IQ Option
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create bot to automate operations in IQ Option
#1
Hello everyone!
I come to you in need of immense help!

I want to create a bot to automate entries in binary options at the brokerage IQ Option based on a particular strategy.

The strategy can be found here:https://br.tradingview.com/script/hCdpb2YB

This strategy is very effective, but its signals are very fast, and you need a lot of time in front of the screen to get them, in addition to needing extreme speed to get the price rate at the right time.

I don't have a lot of knowledge on the subject. What I have so far are these codes, which I got through google:

That was the beginning: https://github.com/Lu-Yi-Hsun/iqoptionapi

 from iqoptionapi.stable_api import IQ_Option
import time, json, logging, configparser
from datetime import datetime, date, timedelta
from dateutil import tz
import sys

logging.disable(level=(logging.DEBUG))

API = IQ_Option('login', 'senha')
API.connect()

API.change_balance('PRACTICE') # PRACTICE / REAL

while True:
	if API.check_connect() == False:
		print('Erro ao se conectar')
		
		API.connect()
	else:
		print('\n\nConectado com sucesso')
		break
	
	time.sleep(1)

def perfil():
	perfil = json.loads(json.dumps(API.get_profile_ansyc()))
	
	return perfil
	
	'''
		name
		first_name
		last_name
		email
		city
		nickname
		currency
		currency_char 
		address
		created
		postal_index
		gender
		birthdate
		balance		
	'''

def timestamp_converter(x, retorno = 1):
	hora = datetime.strptime(datetime.utcfromtimestamp(x).strftime('%Y-%m-%d %H:%M:%S'), '%Y-%m-%d %H:%M:%S')
	hora = hora.replace(tzinfo=tz.gettz('GMT'))
	
	return str(hora.astimezone(tz.gettz('America/Sao Paulo')))[:-6] if retorno == 1 else hora.astimezone(tz.gettz('America/Sao Paulo'))

def banca():
	return API.get_balance()

def payout(par, tipo, timeframe = 1):
	if tipo == 'turbo':
		a = API.get_all_profit()
		return int(100 * a[par]['turbo'])
		
	elif tipo == 'digital':
	
		API.subscribe_strike_list(par, timeframe)
		while True:
			d = API.get_digital_current_profit(par, timeframe)
			if d != False:
				d = int(d)
				break
			time.sleep(1)
		API.unsubscribe_strike_list(par, timeframe)
		return d

def configuracao():
	arquivo = configparser.RawConfigParser()
	arquivo.read('config.txt')	
		
	return {'seguir_ids': arquivo.get('GERAL', 'seguir_ids'),'stop_win': arquivo.get('GERAL', 'stop_win'), 'stop_loss': arquivo.get('GERAL', 'stop_loss'), 'payout': 0, 'banca_inicial': banca(), 'filtro_diferenca_sinal': arquivo.get('GERAL', 'filtro_diferenca_sinal'), 'martingale': arquivo.get('GERAL', 'martingale'), 'sorosgale': arquivo.get('GERAL', 'sorosgale'), 'niveis': arquivo.get('GERAL', 'niveis'), 'filtro_pais': arquivo.get('GERAL', 'filtro_pais'), 'filtro_top_traders': arquivo.get('GERAL', 'filtro_top_traders'), 'valor_minimo': arquivo.get('GERAL', 'valor_minimo'), 'paridade': arquivo.get('GERAL', 'paridade'), 'valor_entrada': arquivo.get('GERAL', 'valor_entrada'), 'timeframe': arquivo.get('GERAL', 'timeframe')}

def entradas(config, entrada, direcao, timeframe):
	status,id = API.buy_digital_spot(config['paridade'], entrada, direcao, timeframe)

	if status:
		# STOP WIN/STOP LOSS
		banca_att = banca()
		stop_loss = False
		stop_win = False

		if round((banca_att - float(config['banca_inicial'])), 2) <= (abs(float(config['stop_loss'])) * -1.0):
			stop_loss = True
			
		if round((banca_att - float(config['banca_inicial'])) + (float(entrada) * float(config['payout'])) + float(entrada), 2) >= abs(float(config['stop_win'])):
			stop_win = True
		
		while True:
			status,lucro = API.check_win_digital_v2(id)
			
			if status:
				if lucro > 0:		
					return 'win',round(lucro, 2),stop_win
				else:				
					return 'loss',0,stop_loss
				break
		
		
	else:
		return 'error',0,False

def sorosgale (perca):
	lucro_total = 0
	nivel = 2   
	mao = 1
	lucro = 0
	print ('\ n Perca total:', perca, '- entrada inicial:', (perca / 2))

	enquanto True:
		
		resultado, lucro = entradas ('EURUSD', (perca / 2) + lucro, 'put', 1)
		
		se resultado == 'ganhar':
			lucro_total + = lucro
			print ('\ n', nivel, '-', mao, '|', resultado, '- lucro:', lucro, '- perder:', perder)
			mao + = 1
		outro:
			lucro_total = 0
			mao = 1
			perder + = perder / 2
			print ('\ n', nivel, '-', mao, '|', resultado, '- lucro:', lucro, '- perder:', perder)
			nĂ­vel + = 1
			
		
		se lucro_total> = perca:
			print ('FIM \ n', nivel, '-', mao, '|', perca, '->', lucro_total)
			pausa
		outro:
			print ('perca atual:', perca, 'lucro:', lucro)[python][python]
Archives: https://drive.google.com/drive/folders/1...sp=sharing

WHAT I NEED:

I want to automate the inputs using two indicators, Bollinger band (period 20 and deviation 2.5) and exponential moving average (period 100).

The rules would be these:
When the candle touches one of the lines of the bollinger band, the bot will enter in the opposite direction (CALL or PUTT) always in the direction of the trend. Example: price above the moving average and candle touches the bottom line Bollinger Band, CALL, expiring for the same candle.
-If you win the first, add the profit plus the fixed value entry to make the second entry. Afterwards, make the next entry with the fixed value again, that is, use level 2 sorogale.
-If you lose, do not martingale.

Rules for not making the operation:
-Do not perform the operation in the opposite direction of the trend, that is, price above the moving average and the candle touches the upper line of the Bollinger band, do not perform the operation, and vice versa.
-Do not perform the operation if the candle crosses the trend line and then touches the line of the Bollinger band.
-if the candle has an expiration less than or equal to 1m29s and touch the line of the Bollinger band, do not perform the operation.

I need to get these signals to arrive at IQ Option and I thought of 3 ways: receiving these signals from MT4, receiving these signals from tradingview.com itself or receiving from the IQ Option itself. From IQ Option I was able to receive data from the moving average, but I was unable to receive data from Bollinger bands.

I want to learn how to create these codes! Please give me directions on how to proceed. If you know something relevant that would make it easier, share it too. I would like to keep this code open after completion for everyone to use!

Thanks for your attention! Big Grin

[Image: 4SG1nby]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Replicate Excel operations with Python Lumberjack 3 934 May-10-2022, 01:44 AM
Last Post: Lumberjack
  Program demonstrates operations of bitwise operators without using bitwise operations ShawnYang 2 1,212 Aug-18-2021, 03:06 PM
Last Post: deanhystad
  Random Choice Operations Souls99 6 2,014 Jul-31-2020, 10:37 PM
Last Post: Souls99
  Two operations in two ranges salwa17 3 1,514 Jun-22-2020, 04:15 PM
Last Post: perfringo
  How to avoid slow cursor operations? sevensixtwo 0 1,400 Oct-11-2019, 02:23 PM
Last Post: sevensixtwo
  Operations on indexed variables in loop Fibulavie 1 1,488 Aug-14-2019, 06:07 AM
Last Post: fishhook
  Confused by order of operations ward 4 1,939 Jan-22-2019, 08:53 PM
Last Post: Larz60+
  1. How can I automate this batch creation of documents? 2. How can I automate posting SamLearnsPython 2 2,631 Jul-02-2018, 11:36 AM
Last Post: buran
  Beginner user: mathematical operations Mahdi1994 1 2,329 Mar-19-2018, 11:07 AM
Last Post: Larz60+
  Exponentiation order of operations Slatye 6 4,190 Oct-10-2017, 07:49 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020