Giter Site home page Giter Site logo

mdn522 / binaryapi Goto Github PK

View Code? Open in Web Editor NEW
46.0 8.0 35.0 289 KB

Binary.com & Deriv.com API for Python

Home Page: https://binaryapi.readthedocs.io/

License: GNU General Public License v3.0

Python 100.00%
binary python api automated-trading binary-com binary-options deriv-com deriv-api money trading

binaryapi's Introduction

Hi ๐Ÿ‘‹, I'm Abdullah Mallik

A Python / Django Developer

  • ๐Ÿ’ฌ Ask me about Python, Django, Flask, FastAPI, Web Scraping

Connect with me:

mdn522 mdn522 4854605 mdn522 mdn522 @mdn522

Languages and Tools:

bulma chartjs css3 django flask git html5 javascript postgresql python redis sqlite vuetify

mdn522

ย mdn522

binaryapi's People

Contributors

mdn522 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binaryapi's Issues

Bug Error

from binaryapi.stable_api import Binary

binary_token = "*************"

binary = Binary(token=binary_token)

symbol = "frxEURUSD"
print("Buy a CALL contract")
print(binary.buy('CALL', amount=1, symbol=symbol, duration=5, duration_unit='t'))

DEBUG:binaryapi.api:{"authorize": "************", "req_id": 1}
ERROR:websocket:error from callback <bound method WebsocketClient.on_message of <binaryapi.ws.client.WebsocketClient object at 0xb654ada8>>: on_message() takes 2 positional arguments but 3 were given
ERROR:binaryapi.ws.client:on_message() takes 2 positional arguments but 3 were given

Technical indicators for autotrading

Hi @mdn522
I've been looking all over the internet to automate my strategy but couldn't find anything
could you please add technical indicators like rsi,ema cross,bollinger bands it would really be helpful

If not could you simply give me an example for one indicator rsi for all the available assets
what i want to acheive is receive all the available assets data and calculate rsi with tf-1min period-14 ob/os-70/30
and then take a trade for 5min expiry,Also could you give example for detecting pinbar candles

Install problem

Hi
I am trying to install your library but shell give me some errors:
`C:\Users\Jhon>pip install -U git+git://github.com/mdn522/binaryapi.git
Collecting git+git://github.com/mdn522/binaryapi.git
Cloning git://github.com/mdn522/binaryapi.git to c:\users\jhon\appdata\local\temp\pip-req-build-wcdwqrhl
Running command git clone --filter=blob:none --quiet git://github.com/mdn522/binaryapi.git 'C:\Users\Jhon\AppData\Local\Temp\pip-req-build-wcdwqrhl'
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
error: subprocess-exited-with-error

ร— git clone --filter=blob:none --quiet git://github.com/mdn522/binaryapi.git 'C:\Users\Jhon\AppData\Local\Temp\pip-req-build-wcdwqrhl' did not run successfully.
โ”‚ exit code: 128
โ•ฐโ”€> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

ร— git clone --filter=blob:none --quiet git://github.com/mdn522/binaryapi.git 'C:\Users\Jhon\AppData\Local\Temp\pip-req-build-wcdwqrhl' did not run successfully.
โ”‚ exit code: 128
โ•ฐโ”€> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.`

error message when trying to install bynariapi

hi i got following error message when trying to install bynariapi with spyder and python 3.8.3

In [188]:pip install -U git+git://github.com/mdn522/binaryapi.git

Collecting git+git://github.com/mdn522/binaryapi.git
Cloning git://github.com/mdn522/binaryapi.git to c:\users\gusta\appdata\local\temp\pip-req-build-fwhze4r9
Note: you may need to restart the kernel to use updated packages.
Running command git clone -q git://github.com/mdn522/binaryapi.git 'C:\Users\gusta\AppData\Local\Temp\pip-req-build-fwhze4r9'
ERROR: Error [WinError 2] El sistema no puede encontrar el archivo especificado while executing command git clone -q git://github.com/mdn522/binaryapi.git 'C:\Users\gusta\AppData\Local\Temp\pip-req-build-fwhze4r9'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

