这是我的代码和收到的输出:
代码
from iqoptionapi.stable_api import IQ_Option
import time
import threading
import pandas as pd
goal="EURUSD"
email = "email"
password = "password"
Candles_Required = 3
ANS=[]
print("login...")
I_want_money=IQ_Option(email,password)
I_want_money.suspend = 0.1
Threads = []
times = [1565257105, 1565197105, 1565137105]
print("All Times Series : ",times)
def candles_history(tt):
global goal,ANS,times
print(times[tt])
data=I_want_money.get_candles(goal, 60, 1000, times[tt])
ANS =data+ANS
print("Executed Time : ",tt)
df = pd.DataFrame(data)
df.to_csv("AllTimes//"+str(times[tt])+".txt", index=False)
return len(data)
for i in range(Candles_Required):
t = threading.Thread(target = candles_history,args=(i,) )
Threads.append(t)
t.start()
print(i," Process Started")
for thread in Threads:
while thread.is_alive():
print("Thread_output : ",thread.join())
print("Thread is alive")
pass
print("Len ANS : ", len(ANS))
df=pd.DataFrame(ANS)
df = df.sort_values('to')
print(df.head(5))
上述脚本的输出
login...
All Times Series : [1565257105, 1565197105, 1565137105]
1565257105
0 Process Started
1565197105
1 Process Started
1565137105
2 Process Started
Executed Time : 1
Executed Time : 0
Executed Time : 2
Thread_output : None
Thread is alive
Thread_output : None
Thread is alive
Thread_output : None
Thread is alive
Len ANS : 3000
at close from id max min open to volume
0 1565197200001474593 1.12271 1565197140 660039 1.122795 1.12266 1.122755 1565197200 185
1000 1565197200001474593 1.12271 1565197140 660039 1.122795 1.12266 1.122755 1565197200 185
2000 1565197200001474593 1.12271 1565197140 660039 1.122795 1.12266 1.122755 1565197200 185
1 1565197260022881266 1.12296 1565197200 660040 1.122960 1.12271 1.122720 1565197260 321
1001 1565197260022881266 1.12296 1565197200 660040 1.122960 1.12271 1.122720 1565197260 321
结果表明:
我运行thread.join
后的输出是None
。
即使是print(df.head(5))
的输出,前三个值也是相同的。
我正在尝试使用以下API从Iqoption加载3000支蜡烛:IQOPTION_API
但是我得到的输出是3000根蜡烛,但都一样。我无法猜测线程有什么问题。
3000支蜡烛花了3秒,但我想在1秒内得到结果。因此尝试线程。
请建议我如何才能在一秒钟内获得结果。
我希望我对此很清楚。如果有人需要更多信息,请在评论中让我知道。