├── requirements.txt ├── sinais.txt ├── Dockerfile ├── config.txt ├── README.md ├── Bot-Telegram.md └── main.py /requirements.txt: -------------------------------------------------------------------------------- 1 | python-dateutil 2 | git+https://github.com/fexd12/iqoptionapi.git 3 | python-telegram-bot -------------------------------------------------------------------------------- /sinais.txt: -------------------------------------------------------------------------------- 1 | M1;eurusd;23:19:00;CALL 2 | M5;eurusd;23:21:00;CALL 3 | M15;eurusd;23:30:00;CALL 4 | H1;eurusd;00:00:00;CALL -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8.1 2 | 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app 5 | 6 | COPY . /usr/src/app 7 | 8 | RUN apt-get update && pip install -r requirements.txt 9 | 10 | CMD ["python","./main.py"] -------------------------------------------------------------------------------- /config.txt: -------------------------------------------------------------------------------- 1 | [GERAL] 2 | stop_win = 30 3 | stop_loss = 15 4 | martingale = S 5 | sorosgale = N 6 | niveis = 1 7 | 8 | [telegram] 9 | telegram_token = 10 | telegram_id = 11 | usar_bot = N -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bot-sinais 2 |
3 | Bot opera apartir de uma lista de sinais(binaria ou digital)
4 |
5 | Exemplo de sinais:
6 |

M1;eurusd;23:19:00;CALL - timeframe de 1 minuto

7 |

M5;gbpusd;03:54:00;CALL - timeframe de 5 minutos

8 |

M15;eurusd;23:30:00;CALL - timeframe de 15 minutos

9 |

H1;eurusd;00:00:00;CALL - timeframe de 1 hora

10 |
11 | Os sinais deve ser inserido em sinais.txt
12 |
13 | Em configuração.txt colocar seu stop_win e stop_loss
14 |
15 | Instalar as dependencias necessarias:
16 |

pip install -r requirements.txt

17 |
18 | Para executar o robo:
19 |

python main.py