Error sending buy or sell

Hi

Me again

Now when I have sent some contracts, I get the error:

ERROR:root:**warning** 30late proposal sec(s)

This is really interesting

Buy an UPORDOWN contract

Hi, i'm trying to buy an up or down contract but i always have a barrier error, this type of contract has no barrier

from binaryapi.stable_api import Binary
import logging
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')

binary = Binary(token="XXXXXXXXX") ###accesso all'account

binary.buy(contract_type="UPORDOWN", amount=10, symbol="AUDJPY", duration=5, duration_unit='m')

response:

{"echo_req":{"amount":10,"basis":"stake","contract_type":"UPORDOWN","currency":"USD","duration":5,"duration_unit":"m","product_type":"basic","proposal":1,"req_id":4,"symbol":"AUDJPY"},"error":{"code":"ContractCreationFailure","details":{"field":"barrier"},"message":"Invalid barrier (Double barrier input is expected)."},"msg_type":"proposal","req_id":4}

what's the problem? thank you

Payout

Hello! Why am i receiving a different payout amount?
image
image

Problem getting the maximum payment.

Hello how are you? first, great job you did with this API, congratulations...
The problem I'm having is that the payout for volatile indexes is set at 95.5% in the broker's app, but in the API I'm only getting paid 78%, isn't there something in the API that is limiting the payout %?

Now other issue

DEBUG:binaryapi.ws.client:Websocket client connected. DEBUG:binaryapi.api:{"authorize": "xxxxxxxxxxxxxxxxxxxxx", "req_id": 48} DEBUG:binaryapi.ws.client:{"authorize":{"account_list":[{"account_type":"trading","created_at":1616442487,"currency":"USD","is_disabled":0,"is_virtual":0,"landing_company_name":"svg","loginid":"CR2256814","trading":{}},{"account_type":"trading","created_at":1616265606,"currency":"USD","is_disabled":0,"is_virtual":1,"landing_company_name":"virtual","loginid":"VRTC3993956","trading":{}}],"balance":10003.95,"country":"co","currency":"USD","email":"[email protected]","fullname":" ","is_virtual":1,"landing_company_fullname":"Deriv Limited","landing_company_name":"virtual","local_currencies":{"COP":{"fractional_digits":2}},"loginid":"VRTC3993956","preferred_language":"ES","scopes":["read","trade","admin","trading_information"],"trading":{},"upgradeable_landing_companies":["svg"],"user_id":8106808},"echo_req":{"authorize":"<not shown>","req_id":48},"msg_type":"authorize","req_id":48} DEBUG:binaryapi.ws.client

This is a real issue...

problem with buy

When I try an examle binary.buy('put',.....), I get:
'message': 'Trading is not offered for this duration.'
I had duration 3. I try 1,try 180.but get the same

get contract result win or loss

I now basic of python pls help me sir
This is my buy contract

from binaryapi.stable_api import Binary

binary_token = 'xxxxxxxxxxxxx'

binary = Binary(token=binary_token)

symbol = "R_75"  # symbol/asset

success,contract_id, req_id = binary.buy('PUT',subscribe = 1, amount=1, symbol=symbol, duration=5, duration_unit='t')

print('success={}, contract_id={}, req_id={}'.format(success, contract_id, req_id))

and I need the result of buy trade (contract_id)

Buy Touch contract error

Hello!
I'm getting error when trying to buy a Touch contract.
Just change the contract type to "ONETOUCH", and insert parameter "barrier=+1.00".
Then: ModuleNotFoundError: No module named 'binaryapi'.
If change back to "PUTE" contract type and delete barrier parameter, all works good for Put contract.

