harwee / IQOption-Api

** Unmaintained ** I have rewritten some of the functionality using async if you are want to use the updated code you can use the code from `async` branch
Apache License 2.0
53 stars 54 forks source link

How do you trade with Over the Counter (OTC)???? #55

Closed MightyMaxSaviorOfTheUniverse closed 5 years ago

MightyMaxSaviorOfTheUniverse commented 5 years ago

Hello

I see that this is a problem that many people have had, that over the counter stocks don't have an expiration list.

Has anyone figured out how to trade with over the counter stocks? It's really annoying that I can't make money when the stock exchange is closed

MightyMaxSaviorOfTheUniverse commented 5 years ago

Solution, replace the existing code in 'binary_option.py' with my modifications

async def get_expiration_list(self):
        server_time = int(self._parent._server_time/1000)

        if server_time%60 < 30:
            closest_minute_expiration = server_time-server_time%60+60
        else:
            closest_minute_expiration = server_time-server_time%60+120

        expirations_1M = [closest_minute_expiration+i*60 for i in range(5)]
        expirations_15M = [int(key) for key, value in self._option["bet_close_time"].items() if self._parent._server_time/1000 < int(key)-self._deadtime and value["enabled"] and self._option["exp_time"] == 900]
        expiration_EOD = 0
        expiration_EOW = 0
        expiration_EOM = 0
        if(len(str(self._option["special"]))>3):
            for key, value in self._option["special"].items():
                if value["title"].endswith("End of day"):
                    expiration_EOD = int(key)
                elif value["title"].endswith("End of week"):
                    expiration_EOW = int(key)
                elif value["title"].endswith("End of month"):
                    expiration_EOM = int(key)
        return {"1M":expirations_1M,"15M":expirations_15M,"EOD":expiration_EOD,"EOW":expiration_EOW,"EOM":expiration_EOM}