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()
EMAIL = Credentials().email # email de login PASSWORD = Credentials().password # senha da conta CYCLE_DURATION = 15 # tempo de cada ciclo EXPIRATION_TIME = 5 # tempo de expiração ACTION = 'put' # call/put MINIMUN_PAYOUT = 74 # payout mínimo pra fazer a entrada OPERATIONS = {} # lista de operações do dia ALL_ASSETS = [] # lista com todos os ativos INITIAL_BALANCE = 0 # banca inicial while True: try: print('Trying to connect...') API = IQ_Option(EMAIL, PASSWORD) API.set_max_reconnect(5) API.change_balance(ACCOUNT) except: print('Error defining API, trying again') continue break while True: if API.check_connect() == False: print('Not connected') API.connect() else: print('Connected') break time.sleep(1) results_file = open('results/results_{}.txt'.format(FILE_NAME), 'a+')
import datetime import gsheet import os from iqoptionapi.stable_api import IQ_Option os.system('clear') ## INITIALIZE PART ## # Connecting to IQ server. # allow to logging. # logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s') # iq option setting. iq = IQ_Option('*****@*****.**', '5big09oN') mode = 'PRACTICE' # allow unlimited reconnect, (_) number of reconnection. iq.set_max_reconnect(-1) # Check connection. while iq.check_connect() == False: # detect the websocket is close print("try reconnect") iq.connect() # try to connect print("reconnect Success") time.sleep(1) # send status updated. print("\n\n\tConnection Success.\n\n") print('\nWorking in \"' + mode + ' MODE\"\n') # check balance and change mode. iq.change_balance(mode) balance = float(str(iq.get_balance()))
from iqoptionapi.stable_api import IQ_Option import time API = IQ_Option('login', 'senha') API.set_max_reconnect(3) API.change_balance('PRACTICE') #PRACTICE/REALg while True: if API.check_connect() == False: print('Erro ao conectar') API.reconnect() else: print('Conectado com sucesso') break time.sleep(1)
from iqoptionapi.stable_api import IQ_Option import time import logging import matplotlib.pyplot as plt from mpl_finance import candlestick_ohlc from matplotlib.animation import FuncAnimation import numpy as np # logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s') login = IQ_Option('*****@*****.**', 'letminjojo') login.set_max_reconnect(-1) endTime = time.time() dataCandleSum = [] dataClose = [] dataOpen = [] dataHigh = [] dataLow = [] countMt = 0 countWin = 0 countLose = 0 maxMt = 0 fig = plt.figure() ax1 = plt.subplot2grid((1, 1), (0, 0)) # while True: # # Reconnect # if login.check_connect() == False: # print("try reconnect") # login.connect() # time.sleep(1) # for i in range(2):