from binaryapi.stable_api import Binary
binary_token = "xxxxxxxxxxxxxxxxxx"
binary = Binary(token=binary_token)

This works for Put contract:
symbol = "R_100"
print("Buy a PUT contract")
print(binary.buy('PUTE', amount=1.02, symbol=symbol, duration=5, duration_unit='t'))

This also works for Put contract:
symbol = "R_100"
print("Buy a PUT contract")
print(binary.buy(contract_type='PUTE', amount=1.02, symbol=symbol, duration=5, duration_unit='t'))

This does not work (binaryapi module not found) for Touch contract:
symbol = "R_100"
print("Buy a TOUCH contract")
print(binary.buy('ONETOUCH', barrier=+1.00, amount=1.02, symbol=symbol, duration=5, duration_unit='t'))

This also does not work (binaryapi module not found) for Touch contract:
symbol = "R_100"
print("Buy a TOUCH contract")
print(binary.buy(contract_type='ONETOUCH', barrier='+1.00', amount=1.02, symbol=symbol, duration=5, duration_unit='t'))

Reference for Buy contract parameters:
https://developers.binary.com/api/#buy

Thank you so much for this Python Binary API!!

contract payout

I run the python script "examples/propose_and_buy_contract.py" . The payout is always significantly lower than that I saw in browser page at the same time ? Any other settings such as currency, duration remain the same.

E.g. It displayed "85% Return" in browser page, but only about 70% from runing the python script.

hi,

does this api(project) work with deriv broker?
i saw the endpoint urls as binary.com

I can't use a handle message function

I've tried in every way to use the message handle function and it always gives an error.
Can you please give an example of a script with a request for some function and the correct way to get the response using the handle message function.

Thank you very much in advance

Problem logging in

Thanks for the awesome software. I have an issue connecting on my Rock64 (RPI-like device). It works fine on my desktop.

The error is:

File "/home/rock64/python-environments/binary/lib/python3.7/site-packages/websocket/_app.py", line 407, in _callback
callback(self, *args)
ERROR:root:error authorize late 30 sec
ERROR:websocket:error from callback <function WebsocketClient.on_close at 0xf69d6930>: on_close() takes 1 positional argument but 3 were given
File "/home/rock64/python-environments/binary/lib/python3.7/site-packages/websocket/_app.py", line 407, in _callback
callback(self, *args)
DEBUG:binaryapi.ws.client:Websocket client connected.
DEBUG:binaryapi.api:{"authorize": "y1sdw0uV2rOoNJl", "req_id": 1}
ERROR:websocket:error from callback <bound method WebsocketClient.on_message of <binaryapi.ws.client.WebsocketClient object at 0xf69e8990>>: on_message() takes 2 positional arguments but 3 were given
File "/home/rock64/python-environments/binary/lib/python3.7/site-packages/websocket/_app.py", line 407, in _callback
callback(self, *args)

Many thanks!

demo balance

Is the API work with demo balance.i want trade with my demo balance.
For that would happened?
what i have to do?

Potential profit or loss of current transaction

how can i use the api to extract the profit or loss of current transaction
or check result

also how do i get the current candle or last two candle from the API

Suggesttion
i think if you upload a simple test bot, most of the api function and object question will be answered.
the doc at https://developers.binary.com/api/ is more confusing when one is not used to json

thank you

Connection is already closed.

I keep get Connection is already closed. error after sometime how do i reconnect to the websocket without rerunning the script?

Here is a snippet of what i have tried so far but doesnt work

def deriv():
     binary = Binary(token=binary_token, message_callback=message_handler)
     . . . . . . . . . 
     while 1:
           try:
               trade()
           except:
              #connection closed
               deriv()

Any help would be appreciated thanks!

Pocket option

Hello, can you get the pocket option broker api? It is also a large broker and allows copy trade from other users

how do I get the PROFIT Balance?

I can't use the api to extract the Balance from the message below. How do I do?

