Lu-Yi-Hsun / iqoptionapi

IQ Option API
372 stars 289 forks source link

ERROR:root:**error** get_candles need reconnect #29

Open sqlsaikumar opened 6 years ago

sqlsaikumar commented 6 years ago

Hey Hi @Lu-Yi-Hsun , Most of the time while fetching 1min candle it raising

ERROR:root:**error** get_candles need reconnect .

Because of re-connection i'm missing some 1min candles .Is there anything that i need to add in my code to increase the connection buffer. Here is my code .

from iqoptionapi.stable_api import IQ_Option
import datetime
import time
import subprocess
import pymysql
import json
import string
import sys
import logging
I_want_money=IQ_Option("user","password")
goal=sys.argv[1]
pt=I_want_money.get_candles(goal,60,2,time.time())
x=json.dumps(pt[0])
y=json.dumps(pt[1])
Lu-Yi-Hsun commented 6 years ago

@sqlsaikumar I think you can try real-time sample ,it is candle stream I think it can work better

sqlsaikumar commented 6 years ago

Thanks for the update @Lu-Yi-Hsun , Tried the realtime candle . but its not accepting the parameters .Below is the code i tried

from iqoptionapi.stable_api import IQ_Option
import logging
import time
I_want_money=IQ_Option("email","password")
goal="EURUSD"
size=60
maxdict=10
I_want_money.start_candles_stream(goal,size,maxdict)
time.sleep(10)
cc=I_want_money.get_realtime_candles(goal,size)
for k in cc:
    print(goal,"size",k,cc[k])
print("stop candle")
I_want_money.stop_candles_stream(goal,size)

it raising error . I think its not accepting more than 1 parameter : is there any thing like we get 1min candle from realtime stream.

Traceback (most recent call last):
  File "test.py", line 18, in <module>
    thread=I_want_money.collect_realtime_candles_thread_start(goal,60,100)
TypeError: collect_realtime_candles_thread_start() takes 3 positional arguments but 4 were given
Lu-Yi-Hsun commented 6 years ago

Check your iqoption version is last version

sqlsaikumar commented 6 years ago

yes @Lu-Yi-Hsun . i upgraded it to latest one,Still im getting the same , unable to pass parameters

Lu-Yi-Hsun commented 6 years ago

@sqlsaikumar first check your version is 2.1.1 if not please uninstall all all and reinstall

I_want_money=IQ_Option("email","password")
print(I_want_money.__version__)

than run this sample

from iqoptionapi.stable_api import IQ_Option
import logging
import time
#logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
print("login...")
I_want_money=IQ_Option("email","password")
goal="EURUSD"
size="all"#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
maxdict=10
print("start stream...")
I_want_money.start_candles_stream(goal,size,maxdict)
#DO something
print("Do something...")
time.sleep(10)

print("print candles")
cc=I_want_money.get_realtime_candles(goal,size)
for k in cc:
    print(goal,"size",k,cc[k])
print("stop candle")
I_want_money.stop_candles_stream(goal,size)