iqoptionapi icon indicating copy to clipboard operation
iqoptionapi copied to clipboard

How to use them

Open Marc1993Idel opened this issue 9 years ago • 49 comments

Hey, can you leave a short comment how to use this API? I want to add them to my EA. Thanks

Marc1993Idel avatar Aug 02 '16 10:08 Marc1993Idel

Added a little comment to a README.md

n1nj4z33 avatar Aug 15 '16 00:08 n1nj4z33

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?

engelkohle avatar Aug 19 '16 08:08 engelkohle

hi try to buy on 0 seconds by server time something like

if api.timesync.servertime.seconds == 0: api.buy(args)

n1nj4z33 avatar Aug 21 '16 20:08 n1nj4z33

@n1nj4z33 And what value goes in args?

This project needs documentation.

Could you publish a sample of how to use this API?

joebrassi avatar Aug 28 '16 17:08 joebrassi

@joebrassi Hi, i add sphinx generated documentation http://iqapi.readthedocs.io/en/latest/ I'll add a user guide to wiki soon

n1nj4z33 avatar Aug 31 '16 10:08 n1nj4z33

@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 avatar Aug 31 '16 12:08 joebrassi

@joebrassi api.buy(price, active, option, direction) api.buy(10, 76, "turbo", "call")

n1nj4z33 avatar Aug 31 '16 13:08 n1nj4z33

@joebrassi also you can see here https://github.com/n1nj4z33/iqpy

n1nj4z33 avatar Aug 31 '16 13:08 n1nj4z33

@n1nj4z33 Thank you very much. And a couple more questions,

  1. Is there any way to retrieve the current price from the API?
  2. I see you assign 76 to the parameter "active", what does 76 actually mean?

joebrassi avatar Aug 31 '16 13:08 joebrassi

@joebrassi

  1. No way yet. You just send your price to buy
  2. https://github.com/n1nj4z33/iqapi/blob/master/iqapi/constants.py

n1nj4z33 avatar Aug 31 '16 13:08 n1nj4z33

  1. OK.
  2. Are those the only constants you have? How should I get the number of other symbols?

joebrassi avatar Aug 31 '16 13:08 joebrassi

@joebrassi Im get it from chrome devtools in websocket tab just choose another active ad check

http://i.stack.imgur.com/OIbxT.png

n1nj4z33 avatar Aug 31 '16 13:08 n1nj4z33

I see. Well, it seems that it needs to be completed then.

joebrassi avatar Aug 31 '16 13:08 joebrassi

@joebrassi of course it was )

n1nj4z33 avatar Aug 31 '16 14:08 n1nj4z33

@joebrassi and you can help by doing a pull requests )

n1nj4z33 avatar Aug 31 '16 14:08 n1nj4z33

OK, let me see what I can do.

joebrassi avatar Aug 31 '16 14:08 joebrassi

@joebrassi @engelkohle @Marc1993Idel you can find some information in wiki now https://github.com/n1nj4z33/iqoptionapi/wiki.

n1nj4z33 avatar Sep 01 '16 23:09 n1nj4z33

{'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?

fsnlarson avatar Sep 04 '16 23:09 fsnlarson

@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

fsnlarson avatar Sep 05 '16 18:09 fsnlarson

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

n1nj4z33 avatar Sep 06 '16 15:09 n1nj4z33

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.

engelkohle avatar Sep 10 '16 07:09 engelkohle

How do you set the volume in a call to:

api.buy(price, active, option, direction)
api.buy(10, 76, "turbo", "call")

joebrassi avatar Sep 20 '16 20:09 joebrassi

volume? what does it mean "volume"?

n1nj4z33 avatar Sep 21 '16 21:09 n1nj4z33

Also called "Trading Size" or "Amount".

joebrassi avatar Sep 21 '16 21:09 joebrassi

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

RickyGlobal9 avatar Oct 15 '16 08:10 RickyGlobal9

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

engelkohle avatar Oct 28 '16 08:10 engelkohle

Hi, did you manage to figure out how to resolve the issue with expiration times? I'm kinda stuck at this...

j1and1 avatar Dec 14 '16 15:12 j1and1

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.

engelkohle avatar Dec 27 '16 11:12 engelkohle

Hey @engelkohle thanks that solved the issue with expiration times!

j1and1 avatar Dec 28 '16 14:12 j1and1

hi, how can i retrieve profile data? i would like to get the users balance

jglydes avatar Jan 11 '17 00:01 jglydes