Lu-Yi-Hsun / iqoptionapi

IQ Option API
372 stars 289 forks source link

get_remaining error #143

Open kkagill opened 4 years ago

kkagill commented 4 years ago
try:        
        remaning_time = self.iqOptionApi.get_remaning(1)
        purchase_time = int(remaning_time) - 30
        return purchase_time
except Exception as e:
        logging.exception(e)
        print(e)    

I find that sometimes i get AttributeError: 'str' object has no attribute 'get_remaning'

Am I getting this error because I called this right before remaining time hit 0? To resolve this, would calling this again will work like below?

try:        
        remaning_time = self.iqOptionApi.get_remaning(1)
        purchase_time = int(remaning_time) - 30
        return purchase_time
except Exception as e:
        logging.exception(e)
        time.sleep(1)
        remaning_time = self.iqOptionApi.get_remaning(1)
        purchase_time = int(remaning_time) - 30
        return purchase_time
Lu-Yi-Hsun commented 4 years ago

I need full source code

kkagill commented 4 years ago
  def get_remaning(self,duration):
        for remaning in get_remaning_time(self.api.timesync.server_timestamp):
            if remaning[0]==duration:
                return remaning[1]
        logging.error('get_remaning(self,duration) ERROR duration')
        return "ERROR duration"

I think the error AttributeError: 'str' object has no attribute 'get_remaning' comes from when your get_remaning returns "ERROR duration".

When do I get ERROR duration?

Lu-Yi-Hsun commented 4 years ago

If you in put error duration,I will be error

Lu-Yi-Hsun commented 4 years ago

https://github.com/Lu-Yi-Hsun/iqoptionapi/blob/master/image/expiration_time.png

Lu-Yi-Hsun commented 4 years ago

duration=[1,2,3,4,5,15,30,45,60....]

kkagill commented 4 years ago

yes.. but i put duration as 1 remaning_time = self.iqOptionApi.get_remaning(1)

but getting this error AttributeError: 'str' object has no attribute 'get_remaning'

Right now, I added time.sleep(1) and call get_remaning one more time.

Lu-Yi-Hsun commented 4 years ago

Ok i will check what happen

Lu-Yi-Hsun commented 4 years ago

@kkagill i can not rebuild the bug

JafferWilson commented 4 years ago

@kkagill Hi, why don't you share a fully working simple example? That will help @Lu-Yi-Hsun and even me if I can be o some help.