def message_handler(message):
    # message = json.loads(str(message))
    msg_type = message.get('msg_type')
    print("MSG", msg_type, "=>", message)

binary = Binary(token="my_token", message_callback=message_handler)

websocket closed

Hello again) I need to get candles by 24 currency. Sometime my script stopped,in logging i get websocket closed. Do you have there a method to check connect and reconnect?

error

"C:\Python310\lib\site-packages\websocket_client-0.56.0-py3.10.egg\websocket_app.py", line 343, in _callback
callback(*args)

I'm just getting numbers

I didn't quite understand why, but the only thing I get as an answer is numbers in an increasing way. I will put two code samples:

First:

# High Level API, This API is based on "binaryapi.api" for easy usage
from binaryapi.stable_api import Binary
# Low Level API
from binaryapi.api import BinaryAPI

binary = Binary(token="my_token")

stats = binary.api.get_account_status(1)
print('account status ',stats)

Respsonse: 4

Second:

# High Level API, This API is based on "binaryapi.api" for easy usage
from binaryapi.stable_api import Binary
# Low Level API
from binaryapi.api import BinaryAPI

binary = Binary(token="my_token")
import time

# Ticks API - https://developers.binary.com/api/#ticks
while True:
	a = binary.api.ticks(ticks="frxEURUSD", subscribe=None, passthrough=None, req_id=None)
	print(a)
	time.sleep(1)

Respsonse:
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Why can't I open a trade?

from binaryapi.stable_api import Binary

binary_token = "***************"

binary = Binary(token=binary_token)

symbol = "frxAUDUSD"
print("Buy a CALL contract")
print(binary.buy('CALL', amount=1, symbol=symbol, duration=4, duration_unit='t'))

Answer:
Buy a CALL contract (False, None, 4)

What am I doing wrong?
Sorry for bothering you with my questions :)

Websocket problem

Hello,something new:

DEBUG:binaryapi.ws.client:{"echo_req":{"authorize":"","req_id":1},"error":{"code":"WrongResponse","message":"Sorry, an error occurred while processing your request."},"msg_type":"authorize","req_id":1}
ERROR:websocket:error from callback <bound method WebsocketClient.on_message of <binaryapi.ws.client.WebsocketClient object at 0x7f970fabe240>>: 'authorize'
File "/usr/local/lib/python3.7/site-packages/websocket_client-0.56.0-py3.7.egg/websocket/_app.py", line 343, in _callback
callback(*args)
File "/usr/local/lib/python3.7/site-packages/binaryapi/ws/client.py", line 39, in on_message
self.api.profile.msg = message["authorize"]

API: Top Up Virtual-Money Account

Thank you by your work first at all...

I wanna reset my demo balance with:

Binary(token=token).api.topup_virtual:1

But doesn't works, what can I do?

Problem with code in readme

Hi,

thank you for youre work.
I have tried to run the code from the readme, "Getting Started". But i get an error:
TypeError: call() missing 1 required positional argument: 'currency'
Can you please help me to solve the problem?

image

Cannot get data

I try to get candle by ticks_history. But always get an int in response. Why that?

in example:
from binaryapi.stable_api import Binary
binary = Binary(token)
candles = binary.api.ticks_history(ticks_history="frxEURUSD", end="latest", style="candles")
print(candles)

hello

Hello, I want to add Check win system.

Buy a "DIGITOVER" contract

Hy my friend!
I am trying to buy a "DIGITOVER" contract but the parameters do not accept.
The return is False, None, 4.
I believe it is for lack of "barrier". how can I buy "DIGITOVER", barrier = 2?

This does not work for DIGITOVER contract:

symbol = "R_100"
print("Buy a Digit Over contract")
print(binary.buy('DIGITOVER', barrier=2, amount=1, symbol=symbol, duration=1, duration_unit='t'))

I read in another "issue" that has to add "barrier" in stable_api.py but I don't know how to do that.

How can I do it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.