n1nj4z33 / iqoptionapi

IQ Option API 4.x (Python 2.7) The project is obsolete and is not supported because of problems with access to IQ Options in Russia
119 stars 539 forks source link

Exp Time #82

Closed marleymwangi closed 6 years ago

marleymwangi commented 6 years ago

Hey, so I've been looking through the sample code posted here and I can't seem to find a way to change the expiration time for a binary option

The all seem to be one minute ...

Could someone please clarify how I can do this... Thanks

marleymwangi commented 6 years ago

Found it one of the closed ones...

Anyway, in the API folder search for a file named " timesync.py "... You'll find the expiry time there.. You can change it to whatever time you want..

self.__expiration_time = 1......

time seems to be in minutes

lucianopinheiro commented 5 years ago

Not exactly whatever time. There is "turbo" mode and "binary" mode. You may see available times at api_init_all websocket return message.

Aleandro21 commented 5 years ago

@marleymwangi don't work, i have changed the value 1 to 15

Aleandro21 commented 5 years ago

@marleymwangi @lucianopinheiro @boskiv I want to open a position by setting the closing time. for example open 1$ in eur/usd time 13:00 binary. i have try a set self.__expiration_time = * minute , but don't work

lucianopinheiro commented 5 years ago

You have to do something like: minutes = 3 exp_not_rounded = now() + minutes 3 60 round_exp = exp_not_rounded % 60 expiration = exp_not_rounded - round_exp

You should also test if you can open inside next minute or not (for example, if actual seconds > 30).

Also, on TURBO buy mode, you can set just to 5 minutes in advance. bigger times are available only at BINARY buy mode.

You probably should check how many minutes you need against api_init_all variable. If 1 ~ 5, use TURBO If 15, 30, 45, etc., use BINARY.

But you should never use time * minute. Because time is unix_timestamp (seconds since 1970-01-01), not number of minutes from now.

Aleandro21 commented 5 years ago

@lucianopinheiro thanks for your reply, Where should I apply this change in file?

Aleandro21 commented 5 years ago

exp_not_rounded = datetime.datetime.now() + minutes 3 60 TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'int'

lucianopinheiro commented 5 years ago

You should have a function at iqoptionapi/ws/objects/timesync.py This function should return an expiration time for actual time (timesync.server_timestamp). This function uses as parameter the number of minutes to expire. But don't do it before you understand the logic. The main thing is that expire time hits a rounded time, not exactly just 60 seconds from now.

datetime.now() uses a datetime object, not a unix timestamp. Just study a little bit more. :)