Skip to content

Commit

Permalink
v3.9.2 support window
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu-Yi-Hsun committed Sep 11, 2019
1 parent 0e342c7 commit cf0c8d6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions iqoptionapi/expiration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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 index<idx:
if int(exp_date.strftime("%M"))%15==0 and (int(exp_date.strftime("%s"))-int(timestamp))>60*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)

Expand All @@ -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 index<idx:
if int(exp_date.strftime("%M"))%15==0 and (int(exp_date.strftime("%s"))-int(timestamp))>60*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)

Expand Down
40 changes: 18 additions & 22 deletions iqoptionapi/stable_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion iqoptionapi/ws/chanels/buyv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pylint
requests
websocket-client
interruptingcow
websocket-client
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit cf0c8d6

Please sign in to comment.