1 Star 1 Fork 1

xiaoxinwt / python-binance

加入 Gitee
与超过 800 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.rst

Welcome to python-binance v0.5.6

This is an unofficial Python wrapper for the Binance exchange REST API v1/3. I am in no way affiliated with Binance, use at your own risk.

If you came here looking for the Binance exchange to purchase cryptocurrencies, then go here. If you want to automate interactions with Binance stick around.

Source code
https://github.com/sammchardy/python-binance
Documentation
https://python-binance.readthedocs.io/en/latest/
Binance API Telegram
https://t.me/binance_api_english

Features

  • Implementation of General, Market Data and Account endpoints.
  • Simple handling of authentication
  • No need to generate timestamps yourself, the wrapper does it for you
  • Response exception handling
  • Websocket handling with reconnection and multiplexed connections
  • Symbol Depth Cache
  • Withdraw functionality
  • Deposit addresses

Quick Start

Register an account with Binance.

Generate an API Key and assign relevant permissions.

pip install python-binance
from binance.client import Client
client = Client(api_key, api_secret)

# get market depth
depth = client.get_order_book(symbol='BNBBTC')

# place market buy order
order = client.create_order(
    symbol='BNBBTC',
    side=Client.SIDE_BUY,
    type=Client.ORDER_TYPE_MARKET,
    quantity=100)

# get all symbol prices
prices = client.get_all_tickers()

# withdraw 100 ETH
# check docs for assumptions around withdrawals
from binance.exceptions import BinanceApiException, BinanceWithdrawException
try:
    result = client.withdraw(
        asset='ETH',
        address='<eth_address>',
        amount=100)
except BinanceApiException as e:
    print(e)
except BinanceWithdrawException as e:
    print(e)
else:
    print("Success")

# fetch list of withdrawals
withdraws = client.get_withdraw_history()

# fetch list of ETH withdrawals
eth_withdraws = client.get_withdraw_history('ETH)

# get a deposit address
address = client.get_deposit_address('BTC)

# start trade websocket
def process_message(msg):
    print("message type: {}".format(msg['e']))
    print(msg)
    # do something

from binance.websockets import BinanceSocketManager
bm = BinanceSocketManager(client)
bm.start_aggtrade_socket(symbol='BNBBTC')
bm.start()

For more check out the documentation.

Donate

If this library helped you out feel free to donate.

  • ETH: 0x79c9A113d63B6AC024c1AAae6f6419721C3611A3
  • NEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBo
  • BTC: 1Dknp6L6oRZrHDECRedihPzx2sSfmvEBys

Other Exchanges

If you use Quoinex or Qryptos check out my python-quoine library.

If you use Kucoin check out my python-kucoin library.

If you use IDEX check out my python-idex library.

https://analytics-pixel.appspot.com/UA-111417213-1/github/python-binance?pixel&useReferer

简介

Binance API python implementation 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/xiaoxinwt/python-binance.git
git@gitee.com:xiaoxinwt/python-binance.git
xiaoxinwt
python-binance
python-binance
master

搜索帮助