diff --git a/README.md b/README.md index bb94cb63..d519642a 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/iqoptionapi) -last Version:3.9.1 +last Version:3.9.2 last update:2019/9/11 + +Version:3.9.2 + +[fix buy() for support OS:window](#buy) + + Version:3.9.1 please update to 3.9.1 diff --git a/iqoptionapi/expiration.py b/iqoptionapi/expiration.py index d26a9237..434ef5e8 100644 --- a/iqoptionapi/expiration.py +++ b/iqoptionapi/expiration.py @@ -8,14 +8,14 @@ def get_expiration_time(timestamp,duration): # now_date = datetime.fromtimestamp(timestamp) exp_date=now_date.replace(second=0,microsecond=0) - if (int((exp_date+timedelta(minutes=1)).strftime("%s"))-timestamp)>30: + if (int((exp_date+timedelta(minutes=1)).timestamp())-timestamp)>30: exp_date= exp_date+timedelta(minutes=1) else: exp_date= exp_date+timedelta(minutes=2) exp=[] for _ in range(5): - exp.append(exp_date.strftime("%s")) + exp.append(exp_date.timestamp()) exp_date= exp_date+timedelta(minutes=1) @@ -25,8 +25,8 @@ def get_expiration_time(timestamp,duration): now_date = datetime.fromtimestamp(timestamp) exp_date=now_date.replace(second=0,microsecond=0) while index60*5: - exp.append(exp_date.strftime("%s")) + if int(exp_date.strftime("%M"))%15==0 and (int(exp_date.timestamp())-int(timestamp))>60*5: + exp.append(exp_date.timestamp()) index=index+1 exp_date= exp_date+timedelta(minutes=1) @@ -43,22 +43,22 @@ def get_expiration_time(timestamp,duration): def get_remaning_time(timestamp): now_date = datetime.fromtimestamp(timestamp) exp_date=now_date.replace(second=0,microsecond=0) - if (int((exp_date+timedelta(minutes=1)).strftime("%s"))-timestamp)>30: + if (int((exp_date+timedelta(minutes=1)).timestamp())-timestamp)>30: exp_date= exp_date+timedelta(minutes=1) else: exp_date= exp_date+timedelta(minutes=2) exp=[] for _ in range(5): - exp.append(exp_date.strftime("%s")) + exp.append(exp_date.timestamp()) exp_date= exp_date+timedelta(minutes=1) idx=11 index=0 now_date = datetime.fromtimestamp(timestamp) exp_date=now_date.replace(second=0,microsecond=0) while index60*5: - exp.append(exp_date.strftime("%s")) + if int(exp_date.strftime("%M"))%15==0 and (int(exp_date.timestamp())-int(timestamp))>60*5: + exp.append(exp_date.timestamp()) index=index+1 exp_date= exp_date+timedelta(minutes=1) diff --git a/iqoptionapi/stable_api.py b/iqoptionapi/stable_api.py index a202a964..c3a06ca1 100644 --- a/iqoptionapi/stable_api.py +++ b/iqoptionapi/stable_api.py @@ -8,7 +8,6 @@ import datetime import pytz from collections import defaultdict -from interruptingcow import timeout from iqoptionapi.expiration import get_expiration_time from datetime import datetime,timedelta @@ -21,7 +20,7 @@ def nested_dict(n, type): class IQ_Option: - __version__ = "3.9.1" + __version__ = "3.9.2" def __init__(self, email, password): self.size = [1, 5, 10, 15, 30, 60, 120, 300, 600, 900, 1800, @@ -202,12 +201,11 @@ def get_all_init_v2(self): self.api.api_option_init_all_result_v2 = None self.api.get_api_option_init_all_v2() - try: - with timeout(30, exception=RuntimeError): - while self.api.api_option_init_all_result_v2==None: - pass - except RuntimeError: - logging.error('**warning** get_all_init_v2 late 30 sec') + start_t=time.time() + while self.api.api_option_init_all_result_v2==None: + if time.time()-start_t>=30: + logging.error('**warning** get_all_init_v2 late 30 sec') + return None return self.api.api_option_init_all_result_v2 # return OP_code.ACTIVES @@ -660,14 +658,12 @@ def buy(self, price, ACTIVES, ACTION, expirations): self.api.buy_successful = None self.api.buy_id = None self.api.buy(price, OP_code.ACTIVES[ACTIVES], ACTION, expirations) - try: - with timeout(30, exception=RuntimeError): - while self.api.buy_successful == None and self.api.buy_id == None: - pass - except RuntimeError: - logging.error('**warning** buy late 30 sec') - - + start_t=time.time() + while self.api.buy_successful == None and self.api.buy_id == None: + if time.time()-start_t>=30: + logging.error('**warning** buy late 30 sec') + return False,None + return self.api.buy_successful,self.api.buy_id @@ -681,12 +677,12 @@ def sell_option(self, options_ids): def get_digital_underlying_list_data(self): self.api.underlying_list_data=None self.api.get_digital_underlying() - try: - with timeout(30, exception=RuntimeError): - while self.api.underlying_list_data==None: - pass - except RuntimeError: - logging.error('**warning** get_digital_underlying_list_data late 30 sec') + start_t=time.time() + while self.api.underlying_list_data==None: + if time.time()-start_t>=30: + logging.error('**warning** get_digital_underlying_list_data late 30 sec') + return None + return self.api.underlying_list_data def get_strike_list(self, ACTIVES, duration): diff --git a/iqoptionapi/ws/chanels/buyv2.py b/iqoptionapi/ws/chanels/buyv2.py index 0ba61262..cde452ad 100644 --- a/iqoptionapi/ws/chanels/buyv2.py +++ b/iqoptionapi/ws/chanels/buyv2.py @@ -23,7 +23,8 @@ def __call__(self, price, active, direction,duration): #https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6 exp,idx=get_expiration_time(int(self.api.timesync.server_timestamp),duration) - if idx<=5: + + if idx<5: option="turbo" else: option="binary" diff --git a/requirements.txt b/requirements.txt index 4f8abc48..e0f1b152 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ pylint requests -websocket-client -interruptingcow \ No newline at end of file +websocket-client \ No newline at end of file diff --git a/setup.py b/setup.py index 7f723499..6942937a 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,9 @@ setup( name="iqoptionapi", - version="3.9.1", + version="3.9.2", packages=find_packages(), - install_requires=["pylint","requests","websocket-client==0.47","interruptingcow"], + install_requires=["pylint","requests","websocket-client==0.47"], include_package_data = True, description="Best IQ Option API for python", long_description="Best IQ Option API for python",