n1nj4z33 / iqoptionapi

IQ Option API 4.x (Python 2.7) The project is obsolete and is not supported because of problems with access to IQ Options in Russia
119 stars 542 forks source link

How to get changebalance working? #44

Closed burny91 closed 6 years ago

burny91 commented 6 years ago

Hi all,

I do not understand why the method api.changebalance() is not working for me. Could you please give me a hint what I am doing wrong?

My small test shall connect to my IQ account print the real account balance change balance to practice and print then there the balance.

But I only get the current selected balance from the IQ Option application.

I have tried both approaches with but without any success.

 # To enable the real account:
api.changebalance(5955150)
# or
api.changebalance('real')

# To enable the practive account
api.changebalance('practice')
# or
api.changebalance(12074331)

This is the code. Does anyone see the mistakes I am doing?

from iqoptionapi.api import IQOptionAPI
import time

def accountBalance():
    api = None
    api_info = None
    balance_r = 0
    balance_p = 0

    while True:
        if api is None:
            print "Connecting to IQ Option Broker"
            api = IQOptionAPI("iqoption.com","user", "pw")
            api_info = api.connect()
             # To enable the real account:
            api.changebalance(5955150)
#             api.changebalance('practice')
            #api.changebalance('real')
            if api != None:
                print "Connection Established"
        else:
            # To enable the real account:
            #api.changebalance('real')
#             api.changebalance(5955150)
            balance_r = api.profile.balance        

            print balance_r
            # To enable the practice account:
#             api.changebalance(12074331)
            #api.changebalance('practice')
            balance_p = api.profile.balance
            print balance_p

            api.changebalance(12074331)
            balance_p = api.profile.balance
            print balance_p 
            return

accountBalance()

BR Burny

burny91 commented 6 years ago

Found the solution. Needed to find and select my own profile id. Then the balance changes works at a glance.

milteven12 commented 6 years ago

Hello @burny91 , I'm facing the same situation, my script is always in demo account, please, could you explain how can I retrieve the profile id?