iqoptionapi
iqoptionapi copied to clipboard
How to use them
Hey, can you leave a short comment how to use this API? I want to add them to my EA. Thanks
Added a little comment to a README.md
Hi, after run the api the websocket returns the following json message:
{'msg': {'code': 4, 'isSuccessful': False, 'message': ['Time for purchasing options is over, please try again later.'], 'result': {'request_id': None}}, 'name': 'buyComplete'} {'msg': 1471594551119, 'name': 'timeSync'}
Have you the same problem?
hi try to buy on 0 seconds by server time something like
if api.timesync.servertime.seconds == 0: api.buy(args)
@n1nj4z33 And what value goes in args?
This project needs documentation.
Could you publish a sample of how to use this API?
@joebrassi Hi, i add sphinx generated documentation http://iqapi.readthedocs.io/en/latest/ I'll add a user guide to wiki soon
@n1nj4z33 Yes, but that documentation does not say anything about the parameters accepted by the method buy, it only mentions it. Could you just publish a sample?
@joebrassi api.buy(price, active, option, direction) api.buy(10, 76, "turbo", "call")
@joebrassi also you can see here https://github.com/n1nj4z33/iqpy
@n1nj4z33 Thank you very much. And a couple more questions,
- Is there any way to retrieve the current price from the API?
- I see you assign 76 to the parameter "active", what does 76 actually mean?
@joebrassi
- No way yet. You just send your price to buy
- https://github.com/n1nj4z33/iqapi/blob/master/iqapi/constants.py
- OK.
- Are those the only constants you have? How should I get the number of other symbols?
@joebrassi Im get it from chrome devtools in websocket tab just choose another active ad check
http://i.stack.imgur.com/OIbxT.png
I see. Well, it seems that it needs to be completed then.
@joebrassi of course it was )
@joebrassi and you can help by doing a pull requests )
OK, let me see what I can do.
@joebrassi @engelkohle @Marc1993Idel you can find some information in wiki now https://github.com/n1nj4z33/iqoptionapi/wiki.
{'msg': {'code': 4, 'isSuccessful': False, 'message': ['Time for purchasing options is over, please try again later.'], 'result': {'request_id': None}}, 'name': 'buyComplete'} {'msg': 1471594551119, 'name': 'timeSync'}
@engelkohle Have you found a away around this?
@engelkohle @n1nj4z33
May have solved...
{'msg': {'code': 4, 'isSuccessful': False, 'message': ['Time for purchasing options is over, please try again later.'], 'result': {'request_id': None}}, 'name': 'buyComplete'} {'msg': 1471594551119, 'name': 'timeSync'}
This ^^ Is the result of expiration times. When rounding all turbo expirations to up to nearest minute, and binaries up to the nearest 15 minutes, it works.
Using datetime:
def round_up(tm, nearest=15):
upmins = math.ceil(float(tm.minute)/nearest)*nearest
diffmins = upmins - tm.minute
newtime = tm + datetime.timedelta(minutes=diffmins)
newtime = newtime.replace(second=0)
return newtime
https://github.com/n1nj4z33/iqoptionapi/blob/master/iqoptionapi/ws/objects/timesync.py
@property
def expiration_timestamp(self):
"""Property to get expiration timestamp.
:returns: The expiration timestamp.
"""
return time.mktime(self.expiration_datetime.timetuple())
https://github.com/n1nj4z33/iqoptionapi/blob/master/iqoptionapi/ws/chanels/buyv2.py
so you can try to set expiration time before buy
self.api.timesync.expiration_time = 1
Are we all agree that these workarounds are used to resolve the trouble about the time to buy, that is possible to do only when the time is zero zero seconds? Or it is possible to buy a position in every time using one of workarounds described before? Have implemented a method that wait until the time is to zero zero seconds and then return true.
How do you set the volume in a call to:
api.buy(price, active, option, direction)
api.buy(10, 76, "turbo", "call")
volume? what does it mean "volume"?
Also called "Trading Size" or "Amount".
Hi, i want to develop iqoption autotrade bot for my own strategy but i am not a Python programmer and the api script is in the same lang.
Is here anyone who can convert these scripts to .net C#. I'll helpful to him for this kind job.
Regards
Sorry @n1nj4z33, but your suggest:
self.api.timesync.expiration_time = 1
not work absolutely. At the moment I'm using a function waiting that the seconds are zero, like this:
def zero_zero_seconds(self):
logger = logging.getLogger(__name__)
logger.info("Wait for zero zero seconds.")
while not self.timesync.server_datetime.second == 0:
time.sleep(1)
return True
Hi, did you manage to figure out how to resolve the issue with expiration times? I'm kinda stuck at this...
Hi @j1and1, In /iqoptionapi/ws/objects/timesync.py replace the content of expiration_timestamp() method with the following code:
return time.mktime(self.expiration_datetime.replace(second=0, microsecond=0).timetuple())
It should appear:
@property
def expiration_timestamp(self):
"""
Property to get expiration timestamp.
:returns: The expiration timestamp.
"""
# return time.mktime(self.expiration_datetime.timetuple())
return time.mktime(self.expiration_datetime.replace(second=0, microsecond=0).timetuple())
I'm sure this will help you.
Hey @engelkohle thanks that solved the issue with expiration times!
hi, how can i retrieve profile data? i would like to get the users balance