Code Monkey home page Code Monkey logo

python-binance's Introduction

Welcome to python-binance v0.3.5

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

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
  • Symbol Depth Cache
  • Withdraw functionality
  • Order parameter validation based on Trade Rules

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
from binance.enums import *
order = client.create_order(
    symbol='BNBBTC',
    side=SIDE_BUY,
    type=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()

# start trade websocket
def process_message(msg):
    print("message type:" + msg[e])
    print(msg)
    # do something

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

For more check out the documentation.

Donate

If this library helped you out feel free to donate.

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

Other Exchanges

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

python-binance's People

Contributors

mfuellbier avatar samjosephmark avatar sammchardy avatar

Watchers

 avatar  avatar

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.