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
52 stars 54 forks source link

Issue Placing Orders #42

Closed MightyMaxSaviorOfTheUniverse closed 5 years ago

MightyMaxSaviorOfTheUniverse commented 5 years ago

Hello,

First off I would just like to thank you for making such a method of trading possible.

Currently I'm having an issue on placing bets. The program keeps on saying that I have placed the bet too late. I do realise that you have solved a similar threat in the past (https://github.com/harwee/IQOption-Api/issues/34) but I would really appreciate it if you provided me with a full set of instructions I could merely copy and paste.

Coming directly from you I would feel more confident in that this is the way the buy order should be placed

Could you provide me with a working example?

Here is my code at present:

from iqoption_api import IQOption iqoption = IQOption("@gmx.com","") iqoption.start()

EURUSD = iqoption.options["binary"]["EURUSD-OTC"] EURUSD.subscribe_sync() print(EURUSD.buy_v2_sync(1,"put",1,1,"1M"))

I understand that I need to use a specific expiration time given to me by using the EURUSD.get_expiration_list_sync() command... but as of yet I haven't been able to figure out how I should inappropriate it so that it actually works

Thank you in advance

harwee commented 5 years ago

Sorry for the late reply, you can only place oeders when it is

If you check this line you can see that it takes params expiration and expiration_type, the expiration is a timestamp before which you have can place the order. To get all the the expiration times you have to query EURUSD.get_expiration_list_sync() this gives you all the expiry times

Something Like

expiration_list = EURUSD.get_expiration_list_sync()
print(EURUSD.buy_v2_sync(1,"put",1,expiration_list["1M"][0],"1M"))
MightyMaxSaviorOfTheUniverse commented 5 years ago

Agh Thank you for the reply, however now I'm getting the following error when I use this code

expiration_list = EURUSD.get_expiration_list_sync() Error: File "C:\Users\%$#@\Desktop\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'

I googled it to check if this was an error having to do with my python, but it appears that it is a code error of some sort.

Any suggestions?

MightyMaxSaviorOfTheUniverse commented 5 years ago

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 :)

harwee commented 5 years ago

OTC is only available when it's weekend, so if you are doing trade on weekends you have to use OTC and on during weekdays you have to use non OTC. I will close this issue now.