Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the result data of trades. #17

Open
frxncisjoseph opened this issue Mar 16, 2017 · 16 comments
Open

Getting the result data of trades. #17

frxncisjoseph opened this issue Mar 16, 2017 · 16 comments

Comments

@frxncisjoseph
Copy link

frxncisjoseph commented Mar 16, 2017

Hi,

I don't have the time to fork and manually make a pull request so keep this bumped.
I'll be making a couple pull requests on the weekend which add various functionalities to the API.

In order to receive the status of trades alongside the result...

  1. Add the following code to on line 50 inside the 'iqoptionapi/ws/client.py' file:
if message["name"] == "listInfoData":
    listinfodata = lambda: None
    listinfodata.__dict__ = message["msg"][0]
    self.api.listinfodata.add_listinfodata(listinfodata)
  1. Create a new class in 'iqoptionapi/ws/objects' called 'listinfodata.py' and add the following code:
"""Module for IQ Option Candles websocket object."""
import json

from collections import OrderedDict

from iqoptionapi.ws.objects.base import Base


class ListInfoData(Base):
    def __init__(self):
        super(ListInfoData, self).__init__()
        self.__name = "listInfoData"
        self.__listinfodata_list = OrderedDict()

    @property
    def listinfodata_list(self):
        """Property to get listinfodata list.

        :returns: The list of listinfodata.
        """
        return self.__listinfodata_list

    @listinfodata_list.setter
    def listinfodata_list(self, listinfodata_list):
        """Method to set listinfodata list."""
        self.__listinfodata_list = listinfodata_list

    @property
    def current_listinfodata(self):
        """Method to get current iteminfodata item.

         :returns: The object of listinfodata.
         """
        return self.listinfodata_list[next(reversed(self.listinfodata_list))]

    def get_listinfodata(self, id):
        """Method to get iteminfodata item.

         :returns: The object of listinfodata.
         """
        return self.listinfodata_list[id]

    def add_listinfodata(self, new_listinfodata):
        """Method to add listinfodata."""
        #if new_listinfodata.id not in self.listinfodata_list:
        self.listinfodata_list[new_listinfodata.id] = new_listinfodata
  1. Add the following code as an import inside the 'iqoptionapi/api.py' file.
from iqoptionapi.ws.objects.listinfodata import ListInfoData
  1. Add the following code on line 46 inside the 'iqoptionapi/api.py' file.
listinfodata = ListInfoData()

Once done, you can use the new function by doing the following format, i.e. You can give the result by using the 'win' variable which returns either 'equal' (if the trade is ongoing or a draw), 'win' (if the trade was a win), or 'loose' (if the trade was a loss)

self.api.listinfodata.current_listinfodata.win

or

self.api.listinfodata.get_listinfodata(foo)

For more information on what you can actually get, you can use this JSON data that I've extracted myself while testing.

{"name":"listInfoData","msg":[{"amount":1000000,"id":2095724656,"refund":0,"currency":"USD","currency_char":"$","active_id":1,"active":"EURUSD","value":1.07736,"exp_value":1077360,"dir":"call","created":1489706346,"expired":1489706400,"type_name":"turbo","type":"front.TU","profit":100,"profit_amount":1,"win_amount":1.74,"loose_amount":0,"sum":1,"win":"equal","now":1489706346,"user_id":0,"game_state":0,"profit_income":174,"profit_return":0,"option_type_id":3,"site_id":1,"is_demo":false,"user_balance_id":0,"client_platform_id":9,"re_track":"null","params":null}]}
@frxncisjoseph
Copy link
Author

If you need help then comment below and please leave a thumbs up!

@santiagonn
Copy link

Is is possible that you share your version of the api/bot with all these changes? Thanks a lot!!
Do you know if its possible to run this in a demo account?

@frxncisjoseph
Copy link
Author

Yes, I'm current running the api against my demo account with IQ Option.
You can do this using the self.api.change_balance('practice'); method.

I will upload my own altered version of the api publicly to my repository to be forked.

@frxncisjoseph frxncisjoseph changed the title [Tutorial] How to get the result data of trades. Getting the result data of trades. Mar 23, 2017
@santiagonn
Copy link

@frxncisjoseph great thanks!

@0xAalaoui
Copy link

@frxncisjoseph can't wait to try your altered version of the api.

@crypto-maniac
Copy link

yeahhh !!!

@AllenUchiha
Copy link

great work

@crypto-maniac
Copy link

Hello Frxncisjoseph, could you please upload your altered version please?
thx you :)

@frxncisjoseph
Copy link
Author

@crypto-maniac I have already done so, you can find it available here.

I'll be updating the repository on a regular basis with newer and fulfilled features.

Feel free to make pull requests!

@crypto-maniac
Copy link

You rock !

@frxncisjoseph
Copy link
Author

Keeping this BUMPED as it seems new comers are unaware of how to handle the incoming WS messages.

@Aiacos
Copy link

Aiacos commented Jul 2, 2017

please make a pull request

@shiundu
Copy link

shiundu commented Sep 3, 2017

This is breaking

File "/Users/theHopeful/Projects/iqoptionapi/iqoptionapi/ws/objects/listinfodata.py", line 34, current_listinfodata
return self.listinfodata_list[next(reversed(self.listinfodata_list))]
StopIteration

@frxncisjoseph please help

@jacekv
Copy link
Contributor

jacekv commented Sep 19, 2017

@shiundu
The buy order is most probably the problem. I had the same issue when my buy order did not go through.

@leonardoRampazzo
Copy link

how can i use this self.api.listinfodata.get_listinfodata(foo), to get something like this
{"name":"listInfoData","msg":[{"amount":1000000,"id":2095724656,"refund":0,"currency":"USD","currency_char":"$","active_id":1,"active":"EURUSD","value":1.07736,"exp_value":1077360,"dir":"call","created":1489706346,"expired":1489706400,"type_name":"turbo","type":"front.TU","profit":100,"profit_amount":1,"win_amount":1.74,"loose_amount":0,"sum":1,"win":"equal","now":1489706346,"user_id":0,"game_state":0,"profit_income":174,"profit_return":0,"option_type_id":3,"site_id":1,"is_demo":false,"user_balance_id":0,"client_platform_id":9,"re_track":"null","params":null}]}

I dont know what to use as parameter self.api.listinfodata.get_listinfodata(foo)

@gwdm
Copy link

gwdm commented Mar 17, 2018

if you execute a buy you will get a list info message when you enter the trade and again a listinfo record at expiry of the trade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants