Lu-Yi-Hsun / iqoptionapi

IQ Option API
372 stars 288 forks source link

Check Win #14

Open sampyz opened 6 years ago

sampyz commented 6 years ago

Hello,

is it possible to edit api: I_want_money.check_win() like I_want_money.check_win("EURUSD")?

because i need to check win in a multiple bet

Thanks in advance!

Lu-Yi-Hsun commented 6 years ago

@sampyz ok will try to implement that today

sampyz commented 6 years ago

@Lu-Yi-Hsun i love you!

Lu-Yi-Hsun commented 6 years ago

@sampyz i add I_want_money.check_win(id_number) id_number more clear to get the check win try get last version

and try this code

from iqoptionapi.stable_api import IQ_Option
I_want_money=IQ_Option("email","password")

ok,id_number=I_want_money.buy(2,"EURUSD","call",1,force_buy=False)
print(id_number)
ans=I_want_money.check_win(id_number)
print(ans)
sampyz commented 6 years ago

@Lu-Yi-Hsun Thanks! I will try tomorrow!!! If my bots works i will pay for your job! ;)

sampyz commented 6 years ago

@Lu-Yi-Hsun hello, I have a problem when i try to send id_number to another script running I_want_money.check_win trought a .ini File..

What is it "ok," before id_number=I_want_money.buy(2,"EURUSD","call",1,force_buy=False)? Thanks for your helping

Lu-Yi-Hsun commented 6 years ago

@sampyz

1.sorry i am not understand

hello, I have a problem when i try to send id_number to another script running I_want_money.check_win trought a .ini File..

2."ok" return if "buy" ok(True/False)

some time network or some problem buy not sucess it will return False

sampyz commented 6 years ago

Thanks for your assistance!! Do you know if is it possible to checkwin 2 or more bets at the same time or in the same script??

With the same time expire of course

Lu-Yi-Hsun commented 6 years ago

@sampyz You can try thread

sampyz commented 6 years ago

@Lu-Yi-Hsun Hi mister, i tryed check_win_v2 but is a little bit slowly...i have the result after 5 second...is it possible to make it faster?

Thanks!!!

Lu-Yi-Hsun commented 6 years ago

@sampyz i set sleep 5 sec to Polling check if win,so it is slowly. i will change to 0.5 sec i thing it will better. you can try last version

jackynguyen93 commented 5 years ago

@Lu-Yi-Hsun I got an issue when enter multiple order at a time. ex: id_number1=I_want_money.buy(2,"EURUSD","call",1,force_buy=False) id_number2=I_want_money.buy(2,"EURJPY","call",1,force_buy=False) id_number3=I_want_money.buy(2,"EURAUD","call",1,force_buy=False)

The problem is id_number1 = id_number2 = id_number3, all has the same value. So I cannot get the result. Note that I am using multiple threads

Lu-Yi-Hsun commented 5 years ago

@jackynguyen93

Ok I will fix that

jackynguyen93 commented 5 years ago

@Lu-Yi-Hsun I really appreciate that. Thanks so much

Lu-Yi-Hsun commented 5 years ago

@jackynguyen93

v 3.6.3 fix

jackynguyen93 commented 5 years ago

@Lu-Yi-Hsun It seems still happen My application run 2 threads at the same time but both threads response the same ID Untitled You can see my log show 5211822983 is the response of 2 buy difference requests

Lu-Yi-Hsun commented 5 years ago

@jackynguyen93 Not thread safe, you need to use multi connect

! pseudocode !

import time
from iqoptionapi.stable_api import IQ_Option
def thread(email,password):
    I_want_money=IQ_Option(email,password)
    goal="goal"
    print(I_want_money.get_candles(goal,60,111,time.time()))

do thread1(email,password)
do thread2(email,password)
jackynguyen93 commented 5 years ago

@Lu-Yi-Hsun could you explain more. Do I need to have a connect like _I_want_money=IQOption("email","password") everytime I enter an order?

Lu-Yi-Hsun commented 5 years ago

@jackynguyen93 if you want thread ,you need to build new connect

jackynguyen93 commented 5 years ago

So, is it correct if in my order function I put new_connect=IQ_Option("email","password") and use new_connect to enter the order ?

Lu-Yi-Hsun commented 5 years ago

Yes you need to build other connect ,I suggest use multiprocessing for multi cpu

jackynguyen93 commented 5 years ago

Could you provide me an example or some article related to this? Forgive for my lack of knowledge, python is not my main language

Lu-Yi-Hsun commented 5 years ago

from iqoptionapi.stable_api import IQ_Option
import multiprocessing as mp
import time
import logging
import time
def job(email,passwd):
    I_want_money = IQ_Option(email, passwd)
    id_number=I_want_money.buy(2,"EURJPY","call",1,force_buy=False)
    print("buy-time",time.time(),id_number)
p1 = mp.Process(target=job,args=("email","passwd"))

p2 = mp.Process(target=job,args=("email","passwd"))

p3 = mp.Process(target=job,args=("email","passwd"))

p1.start()
p2.start()
p3.start()

p1.join()
p2.join()
p3.join()

image

you can see buy() speed up by multiprocessing

jackynguyen93 commented 5 years ago

@Lu-Yi-Hsun do you have another solution. I think this solution will cause to delay on order. In my case, it takes about 6s to authenticate and makes a connection. Capture Can we do a thread safe for api or using scope variable instead of global variable to make api doesn't get the last response only

Lu-Yi-Hsun commented 5 years ago

you can start the multiprocessing wait for buy() action

jackynguyen93 commented 5 years ago

you can start the multiprocessing wait for buy() action

Sorry, I don't understand what you mean. An example will more clear with me

Lu-Yi-Hsun commented 5 years ago

you need "6s to authenticate" just only at first time!

use "zmq" to connect multiprocessing request what you want

jackynguyen93 commented 5 years ago

you need "6s to authenticate" just only at first time!

use "zmq" to connect multiprocessing request what you want

So you mean we run many threads at start time and do authenticate for all threads. Then zmq will send signal to each thread and enter order in each one?