Skip to content

Commit

Permalink
3.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu-Yi-Hsun committed Oct 15, 2019
1 parent 3ea65bf commit 7ac4a07
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 6 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/iqoptionapi)

last update:2019/10/15
last update:2019/10/16

Version:3.9.8
add [reset_practice_balance](#resetpracticebalance) api



Version:3.9.7

Expand Down Expand Up @@ -1151,10 +1156,23 @@ I_want_money.get_all_traders_mood(goal)
```

### Account

#### get balance
```python
I_want_money.get_balance()
```


#### <a id=resetpracticebalance>reset practice balance</a>

reset practice balance to $10000

```python
from iqoptionapi.stable_api import IQ_Option
I_want_money=IQ_Option("email","password")
print(I_want_money.reset_practice_balance())
```

#### Change real/practice Account
```python
I_want_money.change_balance(MODE)
Expand Down
15 changes: 14 additions & 1 deletion iqoptionapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class IQOptionAPI(object): # pylint: disable=too-many-instance-attributes
buy_multi_result = None
buy_multi_option = {}
#
result=None
result = None
training_balance_reset_request=None
# ------------------

def __init__(self, host, username, password, proxies=None):
Expand Down Expand Up @@ -299,6 +300,18 @@ def token(self):
# <iqoptionapi.http.profile.Profile>`.
# """
# return Profile(self)
def reset_training_balance(self):
# sendResults True/False
# {"name":"sendMessage","request_id":"142","msg":{"name":"reset-training-balance","version":"2.0"}}
logger = logging.getLogger(__name__)
data = json.dumps(dict(name="sendMessage",
msg={"name": "reset-training-balance",
"version": "2.0"}
)
)

logger.debug(data)
self.websocket.send(data)

@property
def changebalance(self):
Expand Down
9 changes: 7 additions & 2 deletions iqoptionapi/stable_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def nested_dict(n, type):


class IQ_Option:
__version__ = "3.9.7"
__version__ = "3.9.8"

def __init__(self, email, password):
self.size = [1, 5, 10, 15, 30, 60, 120, 300, 600, 900, 1800,
Expand Down Expand Up @@ -366,7 +366,12 @@ def get_balance_mode(self):
return "REAL"
elif self.api.profile.balance_type == 4:
return "PRACTICE"

def reset_practice_balance(self):
self.api.training_balance_reset_request=None
self.api.reset_training_balance()
while self.api.training_balance_reset_request==None:
pass
return self.api.training_balance_reset_request
def change_balance(self, Balance_MODE):
real_id = None
practice_id = None
Expand Down
3 changes: 2 additions & 1 deletion iqoptionapi/ws/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ def on_message(self, wss, message): # pylint: disable=unused-argument
pass
self.api.instrument_quites_generated_timestamp[Active_name][period]=message["msg"]["expiration"]["timestamp"]
self.api.instrument_quites_generated_data[Active_name][period]=ans

elif message["name"]=="training-balance-reset":
self.api.training_balance_reset_request=message["msg"]["isSuccessful"]



Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="iqoptionapi",
version="3.9.7",
version="3.9.8",
packages=find_packages(),
install_requires=["pylint","requests","websocket-client==0.47"],
include_package_data = True,
Expand Down
47 changes: 47 additions & 0 deletions tests/test_Binary_Option.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

import unittest
import os
from iqoptionapi.stable_api import IQ_Option
import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')

email=os.getenv("email")
password=os.getenv("password")
class TestBinaryOption(unittest.TestCase):

def test_binary_option(self):
#login
I_want_money=IQ_Option(email,password)
I_want_money.change_balance("PRACTICE")
I_want_money.reset_practice_balance()
self.assertEqual(I_want_money.check_connect(), True)
#start test binary option
ALL_Asset=I_want_money.get_all_open_time()
if ALL_Asset["turbo"]["EURUSD"]["open"]:
ACTIVES="EURUSD"
else:
ACTIVES="EURUSD-OTC"
Money=1
ACTION_call="call"#or "put"
expirations_mode=1
check_call,id_call=I_want_money.buy(Money,ACTIVES,ACTION_call,expirations_mode)
self.assertTrue(check_call)
self.assertTrue(type(id_call) is int)
I_want_money.sell_option(id_call)

ACTION_call="put"
check_put,id_put=I_want_money.buy(Money,ACTIVES,ACTION_call,expirations_mode)
self.assertTrue(check_put)
self.assertTrue(type(id_put) is int)
I_want_money.sell_option(id_put)
I_want_money.check_win_v2(id_put)


I_want_money.get_binary_option_detail()

I_want_money.get_all_profit()

isSuccessful,dict=I_want_money.get_betinfo(id_put)
self.assertTrue(isSuccessful)
I_want_money.get_optioninfo(10)

2 changes: 2 additions & 0 deletions tests/test_Login.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class TestLogin(unittest.TestCase):

def test_login(self):
I_want_money=IQ_Option(email,password)
I_want_money.change_balance("PRACTICE")
I_want_money.reset_practice_balance()
self.assertEqual(I_want_money.check_connect(), True)


0 comments on commit 7ac4a07

Please sign in to comment.