forked from n1nj4z33/iqoptionapi
-
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
907e145
commit f53a555
Showing
6 changed files
with
176 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#python | ||
import time | ||
from datetime import datetime,timedelta | ||
|
||
|
||
|
||
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: | ||
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_date= exp_date+timedelta(minutes=1) | ||
|
||
|
||
|
||
idx=50 | ||
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")) | ||
index=index+1 | ||
exp_date= exp_date+timedelta(minutes=1) | ||
|
||
remaning=[] | ||
|
||
for t in exp: | ||
remaning.append(int(t)-int(time.time())) | ||
|
||
close = [abs(x-60*duration) for x in remaning] | ||
|
||
return int(exp[close.index(min(close))]),int(close.index(min(close))) | ||
|
||
|
||
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: | ||
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_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")) | ||
index=index+1 | ||
exp_date= exp_date+timedelta(minutes=1) | ||
|
||
remaning=[] | ||
|
||
for idx, t in enumerate(exp): | ||
if idx>=5: | ||
dr=15*(idx-4) | ||
else: | ||
dr=idx+1 | ||
remaning.append((dr,int(t)-int(time.time()))) | ||
|
||
return remaning | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters