Lu-Yi-Hsun / iqoptionapi

IQ Option API
373 stars 287 forks source link

Getting only 1000 candles. #39

Closed JafferWilson closed 5 years ago

JafferWilson commented 5 years ago

I have tried the following way to collect the dataset, but got only 1000 candles and no more.

>>> data = pd.DataFrame(I_want_money.get_candles(goal,60,70000, time.time()))
>>> data["at"] = pd.to_datetime(data["at"], format ='%Y.%m.%d %H:%M')
>>> data.to_csv("candles.csv",index=False)

Please help me.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson yes! iqoption only can get 1000 candle once time!! so you need to write a for loop to get more! be careful the time need change!

JafferWilson commented 5 years ago

@Lu-Yi-Hsun Is there no way to get the candles more than 1000? I hope there must be something in the code that can be done. Please help me.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson it need some time, because you only can get 1000 candle once time

from iqoptionapi.stable_api import IQ_Option
import time
I_want_money=IQ_Option("email","password")
end_from_time=time.time()
ANS=[]
for i in range(70):
    data=I_want_money.get_candles("EURUSD", 60, 1000, end_from_time)
    ANS =data+ANS
    end_from_time=int(data[0]["from"])-1
print(ANS)
JafferWilson commented 5 years ago

Thank you @Lu-Yi-Hsun. I tried this. But the candles that I got is something like this:
testiqoption candles I see that the candles returned are not like the actual candles that are on the IQO. Please can you check it once? I see OHLC values but no biid ask values .. may thats the reason for the weird candles.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson How to print candle to that image? Iqoption do not sent ask/bid . Only OHLC

JafferWilson commented 5 years ago

Basically I am using MT5 - Metatrader5 to visualize the candles that are sent through your api. Hence, I am a bit concerned why is this happening? The MT5 show only what it receives. ultimately it just a visualization point for the candles.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson 1.what time you catch the candle

2.give me your raw data (csv file for mt5) what is : Tick Volume /Volume different?

JafferWilson commented 5 years ago

Ok @Lu-Yi-Hsun I will share the data file with you, here it is:

10001candles.txt Please let me know, if there is any issue.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson 1970-01-01? you get the data from iqoption? iqoption do not have volume

JafferWilson commented 5 years ago

Ok check this new file then:
10001candles.txt Please check this.. Still I am having trouble plotting. Please can you check it once.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson try this code output iqoption candle to csv for MT5 i have been check it is same as iqoption plot 1.check MT5 Timeframes is right 2.if you view large gap of candle (1).check your data do not miss (2) or the data is cross to holiday put MT5.csv file to MT5

from iqoptionapi.stable_api import IQ_Option
import time
import datetime
I_want_money=IQ_Option("email","password" )
end_from_time=time.time()
ANS=[]
for i in range(1):
    data=I_want_money.get_candles("EURUSD", 60, 1000, end_from_time)
    ANS =data+ANS
    end_from_time=int(data[0]["from"])-1
ok=""
for li in ANS:
    value = datetime.datetime.fromtimestamp(li["to"])
    exct_time =value.strftime('%Y.%m.%d %H:%M:%S')
    ok=exct_time+","+str(li["open"])+","+str(li["max"])+","+str(li["min"])+","+str(li["close"])+","+str(li["volume"])+"\n"+ok
fp=open("MT5.csv","w+")
fp.write(ok)
JafferWilson commented 5 years ago

@Lu-Yi-Hsun Ok, I will chec it out. I thought the candles returned are not the one from the IQO. I guess the time-frame might be issue. I will check it out. thank you help.

JafferWilson commented 5 years ago

@Lu-Yi-Hsun Have a look at the two images. This one is from the IQoption:
real

The following is from the MT5: got

Kindly, let me know whether they look same to you. Please let me know what might have caused this issue.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson
you check the value is different? i get the same image try this code and we have same timestamp

:heavy_exclamation_mark:please check MT5 and iqoption Timeframes is the same 1 min

from iqoptionapi.stable_api import IQ_Option
import time
import datetime
I_want_money=IQ_Option("email","password" )
end_from_time=1539675885
ANS=[]
for i in range(1):
    data=I_want_money.get_candles("EURUSD", 60, 1000, end_from_time)
    ANS =data+ANS
    end_from_time=int(data[0]["from"])-1
ok=""
for li in ANS:
    value = datetime.datetime.fromtimestamp(li["to"])
    exct_time =value.strftime('%Y.%m.%d %H:%M:%S')
    ok=exct_time+","+str(li["open"])+","+str(li["max"])+","+str(li["min"])+","+str(li["close"])+","+str(li["volume"])+"\n"+ok
fp=open("MT5.csv","w+")
fp.write(ok)

2018-10-16 15-50-41

JafferWilson commented 5 years ago

Hey @Lu-Yi-Hsun can you share the code that you used in MT5 for it? I am trying to make it but getting different result still may be made some another mistake in displaying the stuff.

Lu-Yi-Hsun commented 5 years ago

@JafferWilson you mean MT5 call this api function to produce the candle? i do not know MT5 code! i produce the data from this api,and import the data to MT5

Lu-Yi-Hsun commented 5 years ago

@JafferWilson no! it need to import .csv/.prn/.txt View->Symbols->Create Custom Symbol->click your new Symbol->Bars->import Bars->Browse and you can import the data

JafferWilson commented 5 years ago

Yes yes.. I got it .. I forgot almost.. I am trying it out.. thank you.. I am checking if it works for me.

JafferWilson commented 5 years ago

Dear @Lu-Yi-Hsun Please have a look at this image: I do not understand what might be the issue. I tried everything but still the candles are the same way they looked before. Have a look at the image:
testiqo

There is a lot of dojis. Please let me know whether this is a fault of IQO api or is there anything you think is there any mistake in my way? I tried it your way this time by importing but the same thing happened.

Lu-Yi-Hsun commented 5 years ago

what your timestamp?

JafferWilson commented 5 years ago

Here have a look at the file:
MT5.txt Try using this. I have changed one line from your current where you have mentioned end time: end_from_time=1539675885 to end_from_time=time.time() As I was in need of candles from current time.

Lu-Yi-Hsun commented 5 years ago

check the value is same or different?

JafferWilson commented 5 years ago

See the following @Lu-Yi-Hsun : test Have a look at this. This values are getting truncated I guess.

JafferWilson commented 5 years ago

You helped a lot my friend I guess this is the fault of MT5 itself. I will check with them.

JafferWilson commented 5 years ago

Thank you very much for your help ... :)

Lu-Yi-Hsun commented 5 years ago

@JafferWilson my pleasure