20 |
21 | Adicionado bot para Telegram , em que envia mensagem do status de cada operação eo seu resultado. 22 | ler Bot_Telegram para poder usar a nova função. 23 |
24 | Não me responsabilizo por delays e entradas atrasadas do bot. 25 | 26 | BOT em testes. 27 | 28 | "" Usar na conta demo !!"" 29 | -------------------------------------------------------------------------------- /Bot-Telegram.md: -------------------------------------------------------------------------------- 1 | # bot Telegram 2 | 3 | Para habilitar o bot, em config.txt colocar S em usar_bot ou N para nao usar o bot 4 | 5 | Abaixo tutorial de como criar um bot no Telegram 6 | 7 | 1. Fale com o BotFather em https://telegram.me/botfather 8 | 2. Mande uma mensagem `/newbot` pra ele, escolha um nome pro bot 9 | 3. Ele irá responder com um token de acesso, um longo texto de números e letras. Salve esse token em um lugar seguro 10 | 4. Adicione seu novo bot no Telegram 11 | 5. Crie um novo grupo para testes só com você e seu bot 12 | 6. Vá em https://web.telegram.org e clique no seu novo grupo 13 | 7. No link do seu browser, vai aparecer algo do tipo `https://web.telegram.org/#/im?p=g12345678` 14 | 8. Anote esse número no final do link(somente o numero sem o 'g'), ele é o ID desse chat (sendo um chat de grupo, você terá que adicionar um sinal de menos `-` na frente do ID para usá-lo),exemplo -123456789 15 | 9. Instale a dependência: `pip install -r requirements.txt` 16 | 10. Em config.txt,coloque seu token e ID do chat, obtido anteriormente 17 | 18 | Dúvidas? Leia https://github.com/python-telegram-bot/python-telegram-bot 19 | 20 | Lembre-se: não compartilhe seu token com ninguém, nem suba ele no GitHub, ou outras pessoas poderão usar seu bot! -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from iqoptionapi.stable_api import IQ_Option 2 | from datetime import datetime 3 | from dateutil import tz 4 | 5 | import time, json, logging, configparser,sys,telegram 6 | 7 | logging.disable(level=(logging.DEBUG)) 8 | 9 | 10 | def Martingale(valor): 11 | lucro_esperado = float(valor) * 1.5 # gale para recuperacao = 1.5 , gale para cobertura = 2.3 12 | # perca = valor 13 | 14 | # while True: 15 | # if round(valor * payout, 2) > round(abs(perca) + lucro_esperado, 2): 16 | # return round(valor, 2) 17 | # break 18 | # valor += 0.01 19 | return float(lucro_esperado) 20 | 21 | def Payout(par,timeframe): 22 | API.subscribe_strike_list(par, timeframe) 23 | while True: 24 | d = API.get_digital_current_profit(par, timeframe) 25 | if d > 0: 26 | break 27 | time.sleep(1) 28 | API.unsubscribe_strike_list(par, timeframe) 29 | return float(d / 100) 30 | 31 | def banca(): 32 | return API.get_balance() 33 | 34 | def configuracao(): 35 | arquivo = configparser.RawConfigParser() 36 | arquivo.read('config.txt') 37 | 38 | return {'stop_win': arquivo.get('GERAL', 'stop_win'),'stop_loss': arquivo.get('GERAL', 'stop_loss'), 'payout': 0, 'banca_inicial': banca(), 'martingale': arquivo.get('GERAL', 'martingale'), 'sorosgale': arquivo.get('GERAL', 'sorosgale'), 'niveis': arquivo.get('GERAL', 'niveis'),'telegram_token':arquivo.get('telegram','telegram_token'),'telegram_id':arquivo.get('telegram','telegram_id'),'usar_bot':arquivo.get('telegram','usar_bot')} 39 | 40 | def carregaSinais(): 41 | x = open('sinais.txt') 42 | y=[] 43 | for i in x.readlines(): 44 | # print(i) 45 | y.append(i.replace(':00;',';')) 46 | # print (y) 47 | x.close 48 | return y 49 | 50 | def entradas(par, entrada, direcao,config,opcao,timeframe): 51 | if opcao == 'digital': 52 | status,id = API.buy_digital_spot(par, entrada, direcao, timeframe) 53 | if status: 54 | # STOP WIN/STP LOSS 55 | 56 | banca_att = banca() 57 | stop_loss = False 58 | stop_win = False 59 | 60 | if round((banca_att - float(config['banca_inicial'])), 2) <= (abs(float(config['stop_loss'])) * -1.0): 61 | stop_loss = True 62 | 63 | # if round((banca_att - float(config['banca_inicial'])) + (float(entrada) * float(config['payout'])) + float(entrada), 2) >= abs(float(config['stop_win'])): 64 | # stop_win = True 65 | if round((banca_att - float(config['banca_inicial'])), 2) >= abs(float(config['stop_win'])): 66 | stop_win = True 67 | 68 | while True: 69 | status,lucro = API.check_win_digital_v2(id) 70 | 71 | if status: 72 | if lucro > 0: 73 | return 'win',round(lucro, 2),stop_win 74 | else: 75 | return 'loss',0,stop_loss 76 | break 77 | else: 78 | return 'error',0,False 79 | 80 | elif opcao == 'binaria': 81 | status,id = API.buy(entrada,par,direcao,timeframe) 82 | 83 | if status: 84 | lucro = API.check_win_v3(id) 85 | 86 | banca_att = banca() 87 | stop_loss = False 88 | stop_win = False 89 | 90 | if round((banca_att - float(config['banca_inicial'])), 2) <= (abs(float(config['stop_loss'])) * -1.0): 91 | stop_loss = True 92 | 93 | if round((banca_att - float(config['banca_inicial'])), 2) >= abs(float(config['stop_win'])): 94 | stop_win = True 95 | 96 | if lucro: 97 | if lucro > 0: 98 | return 'win',round(lucro, 2),stop_win 99 | else: 100 | return 'loss',0,stop_loss 101 | else: 102 | return 'error',0,False 103 | else: 104 | return 'opcao errado',0,False 105 | 106 | 107 | def timestamp_converter(): 108 | hora = datetime.now() 109 | tm = tz.gettz('America/Sao Paulo') 110 | hora_atual = hora.astimezone(tm) 111 | return hora_atual.strftime('%H:%M') 112 | # hora = datetime.strptime(datetime.utcfromtimestamp(x).strftime('%H:%M:%S'), '%H:%M:%S') 113 | # hora = hora.replace(tzinfo=tz.gettz('GMT')) 114 | 115 | # return str(hora.astimezone(tz.gettz('America/Sao Paulo')))[:-6] if retorno == 1 else hora.astimezone(tz.gettz('America/Sao Paulo')) 116 | 117 | def Timeframe(timeframe): 118 | 119 | if timeframe == 'M1': 120 | return 1 121 | 122 | elif timeframe == 'M5': 123 | return 5 124 | 125 | elif timeframe == 'M15': 126 | return 15 127 | 128 | elif timeframe == 'H1': 129 | return 60 130 | else: 131 | return 'erro' 132 | 133 | def Mensagem(mensagem): 134 | print(mensagem) 135 | if VERIFICA_BOT == 'S': 136 | bot.sendMessage(chat_id = TELEGRAM_ID, text = mensagem) 137 | 138 | def checkProfit(par,timeframe): 139 | all_asset = API.get_all_open_time() 140 | profit = API.get_all_profit() 141 | 142 | digital = 0 143 | binaria = 0 144 | 145 | if timeframe == 60: 146 | return 'binaria' 147 | 148 | if all_asset['digital'][par]['open']: 149 | digital = Payout(par,timeframe) 150 | digital = round(digital,2) 151 | 152 | if all_asset['turbo'][par]['open']: 153 | binaria = round(profit[par]["turbo"],2) 154 | 155 | if binaria < digital : 156 | return "digital" 157 | 158 | elif digital < binaria : 159 | return "binaria" 160 | 161 | elif digital == binaria : 162 | return "digital" 163 | 164 | else : 165 | "erro" 166 | 167 | 168 | API = IQ_Option('','') 169 | API.connect() 170 | API.change_balance('PRACTICE') # PRACTICE / REAL 171 | 172 | global VERIFICA_BOT,TELEGRAM_ID 173 | 174 | config = configuracao() 175 | config['banca_inicial'] = banca() 176 | 177 | VERIFICA_BOT = config['usar_bot'] 178 | TELEGRAM_ID = config['telegram_id'] 179 | 180 | if VERIFICA_BOT == 'S': 181 | bot = telegram.Bot(token= config['telegram_token']) 182 | 183 | if API.check_connect(): 184 | print(' Conectado com sucesso!') 185 | else: 186 | print(' Erro ao conectar') 187 | input('\n\n Aperte enter para sair') 188 | sys.exit() 189 | 190 | valor_entrada = 1.8 191 | valor_entrada_b = float(valor_entrada) 192 | 193 | lucro = 0 194 | 195 | sinais = carregaSinais() 196 | 197 | 198 | # while True: 199 | # minutos = (((datetime.now()).strftime('%H:%M:%S'))[1:]) 200 | for x in sinais: 201 | timeframe_retorno = Timeframe(x.split(';')[0]) 202 | timeframe = 0 if (timeframe_retorno == 'error') else timeframe_retorno 203 | par = x.split(';')[1].upper() 204 | minutos_lista = x.split(';')[2] 205 | direcao = x.split(';')[3].lower().replace('\n','') 206 | mensagem_paridade = 'paridade a ser operada: ' + par + ' ' + '/' + ' ' + 'timeframe: ' + str(timeframe) + ' ' + '/' + ' ' + 'horario: ' + str(minutos_lista) + ' ' + '/' + ' ' + 'direcao: ' + direcao 207 | Mensagem(mensagem_paridade) 208 | # print(par) 209 | while True: 210 | # payout = Payout(par,timeframe) 211 | # config['payout'] = payout 212 | minutos = timestamp_converter() 213 | 214 | # print(minutos_lista) 215 | # minutos_lista_parse = time.strptime(minutos_lista,'%H:%M:%S') 216 | # c = time.strftime('%H:%M:%S', minutos_lista_parse) 217 | # print(c) 218 | if minutos_lista < minutos: 219 | break 220 | 221 | opcao = checkProfit(par,timeframe) 222 | 223 | entrar = True if (minutos_lista == minutos ) else False 224 | # print('Hora de entrar?',entrar,'/ Minutos:',minutos) 225 | # print('Paridade',par) 226 | 227 | if entrar: 228 | Mensagem('\n\nIniciando Operacao') 229 | dir = False 230 | dir = direcao 231 | 232 | if dir: 233 | mensagem_operacao = 'Paridade: ' + par + ' ' + '/' + ' ' + 'opcao: ' + opcao + ' ' + '/' + ' ' + 'Horario: ' + str(minutos_lista) + ' ' + '/' + ' ' + 'Direção: ' + dir 234 | Mensagem(mensagem_operacao) 235 | valor_entrada = valor_entrada_b 236 | opcao = 'binaria' if (opcao == 60) else opcao 237 | resultado,lucro,stop = entradas(par,valor_entrada, dir,config,opcao,timeframe) 238 | mensagem_resultado = ' -> ' + resultado + ' / ' + str(lucro) 239 | Mensagem(mensagem_resultado) 240 | 241 | if resultado == 'error': 242 | break 243 | 244 | if resultado == 'win': 245 | break 246 | 247 | if stop: 248 | mensagem_stop = '\n\nStop '+ resultado.upper() + ' batido!' 249 | Mensagem(mensagem_stop) 250 | sys.exit() 251 | 252 | if resultado == 'loss' and config['martingale'] == 'S': 253 | valor_entrada = Martingale(float(valor_entrada)) 254 | for i in range(int(config['niveis']) if int(config['niveis']) > 0 else 1): 255 | 256 | mensagem_martingale= ' MARTINGALE NIVEL '+ str(i+1)+ '..' 257 | Mensagem(mensagem_martingale) 258 | resultado,lucro,stop = entradas(par, valor_entrada, dir,config,opcao,timeframe) 259 | mensagem_resultado_martingale = ' ' + resultado + ' / ' + str(lucro) + '\n' 260 | Mensagem(mensagem_resultado_martingale) 261 | if stop: 262 | mensagem_stop = '\n\nStop '+ resultado.upper() + ' batido!' 263 | Mensagem(mensagem_stop) 264 | sys.exit() 265 | 266 | if resultado == 'win': 267 | print('\n') 268 | break 269 | else: 270 | valor_entrada = Martingale(float(valor_entrada)) 271 | break 272 | else: 273 | break 274 | time.sleep(0.1) 275 | # break 276 | Mensagem('lista de sinais finalizada') 277 | sys.exit() --------------------------------------------------------------------------------