theshadow76 / PocketOptionAPI

The API for Pocket Option broker
29 stars 13 forks source link

Buy Sample is not work! #11

Closed MaximusPro closed 3 months ago

MaximusPro commented 5 months ago

Hello. I'm trying to check example on guidance, but it is not work! I changed line check_connect,message=account.connect() on account.connect() and if check_connect: on if account.check_connect: but it is not get resault.


ssid=r"""42["auth",{"session":"a:4:{s:10:\"session_id\";s:32:\"123123123123\";s:10:\"ip_address\";s:12:\"2.111.11.5\";s:10:\"user_agent\";s:104:\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36\";s:13:\"last_activity\";i:123232;}1232321213","isDemo":0,"uid":"123232132"}]"""
account=PocketOption(ssid)
check_connect,message=account.connect()
if check_connect:
    account.change_balance("PRACTICE")#"REAL"
    asset="EURUSD"
    amount=1
    dir="call"#"call"/"put"
    duration=30#sec
    print("Balance: ",account.get_balance())
    buy_info=account.buy(asset,amount,dir,duration)
    #need this to close the connect
    print("----Trade----")
    print("Get: ",account.check_win(buy_info["id"]))
    print("----Trade----")
    print("Balance: ",account.get_balance())
    #need close ping server thread
    account.close()```
chema2411 commented 5 months ago

@MaximusPro Hello, let me explain why it does not work for you, first the example by which you are guided is not the same API since that example belongs to an API that is sold for about 1000usd I believe and here we are trying to develop it and provide it in a way free so we are all collaborating, there is still no official documentation to use the API of this repository since it is under development, but in this version the buy function already works.

chema2411 commented 5 months ago

please try with:

if account.check_connect:
     #the rest in your code, keep in mind that the change_account function has not yet been implemented, this must be done by editing the ssid, the part that says "isDemo=0" to "isDemo=1", when you connect like this it would automatically be in the demo account.