python-binance | Binance Exchange API python implementation | Cryptocurrency library
kandi X-RAY | python-binance Summary
kandi X-RAY | python-binance Summary
Binance Exchange API python implementation for automated trading
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a margin order
- Generate keyword arguments for request
- Make a request to the margin API
- Makes a request
- Returns an iterator over the aggregate trades for a symbol
- Make a request to the API
- Create the API URI
- Get aggregate trades
- Queries universal transfer history
- Get deposit history
- Gets API Trading Trading Status
- Get margin account
- Get margin trades
- Get a list of SubAccountDeposit history
- Get all margin orders
- Get a single ticker
- Get margin details
- Get margin transfer history
- Get open margin orders
- Get klines from binance
- Gets the dust log
- Get account snapshot
- Create a new margin order order
- Cancel margin O margin orders
- Get a specific margin account
- Get all coins
python-binance Key Features
python-binance Examples and Code Snippets
transfer_transaction = await Transaction.transfer_transaction(
from_address, to_address, symbol, amount
)
multi_transfer_transaction = await Transaction.multi_transfer_transaction(
from_address,
to_address,
transfers=[{"symbol":
from binancechain.enums import Ordertype, Side, Timeinforce, Votes
#if client is passed in , testnet arg will be ignored
transaction = Transaction(wallet=wallet, client=client)
transfer = await transaction.transfer(
to_address=wallet_two.get_ad
wallet = Wallet.create_wallet(password=None, testnet=False)
wallet = Wallet.create_wallet_mnemonic(language="english", password=None, testnet=False)
keystore = Wallet.create_keystore(password=None)
wallet = Wallet(key="HDKEY object", testnet=False
def analyze(**res):
print(res)
kline = res['k']
if kline['x']: # candle is completed
print('{} start_sleeping {} {}'.format(
datetime.now(),
kline['s'],
datetime.fromtimestamp(kline[
binance_buy_demand = sum(float(x[1]) for x in alis['bids'])
binance_sell_demand = sum(float(x[1]) for x in alis['asks'])
FROM python:3.8
RUN pip install numpy
RUN pip install python-binance
RUN pip install pandas
RUN pip install backtrader
RUN pip install matplotlib
RUN pip install websocket_client
# TA-Lib
RUN wget http://prdownloads.sourceforge.net/ta-l
import asyncio
from binance import AsyncClient
RESULTS = [] # let's store all results here
class GetAllBinanceData:
def __init__(self, workers_num: int = 10):
self.workers_num: int = workers_num
self.task_q: asyncio
async def main(queue):
coins = ['BTC', 'ETH', 'BNB'] # Add more coins as desired.
calculations = [calculate(client, queue, coin) for coin in coins]
await asyncio.gather(*calculations) # Use a starred expression to unpack the
coinlist = ['XRPUSDT', 'ETHUSDT', 'BTCUSDT']
while True:
for x in coinlist:
pair = x
time.sleep(10)
try:
klines = client.get_klines(symbol=pair, interval=interval, limit=limit)
except Excep
Community Discussions
Trending Discussions on python-binance
QUESTION
hello everyone i have a weird problem when calling get_historical_klines from binance-python in my code. i've tried to run the my personal PC (windows) and it worked but on my VPS it's showing this error this is the part where my program crash. i've tried different versions of python (3.8,3.9) and different versions of python-binance (1.0.15) module but same problem i've made sure that my PC ( windows) and my VPS (Ubuntu 20.04) has the same version of python and python-binance module. Any suggestions why this is happening and how can i solve it ?
...ANSWER
Answered 2022-Mar-16 at 20:56try to downgrade the module regex from 2022.3.15 to 2022.3.2
regards
QUESTION
I am trying to get buy and sell orders from binance api(python-binance) which has a limit of 500 values.(500 ask,500 buy). I already can get this with creating 500 variables with index numbers but it seems to me there has to be a better way than to write 500 lines of code. This is the code I am trying to make it happen.
...ANSWER
Answered 2022-Feb-08 at 08:35Use the sum()
function with a generator that gets the appropriate element of each list item.
QUESTION
I am trying to install the Python-binance package to Pycharm, but it is not available for the conda interpreter that I use.
When I try to install it via 'conda install python-binance'
in my terminal I get the following error:
ANSWER
Answered 2022-Feb-03 at 10:06There is nothing unexpected happening here. pip
and conda
use different sources for their packages. pip
always checks PyPi on which python-binance
is available. conda
looks for packages in a list of configured channels, in you case, the default channels. But if you check with the search function on anaconda.org, you can see that the package is only available from conda-forge
, so you can install it from conda
using
QUESTION
Ive been trying to run some code through AWS Lambda using python 3.9 but I keep bumping into an issue when I run my code. I keep getting the "No module named 'regex._regex'" Error. I had this issue a few days ago when working locally through PyCharm but I managed to fix that by installing a newer version of regex I think (honestly can't remember exactly what fixed it it took be all day to try and solve that problem). But now it works on PyCharm and I have also tested my code on VSCode and it works there too without any problems but for some reason every time I copy my file up to AWS Lambda to run it I get the error again. I've looked around and there have been other people that have had the error a while ago but they didn't come to any solutions there, and none of them worked for me either.
to be specific im importing the python-binance module, and within this module it tries to import regex, which succeeds for a few levels bouncing around the regex files importing other regex files until it just won't read the specific '_regex' file. the _regex file is a python file so maybe that has something to do with it but it works through PyCharm and VSCode so I don't know it would be any different in Lambda. I've got the regex files installed through pip normally (pip install regex) swell as in the same location as my python script is (pip install -t MyFile regex). after installing them they arn't nested in any other folders apart from the initial ones that they come in.
To be clear ive got a local folder which im writing my code and importing my packages to, which I then zip up and then upload to lambda Ive taken out that part of the code and taken out the import for python-binance (what is referring to import regex and therefore causing the problem) and all of my other packages work fine so its not the way ive got my packages stored in the directory.
Ive tried changing the version of Python that lambda is running to 3.8 and 3.7 swell and the issue is still there.
The Error:
{ "errorMessage": "Unable to import module 'lambda_function': No module named 'regex._regex'", "errorType": "Runtime.ImportModuleError", "requestId": "c59ea163-53bf-4b1a-8cc5-a4d23283cf0f", "stackTrace": [] }
Any help would be much appreciated.
...ANSWER
Answered 2022-Feb-03 at 00:40The leading underscore in the _regex module indicates that it's a C extension. You may want to try downloading the wheel into your Lambda project, as described here: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/
QUESTION
So, I'm new to Docker. I want to use Ta-Lib and freqtrade libraries for a bot I want to build. The problem is that I don't want to build the Dockerfile over and over again. I have been copying my python code in the Dockerfile as shown below but as soon as I change the python code, I have to rebuild the Dockerfile because I changed the copied python script. Each build takes over 10 minutes to complete and this makes my life very difficult to test the bot. Is there a way that I build the Dockerfile with all the dependencies and requirements first and then simply run my script using the image made? So that I don't have to rebuild the entire thing just after adding one line of code? The Dockerfile is as shown below
...ANSWER
Answered 2022-Jan-23 at 18:20First, you should copy your python file as late as possible.
QUESTION
I have been using the python-binance package for over a year now without any problem. An hour ago I suddenly get ModuleNotFoundError
when I try to import the package somewhere in my scripts, which were running smoothly before.
I updated the package using pip and checked the git repository for any changes but could not find any.
I tried this using python 3.8.10 and 3.8.12.
So what I did is pip install python-binance --upgrade
to update the package.
The following code was working before and now gives the error:
...ANSWER
Answered 2022-Jan-10 at 23:06Found it. In both env where I tested this I had created a new python file named binance.py
which caused this error. Unfortunately the error message was a bit unclear here. Deleted the file and it is working now.
QUESTION
Currently working on a project that uses Binance Websockets to fetch data of the coin prices and makes calculations with the data.
The number of coins that I calculate is dynamic (varies from 150 to ~250).
The ASYNC function is called calculate(client, queue, coin)
It takes the following arguments:
- client: The Binance Async client (python-binance library)
- queue: A queue where opportunities get passed in if the calculation has a positive outcome
- coin: The coin e.g. BTC
The calculate
function contains a while 1
(infinitive) loop, so the calculations keep on running.
At the moment the main
function uses asyncio.gather to combine the calculate functions for the different coins (150 - ~250)
ANSWER
Answered 2021-Oct-05 at 20:03You want to create a list of the coins to call calculate()
on, use that list to create a list of calculations, and then use a starred expression unpack that list as arguments to asyncio.gather()
:
QUESTION
I'm trying to learn how to deal with python exceptions. In that case I'm working with the binance library and reading the wiki I found the following
...ANSWER
Answered 2021-Sep-06 at 18:49You need to import the specific exception class:
QUESTION
I know there is a command pip show
for the purpose but I would like to know whether it is possible I can fetch details by doing import pip
? When you run pip show
it gives info like:
ANSWER
Answered 2021-Aug-11 at 09:05Playing with pip source code, I found the following solution which works for Python 3.8.1 and pip 21.0.1 .
QUESTION
import python-binance
...ANSWER
Answered 2021-Jul-17 at 19:06You can't. Take a look at this solution. You would need to rename the module with an underscore.
In your case, the python-binance
library doesn't need to be imported like that. All you need to do is import the client like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install python-binance
You can use python-binance like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page