Open btphucvn opened 6 years ago
@btphucvn
thank report it i am fix, now you can get right data
i thing get_candles() not thread safe ,that use the same variable,
but you can try this code to get multi candles, this way is more better than get_candles(), because get_candles() late about 30 sec
from iqoptionapi.stable_api import IQ_Option
import logging
import time
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
I_want_money=IQ_Option("email","password")
I_want_money.start_candles_stream("EURUSD")
thread=I_want_money.collect_realtime_candles_thread_start("EURUSD",100)
I_want_money.start_candles_stream("USDTRY")
thread2=I_want_money.collect_realtime_candles_thread_start("USDTRY",100)
time.sleep(3)
#Do some thing
ans=I_want_money.thread_collect_realtime.items()
for k, v in ans:
print (k, v)
I_want_money.collect_realtime_candles_thread_stop(thread)
I_want_money.stop_candles_stream("EURUSD")
I_want_money.collect_realtime_candles_thread_stop(thread2)
I_want_money.stop_candles_stream("USDTRY")
Hi Anson
Thanks for a great code. I encountered a strange result when executing the code as you give it above. The fields returned for different keys are all the same!
Update I just removed part of my post above. The code produce the expected results this morning. I assume a server problem maybe ?? :)
So far, I am getting non duplicated values. :)
What would be the update of that code? Because start_candles_stream would need three parameters goal,, size, and maxdict. I think collect_realtime_candles_thread_start was replaced by get_realtime_candles also thread_collect_realtime dosnt exist anymore.
@btphucvn
thank report it i am fix, now you can get right data
i thing get_candles() not thread safe ,that use the same variable,
but you can try this code to get multi candles, this way is more better than get_candles(), because get_candles() late about 30 sec
from iqoptionapi.stable_api import IQ_Option import logging import time logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s') I_want_money=IQ_Option("email","password") I_want_money.start_candles_stream("EURUSD") thread=I_want_money.collect_realtime_candles_thread_start("EURUSD",100) I_want_money.start_candles_stream("USDTRY") thread2=I_want_money.collect_realtime_candles_thread_start("USDTRY",100) time.sleep(3) #Do some thing ans=I_want_money.thread_collect_realtime.items() for k, v in ans: print (k, v) I_want_money.collect_realtime_candles_thread_stop(thread) I_want_money.stop_candles_stream("EURUSD") I_want_money.collect_realtime_candles_thread_stop(thread2) I_want_money.stop_candles_stream("USDTRY")
@Lu-Yi-Hsun is function collect_realtime_candles_thread_start still work ?
Hello ALL, I want to get candles of EURUSD and USDTRY. But I only recived candles data of EURUSD. this is my code:
Thank you for your help!!!