harwee/IQOption-Api

Error trying to get the expiration list

Opened this issue · 8 comments

i'm trying to get the expiration list but all that i get is this error, i dont have any idea how to solve this.

error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\WMoraes\Desktop\Api Iq\IQOption-Api-async\iqoption_api\binary_option.py", line 62, in get_expiration_list_sync
return asyncio.run_coroutine_threadsafe(self.get_expiration_list(),self._parent._async_loop).result()
File "C:\Users\WMoraes\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures_base.py", line 432, in result
return self.__get_result()
File "C:\Users\WMoraes\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures_base.py", line 384, in __get_result
raise self._exception
File "C:\Users\WMoraes\Desktop\Api Iq\IQOption-Api-async\iqoption_api\binary_option.py", line 24, in get_expiration_list
for key, value in self._option["special"].items():
AttributeError: 'list' object has no attribute 'items'

any sugestion?

thanks

I have been trying to resolve the same issue

1+ up this issue

Hey I got great news for you!

I found the solution :)

/////Broken Code/////
EURUSD = iqoption.options["binary"]["EURUSD-OTC"]
expiration_list = EURUSD.get_expiration_list_sync()
/////Broken code////

The above broken code results in an error. The solution is to exclude -OTC from the currencies name

////working code////
EURUSD = iqoption.options["binary"]["EURUSD"]
EURUSD.subscribe_sync()
expiration_list = EURUSD.get_expiration_list_sync()
////working code////

Well happy programming and goodluck :)

@WMoraes13

I'm getting the error again and I know what is causing it. The expiration list doesn't seem to work when using over 'the counter stocks'. Which is why removing OTC from EURUSD-OTC seems to fix it only it also means you are not trading in over the counter. I'm going to run a test before sending this message to see if we can use the sync list of the none over the counter for the over the counter stocks. That makes sense right?

Well I just tested it and the result is that when you place an order the return is 'None' which is similar to another users issue here

#46

I'm sorry it looks like we are both stuck on this point... hopefully someone smart helps us

@lucianopinheiro <----- Like this guy

I don't use this software, sorry. But it looks like the object is not as expected.

BinaryOption is based on Option, wich has an attribute called _option["special"]. For some reason, at EURUSD-OTC this attribute is a list, not a dictionary. And the method get_expiration_list expects a dictionary.

Why? I don't know. You can investigate logging the response and seeing how the attribute _option is formed at class Option. You then find what is the difference among EURUSD and EURUSD-OTC options.

glira commented

I Fix this using
if len(self._option["special"])>0:
for key, value in self._option["special"].items():

if len(self._option["special"])>0:
for key, value in self._option["special"].items():

By that.. what do you mean exactly?

It means that you will use items() only when the option is special.
I Assume that when not special (whatever it means) there are no items (whatever it means).

Thanks for the help @lucianopinheiro and @glira

Turns out if a stock doesn't have the 'special' category in its lists then it can't be traded with. The special is actually the time period in which you can trade with it, so without the special it means there is no window available for trade.

if your program returns an error when you run the below code, then it means you can't trade with this stock

_Stock = iqoption.options["binary"][Stockname]

print(Stock.option["special"].items())

it is best to wrap everything in an exception along with a

Stock.subscribe_sync()

Since this is another problem which means a stock cant be traded with, if you can't sync