0% found this document useful (0 votes)
32 views228 pages

Python Binance Readthedocs Io in Latest

The python-binance documentation provides an unofficial Python wrapper for the Binance exchange REST API v3, detailing features such as market data, account endpoints, and async support. It includes a quick start guide for installation, API key generation, and making API calls, along with examples for both synchronous and asynchronous usage. Additionally, it covers upgrading to newer versions, donation options, and references to other exchange libraries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views228 pages

Python Binance Readthedocs Io in Latest

The python-binance documentation provides an unofficial Python wrapper for the Binance exchange REST API v3, detailing features such as market data, account endpoints, and async support. It includes a quick start guide for installation, API key generation, and making API calls, along with examples for both synchronous and asynchronous usage. Additionally, it covers upgrading to newer versions, donation options, and references to other exchange libraries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 228

python-binance Documentation

0.2.0

Sam McHardy

February 15, 2022


Contents

1 Features 3

2 Upgrading to v1.0.0+ 5

3 Quick Start 7

4 Async Example 11

5 Donate 13

6 Other Exchanges 15
6.1 Contents 15
6.2 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

Python Module Index 207

Index 209

i
ii
python-binance Documentation, Release 0.2.0

Updated 27th Sept 2021

This is an unofficial Python wrapper for theBinance exchange REST API v3I am in no way affiliated with Binance.
use at your own risk.
If you came here looking for theBinance exchangeto purchase cryptocurrencies, thengo hereIf you want to automate
interactions with Binance stick around.
If you’re interested in Binance’s new DEX Binance Chain see mypython-binance-chain library
Source codeThe link provided is a URL for the GitHub repository of the Python Binance library.
DocumentationInvalid input. Please provide text to translate.
Binance API Telegramhttps://t.me/binance_api_english
Blog with examples including asyncInvalid input, please provide text for translation.
• Async basics for Binance
• Understanding Binance Order Filters
Make sure you update often and check theChangelogfor new features and bug fixes.

Contents 1
python-binance Documentation, Release 0.2.0

2 Contents
CHAPTER 1

Features

Implementation of all General, Market Data and Account endpoints.


Asyncio implementation
Testnet support for Spot, Futures and Vanilla Options
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
Historical Kline/Candle fetching function
Withdraw functionality
Deposit addresses
Margin Trading
Futures Trading
Vanilla Options
Support other domains (.us, .jp, etc)

3
python-binance Documentation, Release 0.2.0

4 Chapter 1. Features
CHAPTER 2

Upgrading to v1.0.0+

The breaking changes include the migration from wapi to sapi endpoints which are related to the wallet endpoints detailed.
in theBinance Docs
The other breaking change is for websocket streams and the Depth Cache Manager which have been converted to use
Asynchronous Context Managers. See examples in the Async section below or view thewebsocketsanddepth cache
docs.

5
python-binance Documentation, Release 0.2.0

6 Chapter 2. Upgrading to v1.0.0+


CHAPTER 3

Quick Start

Register an account with Binance.


Generate an API Keyand assign relevant permissions.
If you are using an exchange from the US, Japan or other TLD then make sure passtld='us' when creating the client.
To use theSpotorVavanilla OptionsTestnet, passtestnet=True when creating the client.

pip install python-binance

frombinanceimportClient, ThreadedWebsocketManager, ThreadedDepthCacheManager


Client(api_key, api_secret)

get market depth


client.get_order_book(symbol='BNBBTC')

place a test market buy order, to place an actual order use the create_order
˓→ function

order=client.create_test_order(
BNBBTC
side=Client.SIDE_BUY,
type=Client.ORDER_TYPE_MARKET,
quantity=100)

get all symbol prices


client.get_all_tickers()

withdraw 100 ETH


check docs for assumptions around withdrawals
from binance.exceptions importBinanceAPIException
try:
client.withdraw(
ETH
<eth_address>
amount=100)
(continues on next page)

7
python-binance Documentation, Release 0.2.0

(continued from previous page)


exceptBinanceAPIExceptionase:
print(e)
otherwise:
Success

fetch list of withdrawals


client.get_withdraw_history()

fetch list of ETH withdrawals


client.get_withdraw_history(coin='ETH')

get a deposit address for BTC


client.get_deposit_address(coin='BTC')

get historical kline data from any date range

fetch 1 minute klines for the last day up until now


klines=client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE,"1 day
˓→ ago UTC

fetch 30 minute klines for the last month of 2017


client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1
˓→ Dec, 2017","1 Jan, 2018")

fetch weekly klines since it listed


client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan,
˓→ 2017

socket manager using threads


twm=ThreadedWebsocketManager()
twm.start()

depth cache manager using threads


dcm=ThreadedDepthCacheManager()
dcm.start()

defhandle_socket_message(msg):
print(f"message type:{msg['e']}")
print(msg)

defhandle_dcm_message(depth_cache):
symbol{depth_cache.symbol}")
top 5 bids
print(depth_cache.get_bids()[:5])
top 5 asks
print(depth_cache.get_asks()[:5])
last update time{}.format(depth_cache.update_time)

twm.start_kline_socket(callback=handle_socket_message, symbol='BNBBTC')

dcm.start_depth_cache(callback=handle_dcm_message, symbol='ETHBTC')

# replace with a current options symbol


BTC-210430-36000-C
dcm.start_options_depth_cache(callback=handle_dcm_message, symbol=options_symbol)

join the threaded managers to the main thread


(continues on next page)

8 Chapter 3. Quick Start


python-binance Documentation, Release 0.2.0

(continued from previous page)


twm.join()
dcm.join()

For morecheck out the documentation.

9
python-binance Documentation, Release 0.2.0

10 Chapter 3. Quick Start


CHAPTER 4

Async Example

ReadAsync basics for Binancefor more information.

import asyncio
importjson

frombinanceimportAsyncClient, DepthCacheManager, BinanceSocketManager

async defmain():

initialise the client


clientawaitAsyncClient.create()

run some simple requests


print(json.dumps(await client.get_exchange_info(), indent=2))

Invalid input. Please provide the text to be translated.

# initialise websocket factory manager


bsm=BinanceSocketManager(client)

create listener using async with


this will exit and close the connection after 5 messages
async withbsm.trade_socket('ETHBTC')as
for_ in range(5):
awaitts.recv()
print(f'recv{res}')

get historical kline data from any date range

fetch 1 minute klines for the last day up until now


client.get_historical_klines("BNBBTC", AsyncClient.KLINE_INTERVAL_
˓→ 1 minute

use generator to fetch 1 minute klines for the last day up until now
(continues on next page)

11
python-binance Documentation, Release 0.2.0

(continued from previous page)


async forklinein awaitclient.get_historical_klines_generator("BNBBTC",
˓→ AsyncClient.KLINE_INTERVAL_1MINUTE,"1 day ago UTC")

print(kline)

fetch 30 minute klines for the last month of 2017


client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE,
˓→ December 1, 2017

fetch weekly klines since it listed


client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK,"1
˓→ January, 2017

setup an async context the Depth Cache and exit after 5 messages
async withDepthCacheManager(client, symbol='ETHBTC')asdcm_socket:
for_ in range(5):
depth_cacheawaitdcm_socket.recv()
print(f"symbol{depth_cache.symbol} updated:{depth_cache.update_time}")
print("Top 5 asks:")
print(depth_cache.get_asks()[:5])
Top 5 bids:
print(depth_cache.get_bids()[:5])

Vanilla options Depth Cache works the same, update the symbol to a current one
BTC-210430-36000-C
async withOptionsDepthCacheManager(client, symbol=options_symbol)asdcm_socket
for_ in range(5):
depth_cacheawaitdcm_socket.recv()
count+=1
print(f"symbol{depth_cache.symbol} updated{depth_cache.update_time}")
Top 5 asks:
print(depth_cache.get_asks()[:5])
print("Top 5 bids:")
print(depth_cache.get_bids()[:5])

awaitclient.close_connection()

if__main__

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

12 Chapter 4. Async Example


CHAPTER 5

Donate

If this library helped you out feel free to donate.


0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70
•LTC: LPC5vw9ajR1YndE1hYVeo3kJ9LdHjcRCUZ
• NEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBo
1Dknp6L6oRZrHDECRedihPzx2sSfmvEBys

13
python-binance Documentation, Release 0.2.0

14 Chapter 5. Donate
CHAPTER 6

Other Exchanges

If you useBinance Chaincheck out mypython-binance-chainlibrary.


If you useKucoincheck out mypython-kucoinlibrary.
If you useIDEXcheck out mypython-indexlibrary.

6.1 Contents

6.1.1 Getting Started

Installation

python-binance is available onPYPI. Install with pip:

pip install python-binance

Register on Binance

Firstlyregister an account with Binance.

Generate an API Key

To use signed account methods you are required tocreate an API Key.

15
python-binance Documentation, Release 0.2.0

Initialize the client

Pass your API Key and Secret


from binance.client importClient
client=Client(api_key, api_secret)

or for Asynchronous client

async defmain():

initialize the client


clientawaitAsyncClient.create(api_key, api_secret)

if__main__

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

Using the Spot, Futures or Vanilla Options Testnet

Binance offers aSpot, FuturesandVavanilla OptionsTestnet, to test interacting with the exchange.
To enable this set the testnet parameter passed to the Client to True.
The testnet parameter will also be used by any websocket streams when the client is passed to the BinanceSocketMan-
ager.

client=Client(api_key, api_secret, testnet=True)

or for Asynchronous client

clientawaitAsyncClient.create(api_key, api_secret, testnet=True)

Using a different TLD

If you are interacting with a regional version of Binance which has a different TLD such as .us or .com‘.jp' then you will
need to pass this when creating the client, see examples below.
This TLD will also be used by any WebSocket streams when the client is passed to the BinanceSocketManager.

Client(api_key, api_secret, tld='us')

or for Asynchronous client

clientawaitAsyncClient.create(api_key, api_secret, tld='us')

Making API Calls

Every method supports the passing of arbitrary parameters via keyword matching those in theBinance API documen-
tationThese keyword arguments will be sent directly to the relevant endpoint.
Each API method returns a dictionary of the JSON response as per theBinance API documentation. The docstring of
Each method in the code references the endpoint it implements.

16 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

The Binance API documentation references a timestamp parameter, this is generated for you where required.
Some methods have arecvWindowparameter fortiming security, see Binance documentation.
API Endpoints are rate limited by Binance at 20 requests per second, ask them if you require more.

Async API Calls

aiohttp is used to handle asyncio REST requests.


Each function available in the normal client is available in the AsyncClient class.
The only difference is to run within an asyncio event loop and await the function like below.

import asyncio
from binance importAsyncClient

async defmain():
clientawaitAsyncClient.create()

fetch exchange info


awaitclient.get_exchange_info()
Invalid input. Please provide the text you want translated.

awaitclient.close_connection()

if__main__

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

ReadAsync basics for Binancefor more information about asynchronous patterns.

API Rate Limit

Check theget_exchange_info()call for up to date rate limits.


At the current time Binance rate limits are:
1200 requests per minute
10 orders per second
100,000 orders per 24 hours
Some calls have a higher weight than others especially if a call returns information about all symbols. Read theofficial
Binance documentationfor specific information.
On each request, Binance returns X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter) and X-MBX-ORDER-
COUNT-(intervalNum)headers.
Here are examples to access these
Asynchronous example

import asyncio
frombinanceimportAsyncClient

<api_key>
<api_secret>
(continues on next page)

6.1. Contents 17
python-binance Documentation, Release 0.2.0

(continued from previous page)

async defmain():
clientawaitAsyncClient.create(api_key, api_secret)

res=awaitclient.get_exchange_info()
print(client.response.headers)

awaitclient.close_connection()

if__name__ == '__main__':

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

Synchronous example

frombinanceimportClient

<api_key>
<api_secret>

defmain():
client=Client(api_key, api_secret)

client.get_exchange_info()
print(client.response.headers)

if__main__
main()

Requests Settings

python-binance uses therequestslibrary.


YoucansetcustomrequestparametersforallAPIcallswhencreatingtheclient.

Client("api-key","api-secret", {"verify": False,"timeout":20})

You may also pass custom request parameters through any API call to override default settings or the above set.
Please specify new ones like the example below.

this would result in verify: False and timeout: 5 for the get_all_orders call
Client("api-key","api-secret", {"verify": False,"timeout":20})
client.get_all_orders(symbol='BNBBTC', requests_params={'timeout':5})

Check out therequests documentationfor all options.


Proxy Settings
You can use the Requests Settings method above

proxies={
http://10.10.1.10:3128
http://10.10.1.10:1080
}

(continues on next page)

18 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


in the Client instantiation
Client("api-key","api-secret", {'proxies': proxies})

or on an individual call
client.get_all_orders(symbol='BNBBTC', requests_params={'proxies': proxies})

Or set an environment variable for your proxy if required to work across all requests.
An example for Linux environments from therequests Proxies documentationis as follows.

http://10.10.1.10:3128
http://10.10.1.10:1080

For Windows environments

C:\>setHTTP_PROXY=http://10.10.1.10:3128
C:\>setHTTPS_PROXY=http://10.10.1.10:1080

6.1.2 Binance Constants

Binance requires specific string constants for Order Types, Order Side, Time in Force, Order response and Kline.
Intervals are found on binance.client.Client.

SPOT

NEW
PARTIALLY_FILLED
FILLED
CANCELED
PENDING_CANCEL
REJECTED
EXPIRED

1m
3m
5m
15m
30m
1h
2h
4h
6h
8h
12h
1d
3d
1w
1M

BUY
SELL

LIMIT
MARKET
STOP_LOSS
(continues on next page)

6.1. Contents 19
python-binance Documentation, Release 0.2.0

(continued from previous page)


STOP_LOSS_LIMIT
TAKE_PROFIT
TAKE_PROFIT_LIMIT
LIMIT_MAKER

GTC
IOC
FOK

ACK
RESULT
FULL

For accessing the data returned by Client.aggregate_trades().


AGG_ID ='a'
AGG_PRICE 'p'
AGG_QUANTITY 'q'
f
'l'
AGG_TIME 'T'
AGG_BUYER_MAKES 'm
AGG_BEST_MATCH M

For Websocket Depth these are found on binance.websockets.BinanceSocketManager

5
10
20

To use in your code reference either binance.client.Client or binance.websockets.BinanceSocketManager


from binance.client importClient
frombinance.websocketsimportBinanceSocketManager

Client.SIDE_BUY

6.1.3 General Endpoints

Ping the server

client.ping()

Get the server time

client.get_server_time()

Get system status

client.get_system_status()

Returns

20 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{
"status":0, normal system maintenance
normal normal or System maintenance.
}

Get Exchange Info

client.get_exchange_info()

Get Symbol Info

Get the exchange info for a particular symbol

client.get_symbol_info('BNBBTC')

Get All Coins Info

Get information of coins (available for deposit and withdraw) for user

client.get_all_tickers()

Get Daily Account Snapshot

Get daily account snapshot of specific type. Valid types: SPOT/MARGIN/FUTURES.

client.get_account_snapshot(type='SPOT')

Get Current Products

This call is deprecated, use the above Exchange Info call

client.get_products()

6.1.4 Market Data Endpoints

Get Market Depth

client.get_order_book(symbol='BNBBTC')

Get Recent Trades

client.get_recent_trades(symbol='BNBBTC')

6.1. Contents 21
python-binance Documentation, Release 0.2.0

Get Historical Trades

client.get_historical_trades(symbol='BNBBTC')

Get Aggregate Trades

client.get_aggregate_trades(symbol='BNBBTC')

Aggregate Trade Iterator

Iterar sobre operaciones agregadas para un símbolo desde una fecha dada o un ID de orden dado.

client.aggregate_trade_iter(symbol='ETHBTC', start_str='30 minutes ago')


˓→ UTC')

iterate over the trade iterator


fortradeinagg_trades
print(trade)
do something with the trade data

convert the iterator to a list


note: generators can only be iterated over once so we need to call it again
client.aggregate_trade_iter(symbol='ETHBTC', '30 minutes ago UTC')
list(agg_trades)

example using last_id value


client.aggregate_trade_iter(symbol='ETHBTC', last_id=23380478)
list(agg_trades)

Get Kline/Candlesticks

client.get_klines(symbol='BNBBTC', interval=Client.KLINE_INTERVAL_30MINUTE)

Get Historical Kline/Candlesticks

Fetch klines for any date range and interval

fetch 1 minute klines for the last day up until now


client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE,"1 day
˓→ ago UTC

fetch 30 minute klines for the last month of 2017


klines=client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE,"1
˓→ Dec, 2017","1 Jan, 2018

fetch weekly klines since it listed


client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan,
˓→ 2017

22 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Get Historical Kline/Candlesticks using a generator

Fetch klines using a generator

forklineinclient.get_historical_klines_generator("BNBBTC", Client.KLINE_INTERVAL_)
˓→ 1 minute, 1 day ago UTC

print(kline)
do something with the kline

Get average price for a symbol

client.get_avg_price(symbol='BNBBTC')

Get 24hr Ticker

client.get_ticker()

Get All Prices

Get last price for all markets.

client.get_all_tickers()

Get Orderbook Tickers

Get first bid and ask entry in the order book for all markets.

client.get_orderbook_tickers()

6.1.5 Account Endpoints

Orders

Order Validation

Binance has a number of rules around symbol pair orders with validation on minimum price, quantity and total order
value.
Read more about their specifics in theFilterssection of the official API.
ReadUnderstanding Binance Order Filtersfor more information about price and quantity filters onBinance.
It can be helpful to format the output using formatting

amount=0.000234234
precision=5
{:0.0{}f"{:.{}}".format(amount, precision)

Or if you have the tickSize or stepSize then use the helper to round to step size

6.1. Contents 23
python-binance Documentation, Release 0.2.0

from binance.helpers importround_step_size

amount=0.000234234
tick_size=0.00001
round_step_size(amount, tick_size)

Fetch all orders

client.get_all_orders(symbol='BNBBTC', limit=10)

Place an order

Place an order
Use the create_order function to have full control over creating an order.

Invalid input *
order=client.create_order(
BNBBTC
side=SIDE_BUY,
type=ORDER_TYPE_LIMIT,
TIME_IN_FORCE_GTC
quantity=100,
0.00001

Place a limit order


Use the helper functions to easily place a limit buy or sell order

order=client.order_limit_buy(
BNBBTC
quantity=100,
0.00001

order=client.order_limit_sell(
BNBBTC
quantity=100,
0.00001

Place a market order


Use the helper functions to easily place a market buy or sell order

order=client.order_market_buy(
BNBBTC
quantity=100)

order=client.order_market_sell(
BNBBTC
quantity=100)

Place an OCO order


Use the create_oco_order function to have full control over creating an OCO order.

24 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

from binance.enums import *


client.create_oco_order(
BNBBTC
side=SIDE_SELL
TIME_IN_FORCE_GTC
quantity=100,
0.00001
0.00002

Place a test order

Creates and validates a new order but does not send it into the exchange.

from binance.enums import *


order=client.create_test_order(
BNBBTC
side=SIDE_BUY
type=ORDER_TYPE_LIMIT,
TIME_IN_FORCE_GTC
quantity=100,
0.00001

Check order status

order=client.get_order(
BNBBTC
orderId

Cancel an order

client.cancel_order(
BNBBTC
orderId='orderId')

Get all open orders

client.get_open_orders(symbol='BNBBTC')

Get all orders

client.get_all_orders(symbol='BNBBTC')

Account

6.1. Contents 25
python-binance Documentation, Release 0.2.0

Get account info

client.get_account()

Get asset balance

client.get_asset_balance(asset='BTC')

Get account status

client.get_account_status()

Get account API trading status

client.get_account_api_trading_status()

Get trades

client.get_my_trades(symbol='BNBBTC')

Get trade fees

get fees for all symbols


client.get_trade_fee()

get fee for one symbol


client.get_trade_fee(symbol='BNBBTC')

Get asset details

client.get_asset_details()

Get dust log

client.get_dust_log()

Transfer dust

client.transfer_dust(asset='BNZ')

26 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Get Asset Dividend History

client.get_asset_dividend_history()

Disable Fast Withdraw Switch

client.disable_fast_withdraw_switch()

Enable Fast Withdraw Switch

client.enable_fast_withdraw_switch()

6.1.6 Sub Account Endpoints

Get Sub Account list

client.get_sub_account_list()

Get Sub Account Transfer History

client.get_sub_account_transfer_history(fromEmail='[email protected]', toEmail=
˓→ [email protected]

Get Sub Account Assets

client.get_sub_account_assets(email='[email protected]')

6.1.7 Margin Trading Endpoints

Note: Cross-margin vs isolated margin trading


Binance offers both cross-margin trading (where all margin is in one account) and isolated margin trading (where each
pair is a separate margin account). Make sure you are interacting with the right one.
Some of the API endpoints apply to the cross-margin or isolated margin accounts only. Other endpoints, such as
The trade execution endpoints are used for cross-margin account trades by default, but you can use your isolated.
margin accounts by using theisIsolatedorisolatedSymbolparameters. See the documentation below.

6.1. Contents 27
python-binance Documentation, Release 0.2.0

Market Data

Get cross-margin asset info

client.get_margin_asset(asset='BNB')

Get cross-margin symbol info

client.get_margin_symbol(symbol='BTCUSDT')

Get isolated margin symbol info

client.get_isolated_margin_symbol(symbol='BTCUSDT')

Get all isolated margin symbols

client.get_all_isolated_margin_symbols()

Get margin price index

client.get_margin_price_index(symbol='BTCUSDT')

Orders

Cross-margin vs isolated margin orders

By default, these trade execution endpoints will create an order using the cross-margin account.
To use the isolated margin account for the symbol you have specified, simply add the isIsolated='TRUE'
parameter to the API calls below in this ‘Orders’ section.

Order Validation

Binance has a number of rules around symbol pair orders with validation on minimum price, quantity and total order.
value.
Read more about their specifics in theFilterssection of the official API.
It can be helpful to format the output using the following snippet

amount=0.000234234
precision=5
amt_str="{:0.0{}f"{0:.{1}f}".format(amount, precision)

28 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Fetch all margin_orders

client.get_all_margin_orders(symbol='BNBBTC', limit=10)

Place a margin order

Use the create_margin_order function to have full control over creating an order

frombinance.enumsimport *
order=client.create_margin_order(
BNBBTC
side=SIDE_BUY,
type=ORDER_TYPE_LIMIT,
TIME_IN_FORCE_GTC
quantity=100,
0.00001

Check order status

order=client.get_margin_order(
BNBBTC
orderId='orderId')

Cancel a margin order

client.cancel_margin_order(
BNBBTC
orderId

Get all open margin orders

client.get_open_margin_orders(symbol='BNBBTC')

For isolated margin, add theisIsolated='TRUE' parameter.

Get all margin orders

client.get_all_margin_orders(symbol='BNBBTC')

For isolated margin, add the isIsolated='TRUE' parameter.

Account

6.1. Contents 29
python-binance Documentation, Release 0.2.0

Get cross-margin account info

client.get_margin_account()

Create isolated margin account

client.create_isolated_margin_account(base='BTC', quote='ETH')

Get isolated margin account info

client.get_isolated_margin_account()

Transfer spot to cross-margin account

client.transfer_spot_to_margin(asset='BTC', amount='1.1')

Transfer cross-margin account to spot

client.transfer_margin_to_spot(asset='BTC', amount='1.1')

Transfer spot to isolated margin account

client.transfer_spot_to_isolated_margin(asset='BTC')
ETHBTC

Transfer isolated margin account to spot

client.transfer_isolated_margin_to_spot(asset='BTC')
ETHBTC

Get max transfer amount

client.get_max_margin_transfer(asset='BTC')

This max transfer is for the cross-margin account by default. For isolated margin records, add the
symbol_nameparameter

30 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Trades

Get all margin trades

client.get_margin_trades(symbol='BNBBTC')

For isolated margin trades, add thisIsolated='TRUE' parameter.

Loans

Create loan

client.create_margin_loan(asset='BTC', amount='1.1')

This is for the cross-margin account by default. For isolated margin, add the isIsolated='TRUE' and the
symbol=symbol_nameparameters.

Repay loan

client.repay_margin_loan(asset='BTC', amount='1.1')

This is for the cross-margin account by default. For isolated margin, add the thisIsolated='TRUE' and the
symbol=symbol_nameparameters.

Get loan details

client.get_margin_loan_details(asset='BTC', txId='100001')

This is for the cross-margin account by default. For isolated margin records, add the
symbol_nameparameter

Get repay details

client.get_margin_repay_details(asset='BTC', txId='100001')

This is for the cross-margin account by default. For isolated margin records, add the
symbol_nameparameter.

Get max loan amount

client.get_max_margin_loan(asset='BTC')

The max loan is for the cross-margin account by default. For isolated margin records, add the
symbol_nameparameter

6.1. Contents 31
python-binance Documentation, Release 0.2.0

6.1.8 Websockets

There are 2 ways to interact with websockets.


withThreadedWebsocketManagerorBinanceSocketManager.
ThreadedWebsocketManager does not require asyncio programming, while BinanceSocketManager does.
ThreadedWebsocketManager function begins with start_, e.g., start_ticker_socket while BinanceSocketManager is sim-
plyticker_socket.
Multiple socket connections can be made through either manager.
Only one instance of each socket type will be created, i.e. only one BNBBTC Depth socket can be created and there
Both a BNBBTC Depth and a BNBBTC Trade socket can be open at the same time.

Messages are received as dictionary objects relating to the message formats defined in theBinance WebSocket API
documentation.
Websockets sont configurés pour se reconnecter avec un maximum de 5 tentatives avec une stratégie de retour exponentiel.

ThreadedWebsocketManager Websocket Usage

Starting sockets on the ThreadedWebsocketManager requires a callback parameter, similar to the old implementations.
of websockets on python-binance.
ThreadedWebsocketManager takes similar parameters to theClientclass as it creates an AsyncClient internally.
For authenticated streams, api_key and api_stream are required.
As these use threads, start() is required to be called before starting any sockets.
To keep the ThreadedWebsocketManager running, use join() to join it to the main thread.

import time

frombinanceimportThreadedWebsocketManager

<api_key>
<api_secret>

defmain():

BNBBTC

twm=ThreadedWebsocketManager(api_key=api_key, api_secret=api_secret)
start is required to initialize its internal loop
twm.start()

defhandle_socket_message(msg):
print(f"message type:{msg['e']}")
print(msg)

twm.start_kline_socket(callback=handle_socket_message, symbol=symbol)

multiple sockets can be started


twm.start_depth_socket(callback=handle_socket_message, symbol=symbol)

or a multiplex socket can be started like this


see Binance docs for stream names
(continues on next page)

32 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


streams=['bnbbtc@miniTicker','bnbbtc@bookTicker']
twm.start_multiplex_socket(callback=handle_socket_message, streams=streams)

twm.join()

if__main__
main()

Stop Individual Stream


When starting a stream, a name for that stream will be returned. This can be used to stop that individual stream.
from binance importThreadedWebsocketManager

BNBBTC

twm=ThreadedWebsocketManager()
start is required to initialise its internal loop
twm.start()

defhandle_socket_message(msg):
print(f"message type:{msg['e']}")
print(msg)

twm.start_kline_socket(callback=handle_socket_message, symbol=symbol)
twm.start_depth_socket(callback=handle_socket_message,
˓→ symbol=symbol)

some time later

twm.stop_socket(depth_stream_name)

Stop All Streams

frombinanceimportThreadedWebsocketManager

twm=ThreadedWebsocketManager()
start is required to initialize its internal loop
twm.start()

defhandle_socket_message(msg):
print(f"message type:{e}")
print(msg)

twm.start_depth_socket(callback=handle_socket_message,
˓→ symbol=symbol)

twm.stop()

Attempting to start a stream after stop is called will not work.

BinanceSocketManager Websocket Usage

Create the manager like so, passing an AsyncClient.

6.1. Contents 33
python-binance Documentation, Release 0.2.0

import asyncio
from binance importAsyncClient, BinanceSocketManager

async defmain():
client=awaitAsyncClient.create()
bm=BinanceSocketManager(client)
# Start any sockets here, i.e., a trade socket
ts=bm.trade_socket('BNBBTC')
then start receiving messages
async withtsas
while True:
res=awaittscm.recv()
print(res)

awaitclient.close_connection()

if__name__=="__main__":

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

Set a custom timeout for the websocket connections


set a timeout of 60 seconds
bm=BinanceSocketManager(client, user_timeout=60)

Manually enter and exit the Asynchronous context manager


ts=bm.trade_socket('BNBBTC')
enter the context manager
awaitts.__aenter__()
receive a message
msg=awaitts.recv()
print(msg)
exit the context manager
awaitts.__aexit__(None, None, None)

Using a different TLD

The ThreadedWebsocketManager can take the tld when created if required.


from binance.streams importThreadedWebsocketManager

twm=ThreadedWebsocketManager(tld='us')

The BinanceSocketManager uses the same tld value as the AsyncClient that is passed in. To use the 'us' tld we can do
this.
from binance importAsyncClient, BinanceSocketManager

async def
clientawaitAsyncClient.create(tld='us')
bm=BinanceSocketManager(client)

start a socket...
(continues on next page)

34 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)

awaitclient.close_connection()

Websocket Errors

If the websocket is disconnected and is unable to reconnect, a message is sent to the callback to indicate this.
format is

{
error
Max reconnect retries reached
}

check for it like so


defprocess_message(msg):
ifmsg['e']=='error':
close and restart the socket
else:
process message normally

Multiplex Socket

Create a socket combining multiple streams.


These streams can include the depth, kline, ticker, and trade streams but not the user stream which requires extra
authentication.
Symbols in socket name must be lowercase i.ebnbbtc@aggTrade, neobtc@ticker
See theBinance Websocket Streams API documentationfor details on socket names.

pass a list of stream names


ms=bm.multiplex_socket(['bnbbtc@aggTrade','neobtc@ticker'])

Depth Socket

Depth sockets have an optional depth parameter to receive partial book rather than a diff response. By default this the
A different response is returned. Valid depth values are 5, 10, and 20.defined as enums.

depth diff response


ds=bm.depth_socket('BNBBTC')

partial book response


ds=bm.depth_socket('BNBBTC', depth=BinanceSocketManager.WEBSOCKET_DEPTH_5)

Kline Socket

Kline sockets have an optional interval parameter. By default this is set to 1 minute. Valid interval values aredefined
as enums.

Contents 35
python-binance Documentation, Release 0.2.0

from binance.enums import *


ks=bm.kline_socket('BNBBTC', interval=KLINE_INTERVAL_30MINUTE)

Aggregated Trade Socket

ats=bm.aggtrade_socket('BNBBTC')

Trade Socket

ts=bm.trade_socket('BNBBTC')

Symbol Ticker Socket

sts=bm.symbol_ticker_socket('BNBBTC')

Ticker Socket

ts=bm.ticker_socket(process_message)

Mini Ticker Socket

by default updates every second


mts=bm.miniticker_socket()

this socket can take an update interval parameter


set as 5000 to receive updates every 5 seconds
mts=bm.miniticker_socket(5000)

User Socket

This watches for 3 different user events


Account Update Event
Order Update Event
Trade Update Event
The Manager handles keeping the socket alive.
There are separate sockets for Spot, Cross-margin, and separate Isolated margin accounts.

Spot trading

36 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

bm.user_socket()

Cross-margin

bm.margin_socket()

Isolated margin

bm.isolated_margin_socket(symbol)

6.1.9 Depth Cache

To follow the depth cache updates for a symbol, there are 2 options similar to websockets.
Use theDepthCacheManager(orOptionsDepthCacheManagerfor vanilla options) or use theThreadedDepthCache-
Managerif you don’t want to interact with asyncio.

ThreadedDepthCacheManager Websocket Usage

Starting sockets on the ThreadedDepthCacheManager requires a callback parameter, similar to old implementations
of depth cache on python-binance pre v1
ThreadedDepthCacheManager takes similar parameters to theClientclass as it creates an AsyncClient internally.
As these use threads, start() is required to be called before starting any depth cache streams.
To keep the ThreadedDepthCacheManager running using join() to join it to the main thread.

frombinanceimportThreadedDepthCacheManager

defmain():

dcm=ThreadedDepthCacheManager()
start is required to initialize its internal loop
dcm.start()

defhandle_depth_cache(depth_cache):
symbol{depth_cache.symbol}")
top 5 bids
print(depth_cache.get_bids()[:5])
print("top 5 asks")
print(depth_cache.get_asks()[:5])
last update time{}.format(depth_cache.update_time)

dcm.start_depth_cache(handle_depth_cache, symbol='BNBBTC')

multiple depth caches can be started


dcm.start_depth_cache(handle_depth_cache, symbol='ETHBTC')

dcm.join()

(continues on next page)

6.1. Contents 37
python-binance Documentation, Release 0.2.0

(continued from previous page)

if__name__=="__main__":
main()

Stop Individual Depth Cache


When starting a stream, a name for that stream will be returned. This can be used to stop that individual stream.
from binance importThreadedDepthCacheManager

BNBBTC

dcm=ThreadedDepthCacheManager()
dcm.start()

defhandle_depth_cache(depth_cache):
print(f"message type:{e}")
print(msg)

dcm.start_depth_cache(handle_depth_cache, symbol='BNBBTC')

some time later

dcm.stop_socket(dcm_name)

Stop All Depth Cache streams


from binance importThreadedDepthCacheManager

BNBBTC

dcm=ThreadedDepthCacheManager()
dcm.start()

defhandle_depth_cache(depth_cache):
print(f"message type:{msg['e']}")
print(msg)

dcm.start_depth_cache(handle_depth_cache, symbol='BNBBTC')

some time later

dcm.stop()

Attempting to start a stream after stop is called will not work.

DepthCacheManager or OptionsDepthCacheManager Usage

Create the manager like so, passing the async api client, symbol and an optional callback function.
import async

frombinanceimportAsyncClient

async defmain():
(continues on next page)

38 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


clientawaitAsyncClient.create()
DepthCacheManager(client, 'BNBBTC')

asynchronous withdcmasdcm_socket
while True:
depth_cacheawaitdcm_socket.recv()
print("symbol{}.format(depth_cache.symbol)
top 5 bids
print(depth_cache.get_bids()[:5])
top 5 asks
print(depth_cache.get_asks()[:5])
print("last update time{}.format(depth_cache.update_time)

if__main__

loop=asyncio.get_event_loop()
loop.run_until_complete(main())

The Depth Cache Manager returns an Asynchronous Context Manager which can be used with async for or by inter-
acting with the __aenter__ and __aexit__ functions
By default the depth cache will fetch the order book via REST request every 30 minutes. This duration can be changed.
by using the refresh_interval parameter. To disable the refresh pass 0 or None. The socket connection will stay open
receiving updates to be replayed once the full order book is received.

Share a Socket Manager

Here dcm1 and dcm2 share the same instance of BinanceSocketManager


from binance.websockets importBinanceSocketManager
from binance.depthcache importDepthCacheManager
bm=BinanceSocketManager(client)
DepthCacheManager(client, 'BNBBTC', bm=bm)
dcm2=DepthCacheManager(client,'ETHBTC', bm=bm)

Websocket Errors

If the underlying websocket is disconnected and is unable to reconnect, None is returned for the depth_cache parameter.

Examples

1 hour interval refresh


dcm=DepthCacheManager(client,'BNBBTC', refresh_interval=60 60) *

# disable refreshing
dcm=DepthCacheManager(client,'BNBBTC', refresh_interval=0)

async withdcmasdcm_socket:
while True:
depth_cacheawaitdcm_socket.recv()
print("symbol{}.format(depth_cache.symbol)
top 5 bids
(continues on next page)

6.1. Contents 39
python-binance Documentation, Release 0.2.0

(continued from previous page)


print(depth_cache.get_bids()[:5])
top 5 asks
print(depth_cache.get_asks()[:5])
print("last update time"{}.format(depth_cache.update_time)

To use the __aenter__ and __aexit__ magic functions to use this class without the async with.

DepthCacheManager(client, 'BNBBTC')

awaitdcm.__aenter__()
depth_cacheawaitdcm.recv()
print("symbol{}.format(depth_cache.symbol)
top 5 bids
print(depth_cache.get_bids()[:5])
print("top 5 asks")
print(depth_cache.get_asks()[:5])
last update time{}.format(depth_cache.update_time)

exit the context manager


awaitdcm.__aexit__(None, None, None)

6.1.10 Withdraw Endpoints

Place a withdrawal

Make sure you enable Withdrawal permissions for your API Key to use this call.
You must have withdrawn to the address through the website and approved the withdrawal via email before you can
withdraw using the API.

frombinance.exceptionsimportBinanceAPIException
try:
The name parameter will be set to the asset value by the client if not provided.
client.withdraw(
ETH
<eth_address>
amount=100)
exceptBinanceAPIExceptionase:
print(e)
else:
Success

passing a name parameter


client.withdraw(
ETH
<eth_address>
amount=100,
Withdraw

if the coin requires an extra tag or name such as XRP or XMR then pass an
˓→ `addressTag` parameter.

client.withdraw(
XRP
<xrp_address>
(continues on next page)

40 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


<xrp_address_tag>
amount=10000)

Fetch deposit history

client.get_deposit_history()
client.get_deposit_history(coin='BTC')

Fetch withdraw history

client.get_withdraw_history()
client.get_withdraw_history(coin='BTC')

Get deposit address

client.get_deposit_address(coin='BTC')

6.1.11 Helper Functions

binance.helpers
alias ofbinance.helpers

6.1.12 Exceptions

BinanceRequestException

Raised if a non JSON response is returned

BinanceAPIException

On an API call error, a binance.exceptions.BinanceAPIException will be raised.


The exception provides access to the
response status code
•response- response object
Binance error code
Binance error message
request - request object if available

try:
client.get_all_orders()
exceptBinanceAPIExceptionase:
printe.status_code
print.message

6.1. Contents 41
python-binance Documentation, Release 0.2.0

6.1.13 FAQ

Q: Why do I get “Timestamp for this request is not valid”


A: This occurs in 2 different cases.
The timestamp sent is outside of the serverTime - recvWindow value. The timestamp sent is more than 1000ms ahead.
of the server time
Check that your system time is in sync. Seethis issuefor some sample code to check the difference between your
local time and the Binance server time.
Q: Why do I get 'Signature for this request is not valid'
A1: One of your parameters may not be in the correct format.
Check recvWindow is an integer and not a string.
You may need to regenerate your API Key and Secret
A3: You may be attempting to access the API from a Chinese IP address, these are now restricted by Binance.

6.1.14 Changelog

v1.0.15

Added
Enable/disable margin account for symbol endpoints
Top trader long/short positions endpoint
Global long/short ratio endpoint
Fixed
fix websockets to 9.1
websocket reconnect updates
fix futures kline sockets

v1.0.14

Fixed
• websocket reconnecting

v1.0.13

Added
Futures Depth Cache Manager
Futures kline websocket stream
Coin Futures User websocket stream
New Margin endpoints
Margin OCO order endpoints

42 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Fiat endpoints
C2C endpoints
Account API permissions endpoint
Fixed
changed assettocoinin withdraw endpoint

v1.0.12

Added
coin futures batch order function
Fixed
threaded websockets on python3.9
filter out None params in request kwargs
deconflict streams with the same name on different websocket URLs
reduce close timeout on websocket close to short time to reduce waiting

v1.0.10

Added
futures multi-asset margin mode endpoints
optional symbol param to get_all_tickers
Fixed
start_multiplex_socket remove lower case filter on stream names

v1.0.9

Fixed
• start_book_ticker_socket and start_multiplex_socket to call correct async function

v1.0.8

Added
• old style websocket and depth cache managers as option without interacting with asyncio
Fixed
fixed issue with get_historical_klines in Client
remove print debug line

v1.0.7

Fixed
remove version param from get_sub_account_assets

6.1. Contents 43
python-binance Documentation, Release 0.2.0

v1.0.6

Fixed
Fix time for authenticated stream keepalive

v1.0.5

Fixed
Restored access to last response on client

v1.0.4

Added
Futures Testnet support
Kline type for fetching historical klines
Fixed
Spot Testnet websocket URL

1.0.3

Added
• Spot Testnet support

v1.0.2

Added
• start of typing to client and websockets
Fixed
• end_str, limit, spot parameters in kline fetching
drop None values in params passed
Updated
more examples in docs

v1.0.1

Fixed
• restored params for Client and AsyncClient classes

44 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

v1.0.0

Added
• Async support for all REST endpoints
• USD-M and Coin-M Futures websocket streams
Websockets use the same TLD as Client
• convert type option for DepthCache
Breaking Changes
• Supports only py3.6+
All wapi calls changed to sapi
Websockets have changed to use Asynchronous context managers
Fixed
get_historical_klines_params

v0.7.11

Added-Vanilla Options REST endpoints -Vanilla Options websockets - Futures order type enums
Updated
• websocket keep-alive functions for different socket types
• dependencies
Fixed
Change to User-Agent to avoid connection issues

v0.7.5.dev

Changed - Stock json lib to ujsonUnable to access external links for content.)

0.7.5

Added
• Futures REST endpoints
Lending REST endpoints
OCO Orders function create_oco_order, order_oco_buy, order_oco_sell
Average Price function get_avg_price
Support for other domains (.us, .jp, etc)
Updated
• dependencies
Fixed
websocket keepalive callback not found

6.1. Contents 45
python-binance Documentation, Release 0.2.0

v0.7.4

Added
symbol book ticker websocket streams
margin websocket stream
Updated
can call Client without any params
• make response a property of the Client class so you can access response properties after a request
Fixed
issue with None value params causing errors

v0.7.3

Added
sub account endpoints
dust transfer endpoint
asset dividend history endpoint
Removed
deprecated withdraw fee endpoint

v0.7.2

Added
margin trading endpoints
Fixed
depth cache clearing bug

v0.7.1

Added
limit param to DepthCacheManager
limit param to get_historical_klines
• update_time to DepthCache class
Updated
test coverage
Fixed
super init in Websocket class
removal of request params from signature
empty set issue in aggregate_trade_iter

46 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

v0.7.0

Added
get_asset_details endpoint
get_dust_log endpoint
get_trade_fee endpoint
ability for multiple DepthCacheManagers to share a BinanceSocketManager
get_historial_klines_generator function
custom socket timeout param for BinanceSocketManager
Updated
• general dependency version
• removed support for python3.3
Fixed
• add a super init on BinanceClientProtocol

v0.6.9

Added
timestamp in milliseconds together_historical_klines function
timestamp in milliseconds to aggregate_trade_iter function
Fixed
Don't close user stream listen key on socket close

0.6.8

Added
get_withdraw_fee function
Fixed
Remove unused LISTENKEY_NOT_EXISTS
Optimize the historical klines function to reduce requests
Issue with end_time in aggregate trade iterator

v0.6.7

Fixed
Issue with get_historical_klines when response had exactly 500 results
• Changed BinanceResponseException to BinanceRequestException
Set default code value in BinanceApiException properly

6.1. Contents 47
python-binance Documentation, Release 0.2.0

v0.6.6

Fixed
User stream websocket keep alive strategy updated

v0.6.5

Fixed
get_historical_klines response for month interval

0.6.4

Added
system status endpoint get_system_status

v0.6.3

Added
• mini ticker socket function start_miniticker_socket
• aggregate trade iteratoraggregate_trade_iter
Fixes
clean up interval to milliseconds logic
general doc and file cleanups

v0.6.2

Fixes
fixed handling Binance errors that aren’t JSON objects

v0.6.1

Fixes
added missing dateparser dependency to setup.py
documentation fixes

v0.6.0

New version because why not.


Added
get_historical_klines function to fetch klines for any date range
ability to override requests parameters globally
• error on websocket disconnect

48 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

• example related to blog post


Fixes
documentation fixes

v0.5.17

Added
Check for name parameter in withdraw, set to asset parameter if not passed.
Update
Windows install error documentation
Removed
• reference to disable_validation in documentation

0.5.16

Added
addressTag documentation to withdraw function
documentation about requests proxy environment variables
Update
FAQ for signature error with solution to regenerate API key
• change create_order to create_test_order in example
Fixed
• reference to BinanceAPIException in documentation

v0.5.15

Fixed
removed all references to WEBSOCKET_DEPTH_1 enum

v0.5.14

Added
Wait for depth cache socket to start
• check for sequential depth cache messages
Updated
documentation around depth websocket and diff and partial responses
Removed
Removed unused WEBSOCKET_DEPTH_1 enum
removed unused libraries and imports

6.1. Contents 49
python-binance Documentation, Release 0.2.0

v0.5.13

Fixed
Signature invalid error

0.5.12

Added
get_asset_balance helper function to fetch an individual asset’s balance
Fixed
added timeout to requests call to prevent hanging
changed variable type to str for price parameter when creating an order
documentation fixes

0.5.11

Added
Refresh interval parameter to depth cache to keep it fresh, set default at 30 minutes.
Fixed
watch depth cache socket before fetching order book to replay any messages

v0.5.10

Updated
• updated dependencies certifi and cryptography to help resolve signature error

v0.5.9

Fixed
Fixed websocket reconnecting, there was no distinction between manual close or network error.

0.5.8

Changed
Change the symbol parameter to optional for the get_open_orders function.

• added listenKey parameter to stream_close function


Added
get_account_status function that was missed

50 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

v0.5.7

Changed
Change depth cache callback parameter to optional
Added
• note about stopping Twisted reactor loop to exit program

0.5.6

Added
get_symbol_info function to simplify getting info about a particular symbol

0.5.5

Changed
Increased default limit for order book on depth cache from 10 to 500

0.5.4

Added
• symbol property made public on DepthCache class
Changed
Enums are now also accessible from binance.client.Client and binance.websockets.BinanceSocketManager.

v0.5.3

Changed
User stream refresh timeout from 50 minutes to 30 minutes
• User stream socket listen key change check simplified

v0.5.2

Added
• start_multiplex_socket function to BinanceSocketManager to create multiplexed streams

v0.5.1

Added
Close method for DepthCacheManager
Fixes
Fixed modifying array error message when closing the BinanceSocketManager

6.1. Contents 51
python-binance Documentation, Release 0.2.0

0.5.0

Updating to match new API documentation


Added
Recent trades endpoint
Historical trades endpoint
• Order response type option
Check for invalid user stream listen key in socket to keep connected
Fixes
Fixed exchange info endpoint as it was renamed slightly

v0.4.3

Fixes
Fixed stopping sockets where they were reconnecting
Fixed websockets unable to be restarted after close
Exception in parsing non-JSON websocket message

v0.4.2

Removed
Removed websocket update time as 0ms option is not available

0.4.1

Added
Reconnecting websockets, automatic retry on disconnect

v0.4.0

Added
Get deposit address endpoint
• Upgraded withdraw endpoints to v3
New exchange info endpoint with rate limits and full symbol info
Removed
Order validation to return at a later date

52 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

v0.3.8

Fixes
Fix order validation for market orders
WEBSOCKET_DEPTH_20 value, 20 instead of 5
General tidy up

v0.3.7

Fixes
Fix multiple depth caches sharing a cache by initializing bid and ask objects each time

v0.3.6

Fixes
check if Reactor is already running

v0.3.5

Added
support for BNB market
Fixes
• fixed error if new market type is created that we don’t know about

v0.3.4

Added
depth parameter to depth socket
interval parameter to kline socket
update time parameter for compatible sockets
new enums for socket depth and update time values
better websocket documentation
Changed
Depth Cache Manager uses 0ms socket update time
connection key returned when creating socket, this key is then used to stop it
Fixes
General fixes

Contents 53
python-binance Documentation, Release 0.2.0

v0.3.3

Fixes
Fixes for broken tests

0.3.2

Added
More test coverage of requests
Fixes
Order quantity validation fix

v0.3.1

Added
Withdraw exception handler with translation of obscure error
Fixes
Validation fixes

v0.3.0

Added
Withdraw endpoints
Order helper functions

v0.2.0

Added
Symbol Depth Cache

0.1.6

Changes
• Upgrade to v3 signed endpoints
Update function documentation

v0.1.5

Changes
• Added get_all_tickers call
Added get_orderbook_tickers call
• Added some FAQs

54 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Fixes
Fix error in enum value

0.1.4

Changes
• Added parameter to disable client side order validation

v0.1.3

Changes
Updated documentation
Fixes
Small bugfix

v0.1.2

Added
Travis.CI and Coveralls support
Changes
Validation for pairs using public endpoint

v0.1.1

Added
Validation for HSR/BTC pair

v0.1.0

Websocket release
Added
Websocket manager
Order parameter validation
Order and Symbol enums
API Endpoints for Data Streams

v0.0.2

Initial version
Added
General, Market Data and Account endpoints

6.1. Contents 55
python-binance Documentation, Release 0.2.0

6.1.15 Binance API

client module

classbinance.client.AsyncClient(api_key: Optional[str] = None,api_secret: Optional[str] =


None, requests_params: Dict[str,str] = None, tld: str =
'com', testnet: bool = False, loop=None)
Bases:binance.client.BaseClient
__init__(api_key: Optional[str] = None,api_secret: Optional[str] = None,requests_params:
Dict[str,str] = None, tld: str = 'com', testnet: bool = False, loop=None
Binance API Client constructor
Parameters
Api Key
Api Secret
optional - Dictionary of requests params to use for all
calls
•testnet(bool) – Use testnet environment - only available for vanilla options at the
moment
aggregate_trade_iter(symbol,start_str=None,last_id=None)
Iterate over aggregate trade data from (start_time or last_id) to the end of the history so far.
If start_time is specified, start with the first trade after start_time. Meant to initialise a local cache of trade
data.
If last_id is specified, start with the trade after it. This is meant for updating a pre-existing local trade data.
cache.
Only allows start_str or last_id—not both. Not guaranteed to work right if you’re running more than one
of these simultaneously. You will probably hit your rate limit.
See dateparser docs for valid start and end string formatshttp://dateparser.readthedocs.io/en/latest/
If using offset strings for dates add 'UTC' to date string e.g. 'now UTC', '11 hours ago UTC'
Parameters
•symbol(str) – Symbol string e.g. ETHBTC
•start_str– Start date string in UTC format or timestamp in milliseconds. The iterator
will
return the first trade occurring later than this time. :type start_str: str|int :param last_id: aggregate trade ID
of the last known aggregate trade. Not a regular trade ID. Seehttps://binance-docs.github.io/apidocs/spot/
en/#compressed-aggregate-trades-list
Returns an iterator of JSON objects, one per trade. The format of
each object is identical to Client.aggregate_trades().

cancel_margin_oco_order(**params)
(**params)
cancel_order(**params)
Cancel an active order. Either orderId or origClientOrderId must be sent.
Unable to access the content from the provided link.

56 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Parameters
required
The unique order id
string – optional
newClientOrderId(str) – Used to uniquely identify this cancel. Automatically
generated by default.
recvWindow(int) - the number of milliseconds the request is valid for
ReturnsAPI response

{
LTCBTC
myOrder1
"orderId":1,
cancelMyOrder1
}

RaisesBinanceRequestException, BinanceAPIException

change_fixed_activity_to_daily_position(**params)
close_connection()
classmethod create(api_key: Optional[str] = None, api_secret: Optional[str] = None, re-
None
loop=None
create_isolated_margin_account(**params)
create_margin_loan(**params)
create_margin_oco_order(**params)
create_margin_order(**params)
create_oco_order(**params)
Send in a new OCO order
Unable to access the content from the provided URL to translate.
Parameters
required
A unique id for the list order. Automatically generated
if not sent.
required
decimal - required
•limitClientOrderId(str) – A unique id for the limit order. Automatically generated.
ated if not sent.
required
•limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an iceberg
order.
A unique id for the stop order. Automatically generated
if not sent.

6.1. Contents 57
python-binance Documentation, Release 0.2.0

required
If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make an ice-
Mountain order.

Valid values are GTC/FOK/IOC.


Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
Response ACK:

{
}

Response RESULT:

{
}

Response FULL:

{
}

RaisesBinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_order(**params)
Send in a new order
Any order with an icebergQty MUST have timeInForce set to GTC.
Unable to access the content of the specified URL.
Parameters
required
required
•type(str) – required
required if limit order
required
quoteOrderQty(decimal) – amount the user wants to spend (when buying) or re-
receive (when selling) of the quote asset, applicable to MARKET orders
required
A unique id for the order. Automatically generated if not
sent.
decimal – Used with LIMIT, STOP_LOSS_LIMIT, and
TAKE_PROFIT_LIMIT to create an iceberg order.

58 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Set the response JSON. ACK, RESULT, or FULL;


fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
Response ACK:

{
LTCBTC
"orderId":1,
myOrder1Will be newClientOrderId
"transactTime":1499827319559
}

Response RESULT:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
0.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
}

Response FULL:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
0.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
"fills": [
{
4000.00000000
1.00000000
4.00000000
USDT
},
{
3999.00000000
5.00000000
19.99500000
(continues on next page)

6.1. Contents 59
python-binance Documentation, Release 0.2.0

(continued from previous page)


USDT
},
{
3998.00000000
2.00000000
7.99600000
USDT
},
{
3997.00000000
1.00000000
3.99700000
USDT
},
{
3995.00000000
1.00000000
3.99500000
USDT
}
]
}

Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_sub_account_futures_transfer(**params)
create_test_order(**params)
Test new order creation and signature/recvWindow long. Creates and validates a new order but does not
send it into the matching engine.
The provided link does not contain translatable text.
Parameters
required
required
type(str) – required
required if limit order
required
required
•newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
•icebergQty(decimal) – Used with iceberg orders
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – The number of milliseconds the request is valid for
ReturnsAPI response

60 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{}

RaisesBinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
Binance order: Unknown symbol exception, Binance order: Inactive symbol exception

disable_fast_withdraw_switch(**params)
disable_isolated_margin_account(**params)
enable_fast_withdraw_switch(**params)
enable_isolated_margin_account(**params)
enable_subaccount_futures(**params)
enable_subaccount_margin(**params)
futures_account(**params)
futures_account_balance(**params)
(params)
(**params)
futures_adl_quantile_estimate(**params)
futures_aggregate_trades(**params)
futures_cancel_all_open_orders(**params)
futures_cancel_order(**params)
futures_cancel_orders(**params)
futures_change_leverage(**params)
futures_change_margin_type(**params)
futures_change_multi_assets_mode(multiAssetsMargin: bool)
futures_change_position_margin(**params)
futures_change_position_mode(**params)
futures_coin_account(**params)
futures_coin_account_balance(**params)
(**params)
futures_coin_aggregate_trades(**params)
(**params)
futures_coin_cancel_order(**params)
futures_coin_cancel_orders(**params)
futures_coin_change_leverage(**params)
futures_coin_change_margin_type(**params)
futures_coin_change_position_margin(**params)
change the position mode

6.1. Contents 61
python-binance Documentation, Release 0.2.0

futures_coin_continous_klines(**params)
futures_coin_create_order(**params)
futures_coin_exchange_info()
futures_coin_funding_rate(**params)
futures_coin_get_all_orders(**params)
(**params)
(**params)
futures_coin_get_position_mode(**params)
futures_coin_historical_trades(**params)
(**params)
futures_coin_index_price_klines(**params)
futures_coin_klines(**params)
futures_coin_leverage_bracket(**params)
(**params)
futures_coin_mark_price(**params)
futures_coin_mark_price_klines(**params)
futures_coin_open_interest(**params)
futures_coin_open_interest_hist(**params)
futures_coin_order_book(**params)
futures_coin_orderbook_ticker(**params)
futures_coin_ping()
futures_coin_place_batch_order(**params)
futures_coin_position_information(**params)
futures_coin_position_margin_history(**params)
**params
futures_coin_stream_close(listenKey)
futures_coin_stream_get_listen_key()
futures_coin_stream_keepalive(listenKey)
futures_coin_symbol_ticker(**params)
futures_coin_ticker(**params)
futures_coin_time()
futures_continuous_klines(**params)
futures_create_order(**params)
futures_exchange_info()
futures_funding_rate(**params)
futures_get_all_orders(**params)

62 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

futures_get_multi_assets_mode()
futures_get_open_orders(**params)
futures_get_order(**params)
futures_get_position_mode(**params)
futures_global_longshort_ratio(**params)
futures_historical_klines(symbol,interval,start_str,end_str=None,limit=500)
futures_historical_klines_generator(symbol, interval, start_str, end_str=None)
futures_historical_trades(**params)
futures_income_history(**params)
futures_klines(**params)
futures_leverage_bracket(**params)
futures_liquidation_orders(**params)
futures_mark_price(**params)
(**params)
futures_open_interest_hist(**params)
futures_order_book(**params)
futures_orderbook_ticker(**params)
futures_ping()
(**params)
futures_position_information(**params)
futures_position_margin_history(**params)
futures_recent_trades(**params)
futures_stream_close(listenKey)
futures_stream_get_listen_key()
listenKey
(**params)
futures_ticker(**params)
futures_time()
futures_top_longshort_account_ratio(**params)
futures_top_longshort_position_ratio(**params)
get_account(**params)
Get current account information.
Unable to access external links.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

6.1. Contents 63
python-binance Documentation, Release 0.2.0

{
"makerCommission":15,
"takerCommission":15,
"buyerCommission":0,
"sellerCommission":0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"balances": [
{
BTC
4723846.89208129
0.00000000
},
{
LTC
4763368.68006011
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_account_api_permissions(**params)
Fetch API key permissions.
Unable to access the content of the provided link.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
"ipRestrict": false,
"createTime":1623840271000,
"enableWithdrawals": false, This option allows you to withdraw via
˓→ API. You must apply the IP Access Restriction filter.inorder to enable

˓→ withdrawals

"enableInternalTransfer": true, //This option authorizes this key to


˓→ transfer funds between your master accountandyour sub account instantly

"permitsUniversalTransfer": true, //Authorizes this key to be usedfora


˓→ dedicated universal transfer API to transfer multiple supported currencies.

˓→ Each business's own transfer API rights are not affected by this

˓→ authorization

"enableVanillaOptions": false, //Authorizes this key to Vanilla options


˓→ trading

"enableReading": true,
"enableFutures": false, //API Key created before your futures account
˓→ opened doesnotsupport futures API service

"enableMargin": false, This option can be adjusted after the Cross


˓→ Margin account transferiscompleted

"enableSpotAndMarginTrading": false,//Spotandmargin trading


"tradingAuthorityExpirationTime":1628985600000//Expiration timefor
˓→ spotandmargin trading permission

get_account_api_trading_status(**params)

64 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Fetch account API trading status detail.


Unable to access content from the provided link.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
"data": { API trading status detail
"isLocked": false, API trading functionislockedor not
"plannedRecoverTime":0,//If API trading functionislocked, this
˓→ isthe planned recovery time

"triggerCondition": {
"GCR":150,//Number of GTC orders
"IFER":150,//Number of FOK/IOC orders
"UFR":300 Number of orders
},
"indicators": { //The indicators updated every30seconds
The symbol
{
UFR
"c":20, Count of all orders
"v":0.05, //Current UFR value
"t":0.995 Trigger UFR value
},
{
IFER
"c":20, Count of FOK/IOC orders
"v":0.99, Current IFER value
"t":0.99 //Trigger IFER value
},
{
GCR
"c":20, Count of GTC orders
"v":0.99, Current GCR value
"t":0.99 //Trigger GCR value
}
],
"ETHUSDT": [
{
UFR
"c":20,
"v":0.05,
"t":0.995
},
{
IFER
"c":20,
"v":0.99,
"t":0.99
},
{
GCR
"c":20,
"v":0.99,
"t":0.99
}
]
(continues on next page)

6.1. Contents 65
python-binance Documentation, Release 0.2.0

(continued from previous page)


},
"updateTime":1547630471725
}
}

get_account_snapshot(**params)
get_account_status(**params)
Get account status detail.
Unable to access the requested URL.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
Normal
}

get_aggregate_trades(**params)→Dict[KT, VT]
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price.
will have the quantity aggregated.
Invalid request. Please provide text for translation.
Parameters
required
fromId(str) – ID to get aggregate trades from INCLUSIVE.
Timestamp in ms to get aggregate trades from INCLUSIVE.
•endTime(int) – Timestamp in ms to get aggregate trades until INCLUSIVE.
•limit(int) – Default 500; max 1000.
ReturnsAPI response

[
{
"a":26129, Aggregate tradeId
0.01633102Price
4.70443515Quantity
"f":27781, First tradeId
"l":27781, Last tradeId
"T":1498793709153,# Timestamp
"m": true, Was the buyer the maker?
"M": true Was the trade the best price match?
}
]

RaisesBinanceRequestException, BinanceAPIException

get_all_coins_info(**params)
get_all_isolated_margin_symbols(**params)
get_all_margin_orders(**params)

66 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

get_all_orders(**params)
Get all account orders; active, canceled, or filled.
Unable to access external links.
Parameters
required
The unique order id
•startTime(int) – optional
optional
•limit(int) – Default 500; max 1000.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
0.0
NEW
GTC
LIMIT
BUY
0.0
0.0
"time":1499827319559
}
]

Raises BinanceRequestException, BinanceAPIException

get_all_tickers(symbol: Optional[str] = None)→List[Dict[str, str]]


Latest price for all symbols.
https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker
Returns List of market tickers

[
{
LTCBTC
4.00000200
},
{
ETHBTC
0.07946600
}
]

Raises BinanceRequestException, BinanceAPIException

6.1. Contents 67
python-binance Documentation, Release 0.2.0

get_asset_balance(asset, **params)
Get current asset balance.
Parameters
required
recvWindow(int) – the number of milliseconds the request is valid for
Returns dictionary or None if not found

{
BTC
4723846.89208129
0.00000000
}

Raises BinanceRequestException, BinanceAPIException

get_asset_details(**params)
Fetch details on assets.
Unable to access external links or documents.
Parameters
optional
recvWindow(int) - the number of milliseconds the request is valid for
ReturnsAPI response

{
"CTR": {
70.00000000
"depositStatus": false,//deposit status (falseifALL of networks
˓→ are false)

"withdrawFee":35,//withdraw fee
"withdrawStatus": true,//withdraw status (falseifALL of
˓→ networks' are false)

Delisted, Deposit Suspended


},
"SKY": {
0.02000000
"depositStatus": true,
"withdrawFee":0.01,
"withdrawStatus": true
}
}

get_asset_dividend_history(**params)
Query asset dividend record.
Unable to access the document at the provided URL.
Parameters
optional
optional
(long) - optional

68 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

recvWindow(int) - the number of milliseconds the request is valid for

client.get_asset_dividend_history()

ReturnsAPI response

{
"rows":[
{
10.00000000
BHFT
"divTime":1563189166000,
BHFT distribution
"tranId":2968885920
},
{
10.00000000
BHFT
"divTime":1563189165000,
BHFT distribution
"tranId":2968885920
}
],
"total":2
}

RaisesBinanceRequestException, BinanceAPIException

get_avg_price(**params)
Current average price for a symbol.
The link provided does not contain any text to translate.
Parameters symbol (str) –
ReturnsAPI response

{
"mins":5,
9.35751834
}

get_bnb_burn_spot_margin(**params)
get_c2c_trade_history(**params)
get_cross_margin_data(**params)
get_deposit_address(coin: str, network: Optional[str] = None, **params)
Fetch a deposit address for a symbol
Unable to access external content at this time.
Parameters
required
optional
recvWindow(int) – the number of milliseconds the request is valid for

6.1. Contents 69
python-binance Documentation, Release 0.2.0

ReturnsAPI response

{
1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv
BTC
tag
https://btc.com/1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv
}

RaisesBinanceRequestException, BinanceAPIException

get_deposit_history(**params)
Fetch deposit history.
Unable to access external URLs for translation.
Parameters
optional
(long) - optional
long - optional
•offset(long) – optional - default:0
•limit(long) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
0.00999800
PAXG
ETH
"status":1,
0x788cabe9236ce061e5a892e1a59395a81fc8d62c
addressTag
txId
˓→ 0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3

"insertTime":1599621997000,
"transferType":0,
12/12
},
{
0.50000000
IOTA
IOTA
"status":1,
address
˓→ SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLN

˓→ ",

addressTag
txId
˓→ ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999

˓→ ",

"insertTime":1599620082000,
"transferType":0,
(continues on next page)

70 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


1/1
}
]

RaisesBinanceRequestException, BinanceAPIException

get_dust_assets(**params)
Get assets that can be converted into BNB
The provided link does not contain translatable text.
ReturnsAPI response

{
"details": [
{
ADA
ADA
6.21 Convertible amount
0.00016848
0.01777302
0.01741756
˓→ fee
0.00035546
}
],
0.00016848
0.01777302
0.02 Commission fee
}

get_dust_log(**params)
Get log of small amounts exchanged for BNB.
Unable to access the provided URL.
Parameters
•startTime(int) – optional
•endTime(int) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
"total":8, Total counts of exchange
"userAssetDribblets": [
{
0.00132256 Total transferred BNB
˓→ amountforthis exchange.

0.00002699 Total service


˓→ charge amountforthis exchange.

"transId":45178372831,
"userAssetDribbletDetails": [ Details of this
˓→ exchange.

{
(continues on next page)

6.1. Contents 71
python-binance Documentation, Release 0.2.0

(continued from previous page)


"transId":4359321,
0.000009
0.0009
"operateTime":1615985535000,
0.000441
USDT
},
{
"transId":4359321,
0.00001799
0.0009
2018-05-03 17:07:04
0.00088156
ETH
}
]
},
{
"operateTime":1616203180000,
0.00058795
0.000012
"transId":4357015,
"userAssetDribbletDetails": [
{
"transId":4357015,
0.00001
0.001
"operateTime":1616203180000,
0.00049
USDT
},
{
"transId":4357015,
0.000002
0.0001
"operateTime":1616203180000,
0.00009795
ETH
}
]
}
]
}

Returns a dictionary of exchange information.


Return rate limits and list of symbols
List of product dictionaries
{
UTC
"serverTime":1508631584636,
"rateLimits": [
{
REQUESTS
MINUTE
"limit":1200
(continues on next page)

72 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


},
{
ORDERS
SECOND
"limit":10
},
{
ORDERS
DAY
"limit":100000
}
],
"exchangeFilters": [],
"symbols": [
{
ETHBTC
TRADING
ETH
"baseAssetPrecision":8,
BTC
"quotePrecision":8,
"orderTypes": ["LIMIT","MARKET"],
"icebergAllowed": false,
"filters": [
{
PRICE_FILTER
0.00000100
100000.00000000
0.00000100
}, {
LOT_SIZE
0.00100000
100000.00000000
0.00100000
}, {
MIN_NOTIONAL
0.00100000
}
]
}
]
}

Raises BinanceRequestException, BinanceAPIException

get_fiat_deposit_withdraw_history(**params)
get_fiat_payments_history(**params)
get_fixed_activity_project_list
get_historical_klines(symbol, interval, start_str=None, end_str=None, limit=1000)
binance.enums.HistoricalKlinesType = <HistoricalK-
linesType.SPOT: 1>)
Get Historical Klines from Binance
Parameters

6.1. Contents 73
python-binance Documentation, Release 0.2.0

•symbol(str) – Name of symbol pair e.g BNBBTC


Binance Kline interval
•start_str(str|int) – optional - start date string in UTC format or timestamp in
milliseconds
end_str(str|int) – optional - end date string in UTC format or timestamp in mil-
milliseconds (default will fetch everything up to now)
•limit(int) – Default 1000; max 1000.
Historical klines type: SPOT or FU
TURES
Returns a list of OHLCV values (Open time, Open, High, Low, Close, Volume, Close time, Quote)
asset volume
Ignore)
get_historical_klines_generator(symbol, interval start_str=None,
end_str=None limit=1000 klines_type bi-
nance.enums.HistoricalKlinesType = <HistoricalK-
linesType.SPOT: 1>)
Get Historical Klines generator from Binance
Parameters
Name of symbol pair e.g BNBBTC
interval(str) – Binance Kline interval
optional - Start date string in UTC format or timestamp in
milliseconds
end_str(str|int) – optional - end date string in UTC format or timestamp in milliseconds
milliseconds (default will fetch everything up to now)
amount of candles to return per request (default 1000)
Historical klines type: SPOT or FU-
TURES
Returns generator of OHLCV values
get_historical_trades(**params)→Dict[KT, VT]
Get older trades.
Invalid input. Please provide text for translation.
Parameters
required
•limit(int) – Default 500; max 1000.
•fromId(str) – TradeId to fetch from. Default gets most recent trades.
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
"time":1499865549590,
(continues on next page)

74 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


"isBuyerMaker": true,
"isBestMatch": true
}
]

RaisesBinanceRequestException, BinanceAPIException

get_isolated_margin_account(**params)
get_isolated_margin_symbol(**params)
get_klines(**params)→Dict[KT, VT]
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
The provided text is a URL and cannot be translated.
Parameters
required
(str)

int
–Default 500; max 1000.
int
int
ReturnsAPI response
[
[
1499040000000, Open time
0.01634790 Open
0.80000000 High
0.01575800 Low
0.01577100 Close
148976.11427815Volume
1499644799999 Close time
2434.19055334 Quote asset volume
308 Number of trades
1756.87402397 Taker buy base asset volume
28.46694368 Taker buy quote asset volume
17928899.62484339Can be ignored
]
]

Raises BinanceRequestException, BinanceAPIException

get_lending_account(**params)
get lending daily quota left (**params)
get_lending_daily_redemption_quota(**params)
get_lending_interest_history(**params)
get_lending_position(**params)

6.1. Contents 75
python-binance Documentation, Release 0.2.0

get_lending_product_list(**params)
get_lending_purchase_history(**params)
get_lending_redemption_history(**params)
get_margin_account(**params)
Query cross-margin account details
The provided link does not contain text to translate.
ReturnsAPI response

{
"borrowEnabled": true,
11.64405625
6.82728457
0.58633215
6.24095242
"tradeEnabled": true,
"transferEnabled": true,
"userAssets": [
{
BTC
0.00000000
0.00499500
0.00000000
0.00000000
0.00499500
},
{
BNB
201.66666672
2346.50000000
0.00000000
0.00000000
2144.83333328
},
{
ETH
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
},
{
USDT
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_margin_all_assets(**params)

76 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

get_margin_all_pairs(**params)
get_margin_asset(**params)
get_margin_force_liquidation_rec(**params)
get_margin_interest_history(**params)
get_margin_loan_details(**params)
get_margin_oco_order(**params)
get_margin_order(**params)
get_margin_price_index(**params)
get_margin_repay_details(**params)
get_margin_symbol(**params)
get_margin_trades(**params)
get_max_margin_loan(**params)
get_max_margin_transfer(**params)
get_my_trades(**params)
Get trades for a specific symbol.
Unable to access the content of the URL provided.
Parameters
required
•startTime(int) – optional
optional
Default 500; max 1000.
FromId(int) – TradeId to fetch from. Default gets most recent trades.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
10.10000000
BNB
"time":1499865549590,
"isBuyer": true,
"isMaker": false,
"isBestMatch": true
}
]

RaisesBinanceRequestException, BinanceAPIException

get_open_margin_oco_orders(**params)
get_open_margin_orders(**params)

6.1. Contents 77
python-binance Documentation, Release 0.2.0

get_open_orders(**params)
Get all open orders on a symbol.
Unable to access the provided URL to translate.
Parameters
•symbol(str) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
0.0
NEW
GTC
LIMIT
BUY
0.0
0.0
"time":1499827319559
}
]

RaisesBinanceRequestException, BinanceAPIException

get_order(**params)
Check an order’s status. Either orderId or origClientOrderId must be sent.
Unable to access external links.
Parameters
required
The unique order id
(str) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
0.0
NEW
GTC
LIMIT
BUY
(continues on next page)

78 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.0
0.0
"time":1499827319559
}

RaisesBinanceRequestException, BinanceAPIException

get_order_book(**params)→Dict[KT, VT]
Get the Order Book for the market
The provided text is a URL and does not contain translatable content.
Parameters
required
•limit(int) – Default 100; max 1000
ReturnsAPI response

{
"lastUpdateId":1027024,
"bids": [
[
4.00000000 PRICE
431.00000000 QTY
[] Can be ignored
]
],
"asks": [
[
4.00000200
12.00000000
[]
]
]
}

Raises Binance Request Exception, Binance API Exception

get_orderbook_ticker(**params)
Latest price for a symbol or symbols.
The provided link does not contain translatable text.
Parameterssymbol(str) –
ReturnsAPI response

{
LTCBTC
4.00000000
431.00000000
4.00000200
9.00000000
}

OR

6.1. Contents 79
python-binance Documentation, Release 0.2.0

[
{
LTCBTC
4.00000000
431.00000000
4.00000200
9.00000000
},
{
ETHBTC
0.07946700
9.00000000
100000.00000000
1000.00000000
}
]

RaisesBinanceRequestException, BinanceAPIException

get_orderbook_tickers() → Dict[KT, VT]


Best price/qty on the order book for all symbols.
Invalid input. Please provide text for translation.
Parameterssymbol(str) – optional
Returns List of order book market entries

[
{
LTCBTC
4.00000000
431.00000000
4.00000200
9.00000000
},
{
ETHBTC
0.07946700
9.00000000
100000.00000000
1000.00000000
}
]

RaisesBinanceRequestException, BinanceAPIException

Returns a dictionary mapping keys of type KT to values of type VT.


Return list of products currently listed on Binance
Use get_exchange_info() call instead
List of product dictionaries
RaisesBinanceRequestException, BinanceAPIException
(**params)→Dict[KT, VT]
Get recent trades (up to last 500).

80 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

The provided text is a URL and does not contain translatable content.
Parameters
string - required
•limit(int) – Default 500; max 1000.
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
"time":1499865549590,
"isBuyerMaker": true,
"isBestMatch": true
}
]

RaisesBinanceRequestException, BinanceAPIException

Dict[KT, VT]
Test connectivity to the Rest API and get the current server time.
Check Server Time
Returns current server time

{
"serverTime":1499827319559
}

RaisesBinanceRequestException, BinanceAPIException

get_sub_account_assets(**params)
get_sub_account_futures_transfer_history(**params)
get_sub_account_list(**params)
get_sub_account_transfer_history(**params)
get_subaccount_deposit_address(**params)
get_subaccount_deposit_history(**params)
get_subaccount_futures_details(**params)
get_subaccount_futures_margin_status(**params)
get_subaccount_futures_positionrisk(**params)
get_subaccount_futures_summary(**params)
get_subaccount_margin_details(**params)
get_subaccount_margin_summary(**params)
get_subaccount_transfer_history(**params)
get_symbol_info(symbol)→Optional[Dict[KT, VT]]
Return information about a symbol

6.1. Contents 81
python-binance Documentation, Release 0.2.0

Parametersymbol(str) – required e.g BNBBTC


ReturnsDict if found, None if not

{
ETHBTC
TRADING
ETH
"baseAssetPrecision":8,
BTC
"quotePrecision":8,
"orderTypes": ["LIMIT","MARKET"],
"icebergAllowed": false,
"filters": [
{
PRICE_FILTER
0.00000100
100000.00000000
0.00000100
}, {
LOT_SIZE
0.00100000
100000.00000000
0.00100000
}, {
MIN_NOTIONAL
0.00100000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_symbol_ticker(**params)
Latest price for a symbol or symbols.
The provided link does not contain translatable text.
Parameters symbol (str) –
ReturnsAPI response

{
LTCBTC
4.00000200
}

OR

[
{
LTCBTC
4.00000200
},
{
ETHBTC
0.07946600
}
]

82 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException, BinanceAPIException

get_system_status()
Get system status detail.
Unable to access the content of the provided link.
ReturnsAPI response
{
"status":0, normal system maintenance
normal normal or System maintenance.
}

Raises Binance API Exception

get_ticker(**params)
24 hour price change statistics.
24hr Ticker Price Change Statistics
Parameterssymbol(str) –
ReturnsAPI response
{
-94.99999800
-95.960
0.29628482
0.10002000
4.00000200
4.00000000
4.00000200
99.00000000
100.00000000
0.10000000
8913.30000000
"openTime":1499783499040,
"closeTime":1499869899040,
"fristId":28385, First tradeId
"lastId":28460, Last tradeId
"count":76 Trade count
}

OR
[
{
-94.99999800
-95.960
0.29628482
0.10002000
4.00000200
4.00000000
4.00000200
99.00000000
100.00000000
0.10000000
8913.30000000
(continues on next page)

6.1. Contents 83
python-binance Documentation, Release 0.2.0

(continued from previous page)


"openTime":1499783499040,
"closeTime":1499869899040,
"fristId":28385, First tradeId
"lastId":28460, Last tradeId
"count":76 Trade count
}
]

RaisesBinanceRequestException, BinanceAPIException

get_trade_fee(**params)
Get trade fee.
Trade Fee
Parameters
optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
ADABNB
0.001
0.001
},
{
BNBBTC
0.001
0.001
}
]

get_universal_transfer_history(**params)
get_withdraw_history(**params)
Fetch withdraw history.
Unable to access provided URL for translation.
Parameters
•coin(str) – optional
•offset(int) – optional - default:0
optional
•startTime(int) – optional - Default: 90 days from current timestamp
•endTime(int) – optional - Default: present timestamp
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

84 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

[
{
0x94df8b352de7f46f64b01d3666bf6e936e44ce60
8.91000000
2019-10-12 11:12:02
USDT
b6ae22b3aa844210a7041aee7589627c
WITHDRAWtest123notbe returnedifthere
˓→ There's no withdrawOrderId for this withdraw.
ETH
"transferType":0, //1forinternal transferforexternal
˓→ transfer
"status":6,
txId
˓→ 0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268

},
{
1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB
0.00150000
2019-09-24 12:43:45
BTC
156ec387f49b41df8724fa744fa82719
BTC
"status":6,
txId
˓→ 60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354

}
]

Raises BinanceRequestException, BinanceAPIException

get_withdraw_history_id(withdraw_id, **params)
Fetch withdraw history.
Unable to access the content from the provided URL.
Parameters
required
optional
long - optional
•endTime(long) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
7213fea8e94b4a5593d507237e5a555b
withdrawOrderIdNone,
"amount":0.99,
"transactionFee":0.01,
0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b
ETH
txId
˓→ 0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1

(continues on next page)

6.1. Contents 85
python-binance Documentation, Release 0.2.0

(continued from previous page)


"applyTime":1508198532000,
"status":4
}

RaisesBinanceRequestException, BinanceAPIException

isolated_margin_stream_close(symbol, listenKey)
isolated_margin_stream_get_listen_key(symbol)
isolated_margin_stream_keepalive(symbol,listenKey)
make_subaccount_futures_transfer(**params)
make_subaccount_margin_transfer(**params)
make_subaccount_to_master_transfer(**params)
make_subaccount_to_subaccount_transfer(**params)
make_subaccount_universal_transfer(**params)
make_universal_transfer(**params)
User Universal Transfer
The input text is a URL and does not contain translatable content.
Parameters
•type(str (ENUM)) – required
required
required
recvWindow(int) – the number of milliseconds the request is valid for

client.make_universal_transfer(params)

ReturnsAPI response

{
"tranId":13526853623
}

RaisesBinanceRequestException, BinanceAPIException

margin_stream_close(listenKey)
margin_stream_get_listen_key()
margin_stream_keepalive(listenKey)
new_transfer_history(**params)
options_account_info(**params)
options_bill(**params)
options_cancel_all_orders(**params)
options_cancel_batch_order(**params)

86 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

options_cancel_order(**params)
options_exchange_info()
options_funds_transfer(**params)
options_historical_trades(**params)
options_index_price(**params)
options_info()
options_klines(**params)
options_mark_price(**params)
options_order_book(**params)
options_ping()
options_place_batch_order(**params)
options_place_order(**params)
options_positions(**params)
options_price(**params)
options_query_order(**params)
options_query_order_history(**params)
options_query_pending_orders(**params)
options_recent_trades(**params)
options_time()
options_user_trades(**params)
order_limit(timeInForce=’GTC’,**params)
Send in a new limit order
Any order with an icebergQty MUST have timeInForce set to GTC.
Parameters
required
required
decimal - required
required
default Good till cancelled
newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
decimal – Used with LIMIT, STOP_LOSS_LIMIT, and
TAKE_PROFIT_LIMIT to create an iceberg order.
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
•recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

6.1. Contents 87
python-binance Documentation, Release 0.2.0

See order endpoint for full response options


Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
order_limit_buy(timeInForce='GTC', **params)
Send in a new limit buy order
Any order with an icebergQty MUST have timeInForce set to GTC.
Parameters
str - required
required
required
default Good till cancelled
•newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
Used with stop orders
Used with iceberg orders
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
order_limit_sell(timeInForce=’GTC’,**params)
Send in a new limit sell order
Parameters
required
required
required
default Good till cancelled
newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
Used with stop orders
iceberg quantity (decimal) - Used with iceberg orders

Set the response JSON. ACK, RESULT, or FULL;


fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

88 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

See order endpoint for full response options


Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
order_market(**params)
Send in a new market order
Parameters
required
required
required
quoteOrderQty(decimal) – amount the user wants to spend (when buying) or re-
receive (when selling) of the quote asset
newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
newOrderRespType(str) – Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
order_market_buy(**params)
Send in a new market buy order
Parameters
required
required
quoteOrderQty(decimal) – the amount the user wants to spend of the quote asset
•newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
Binance order unknown symbol exception, Binance order inactive symbol exception
order_market_sell(**params)
Send in a new market sell order
Parameters

6.1. Contents 89
python-binance Documentation, Release 0.2.0

required
decimal - required
the amount the user wants to receive of the quote asset
A unique id for the order. Automatically generated if not
sent.
•newOrderRespType(str) – Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
order_oco_buy(**params)
Send in a new OCO buy order
Parameters
str - required
A unique id for the list order. Automatically generated
if not sent.
required
•limitClientOrderId(str) – A unique id for the limit order. Automatically generated
ated if not sent.
required
•limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an iceberg
order.
A unique id for the stop order. Automatically generated
if not sent.
required
stopLimitPrice(str) – If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make an ice-
mountain order.

Valid values are GTC/FOK/IOC.


Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See OCO order endpoint for full response options
Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

90 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

order_oco_sell(**params)
Send in a new OCO sell order
Parameters
required
A unique id for the list order. Automatically generated
if not sent.
decimal - required
A unique id for the limit order. Automatically generated.
ated if not sent.
required
limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an iceberg
order.
A unique id for the stop order. Automatically generated
if not sent.
required
stopLimitPrice(str) – If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make an ice-
mountain order.

Valid values are GTC/FOK/IOC.


newOrderRespType(str) – Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See OCO order endpoint for full response options
RaisesBinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
Dict[KT, VT]
Test connectivity to the Rest API.
Unable to access the URL provided.
Returns Empty array

{}

RaisesBinanceRequestException, BinanceAPIException

purchase_lending_product(**params)
query_subaccount_spot_summary(**params)
universal_transfer_history
Query User Universal Transfer History
Unable to access the content of the provided URL.
Parameters

6.1. Contents 91
python-binance Documentation, Release 0.2.0

•type(str (ENUM)) – required


optional
optional (int)
optional - Default 1
•size(int) – required - Default 10, Max 100
•recvWindow(int) – the number of milliseconds the request is valid for

client.query_universal_transfer_history(params)

ReturnsAPI response

{
"total":2,
"rows":[
{
USDT
1
MAIN_UMFUTURE
CONFIRMED
"tranId":11415955596,
"timestamp":1544433328000
},
{
USDT
2
MAIN_UMFUTURE
CONFIRMED
"tranId":11366865406,
"timestamp":1544433328000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

redeem_lending_product(**params)
(**params)
stream_close(listenKey)
Close out a user data stream.
The provided text is a link to documentation and does not contain translatable content.
(str) - required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

92 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

stream_get_listen_key()
Start a new user data stream and return the listen key. If a stream already exists, it should return the same.
key. If the stream becomes invalid a new key is returned.
Can be used to keep the user stream alive.
Unable to access external links for translation.
ReturnsAPI response

{
listenKey
˓→ pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1
}

RaisesBinanceRequestException, BinanceAPIException

stream_keepalive(listenKey)
PING a user data stream to prevent a time out.
I cannot access or retrieve content from external links.
str - required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

toggle_bnb_burn_spot_margin(**params)
transfer_dust(**params)
Convert dust assets to BNB.
The provided link does not contain translatable text. Please provide text that needs to be translated.
Parameters
The asset being converted. e.g: ‘ONE’
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_dust(asset='ONE')

ReturnsAPI response

{
0.02102542
1.05127099
"transferResult":[
{
0.03000000
ETH
"operateTime":1563368549307,
0.00500000
"tranId":2970932918,
0.25000000
}
(continues on next page)

6.1. Contents 93
python-binance Documentation, Release 0.2.0

(continued from previous page)


]
}

RaisesBinanceRequestException, BinanceAPIException

(**params)
transfer_isolated_margin_to_spot(**params)
transfer_margin_to_spot(**params)
transfer_spot_to_isolated_margin(**params)
(params)
universal_transfer(**params)
(**params)
Submit a withdrawal request.
Invalid link provided. Translation requires specific text.
Assumptions:
You must have Withdraw permissions enabled on your API key
You must have withdrawn to the address specified through the website and approved the transaction.
via email

Parameters
required
optional - client id for withdraw
optional
optional
required
true
returning the fee to the destination account; false for returning the fee back to the departure
account. Default false.
optional - Description of the address, default asset value passed will be
used
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
7213fea8e94b4a5593d507237e5a555b
}

RaisesBinanceRequestException, BinanceAPIException

class binance.client.BaseClient(api_key: Optional[str] = None, api_secret: Optional[str] =


None,requests_params: Dict[str,str] = None,tld: str = ’com’,
testnet: bool = False)
Bases:object

94 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

M
m
f
a
l
p
q
T
https://testnet.binance.vision/api
https://api.binance.{}/api
CMFUTURE_MAIN
C2C_MINING
C2C_MAIN
C2C_UMFUTURE
v1
v2
https://testnet.binancefuture.com/futures/data
https://dapi.binance.{}/futures/data
https://testnet.binancefuture.com/dapi
https://dapi.binance.{}/dapi
https://testnet.binancefuture.com/futures/data
https://fapi.binance.{}/futures/data
https://testnet.binancefuture.com/fapi
https://fapi.binance.{}/fapi
LIMIT
LIMIT_MAKER
MARKET
STOP
STOP_MARKET
TAKE_PROFIT
TAKE_PROFIT_MARKET
12h
15m
1d
1h
1m

6.1. Contents 95
python-binance Documentation, Release 0.2.0

1M
1w
2h
30m
3d
3m
4h
5m
6h
8h
https://api.binance.{}/sapi
v1
MARGIN_MAIN
MARGIN_UMFUTURE
MINING_C2C
MINING_MAIN
MINING_UMFUTURE
v1
https://testnet.binanceops.{}/vapi
https://vapi.binance.{}/vapi
ACK
FULL
RESULT
CANCELED
EXPIRED
FILLED
NEW
PARTIALLY_FILLED
PENDING_CANCEL
REJECTED
LIMIT
LIMIT_MAKER
MARKET
STOP_LOSS
STOP_LOSS_LIMIT
TAKE_PROFIT

96 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

TAKE_PROFIT_LIMIT
v3
v1
REQUEST_TIMEOUT = 10
BUY
SELL
MAIN_CMFUTURE
MAIN_C2C
MAIN_MARGIN
MAIN_MINING
MAIN_UMFUTURE
SPOT
FOK
GTC
IOC
UMFUTURE_C2C
UMFUTURE_MARGIN
UMFUTURE_MAIN
https://www.binance.{}
__init__(api_key: Optional[str] = None,api_secret: Optional[str] = None,requests_params:
Dict[str,str] = None, tld: str = 'com', testnet: bool = False
Binance API Client constructor
Parameters
Api Key
Api Secret
optional - Dictionary of requests params to use for all
calls
•testnet(bool) – Use testnet environment - only available for vanilla options at the
moment
class binance.client.Client(api_key: Optional[str] = None, api_secret: Optional[str] = None,
requests_params: Dict[str,str] = None,tld: str = ’com’,testnet:
bool = False)
Bases:binance.client.BaseClient
__init__(api_key: Optional[str] = None, api_secret: Optional[str] = None, requests_params:
Dict[str,str] = None,tld: str = 'com',testnet: bool = False)
Binance API Client constructor
Parameters
Api Key
Api Secret

6.1. Contents 97
python-binance Documentation, Release 0.2.0

optional - Dictionary of requests params to use for all


calls
•testnet(bool) – Use testnet environment - only available for vanilla options at the
moment
aggregate_trade_iter(symbol: str,start_str=None,last_id=None)
Iterate over aggregate trade data from (start_time or last_id) to the end of the history so far.
If start_time is specified, start with the first trade after start_time. Meant to initialize a local cache of trade
data.
If last_id is specified, start with the trade after it. This is meant for updating a pre-existing local trade data.
cache.
Only allows start_str or last_id—not both. Not guaranteed to work right if you’re running more than one
of these simultaneously. You will probably hit your rate limit.
See dateparser docs for valid start and end string formatshttp://dateparser.readthedocs.io/en/latest/
If using offset strings for dates, add 'UTC' to date string e.g. 'now UTC', '11 hours ago UTC'
Parameters
Symbol string e.g. ETHBTC
•start_str– Start date string in UTC format or timestamp in milliseconds. The iterator
will
return the first trade occurring later than this time. :type start_str: str|int :param last_id: aggregate trade ID
of the last known aggregate trade. Not a regular trade ID. SeeThe provided text is a URL and cannot be translated.
en/#compressed-aggregate-trades-list
Returns an iterator of JSON objects, one per trade. The format of
each object is identical to Client.aggregate_trades().

cancel_margin_oco_order(**params)
Cancel an entire Order List for a margin account.
The provided link does not contain translatable text.
Parameters
required
•isIsolated– for isolated margin or not, “TRUE”, “FALSE”default “FALSE”
•orderListId(int) – Either orderListId or listClientOrderId must be provided
•listClientOrderId(str) – Either orderListId or listClientOrderId must be pro-
vided
newClientOrderId(str) – Used to uniquely identify this cancel. Automatically
generated by default.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
{
"orderListId":0,
OCO
ALL_DONE
(continues on next page)

98 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


ALL_DONE
C3wyj4WVEktd7u9aVBRXcN
"transactionTime":1574040868128,
LTCBTC
"isIsolated": false, // ifisolated margin
"orders": [
{
LTCBTC
"orderId":2,
pO9ufTiFGg3nw2fOdgeOXa
},
{
LTCBTC
"orderId":3,
TXOvglzXuaubXAaENpaRCB
}
],
"orderReports": [
{
LTCBTC
pO9ufTiFGg3nw2fOdgeOXa
"orderId":2,
"orderListId":0,
unfWT8ig8i0uj6lPuYLez6
1.00000000
10.00000000
0.00000000
0.00000000
CANCELED
GTC
STOP_LOSS_LIMIT
SELL
1.00000000
},
{
LTCBTC
TXOvglzXuaubXAaENpaRCB
"orderId":3,
"orderListId":0,
unfWT8ig8i0uj6lPuYLez6
3.00000000
10.00000000
0.00000000
0.00000000
CANCELED
GTC
LIMIT_MAKER
SELL
}
]
}

cancel_margin_order
Cancel an active order for margin account.
Either orderId or origClientOrderId must be sent.
The provided link appears to lead to the Binance API documentation for the endpoint related to canceling orders in a margin account for trading. You can find further details regarding this functionality at the specified URL.

6.1. Contents 99
python-binance Documentation, Release 0.2.0

Parameters
str - required
set to 'TRUE' for isolated margin (default 'FALSE')
str
origClientOrderId(str)
newClientOrderId(str) - Used to uniquely identify this cancel. Automatically
generated by default.
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
LTCBTC
cancelMyOrder1
10.00000000
8.00000000
SELL
}
Raises BinanceRequestException, BinanceAPIException
cancel_order(**params)
Cancel an active order. Either orderId or origClientOrderId must be sent.
Unable to access the provided URL.
Parameters
required
The unique order id
optional
newClientOrderId(str) – Used to uniquely identify this cancel. Automatically
generated by default.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
LTCBTC
myOrder1
"orderId":1,
cancelMyOrder1
}

RaisesBinanceRequestException, BinanceAPIException

change_fixed_activity_to_daily_position(**params)
Change Fixed/Activity Position to Daily Position
Unable to access the content of the provided URL.
data
close_connection()

100 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

create_isolated_margin_account(**params)
Create isolated margin account for symbol
Unable to access the content from the provided URL.
Parameters
Base asset of symbol
•quote(str) – Quote asset of symbol

client.create_isolated_margin_account(base='USDT', quote='BTC')

ReturnsAPI response

{
"success": true,
BTCUSDT
}

RaisesBinanceRequestException, BinanceAPIException

create_margin_loan(**params)
Apply for a loan in cross-margin or isolated-margin account.
Invalid request: The provided URL is not translatable text.
Parameters
name of the asset
amount to transfer
set to 'TRUE' for isolated margin (default 'FALSE')
Isolated margin symbol (default blank for cross-margin)
recvWindow(int) – the number of milliseconds the request is valid for

client.margin_create_loan(asset='BTC', amount='1.1')

client.margin_create_loan(asset='BTC', amount='1.1')
TRUE

ReturnsAPI response

{
"tranId":100000001
}

RaisesBinanceRequestException, BinanceAPIException

create_margin_oco_order(**params)
Post a new OCO trade for margin account.
Unable to access external links.
Parameters
required

6.1. Contents 101


python-binance Documentation, Release 0.2.0

for isolated margin or not, 'TRUE', 'FALSE' default 'FALSE'


A unique id for the list order. Automatically generated
if not sent.
required
required
limitClientOrderId(str) – A unique id for the limit order.
ated if not sent.
required
•limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an iceberg
order.
•stopClientOrderId(str) – A unique Id for the stop loss/stop loss limit leg. Auto-
matically generated if not sent.
required
•stopLimitPrice(str) – If provided, stopLimitTimeInForce is required.
•stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make an ice-
mountain order.

Valid values are GTC/FOK/IOC.


•newOrderRespType(str) – Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
•sideEffectType(str) – NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; de-
fault NO_SIDE_EFFECT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
{
"orderListId":0,
OCO
EXEC_STARTED
EXECUTING
JYVpp3F0f5CAG15DhtrqLp
"transactionTime":1563417480525,
LTCBTC
5 willnot return ifno margin trade
˓→ happens

BTC willnot return ifno margin trade


˓→ happens

"isIsolated": false, // ifisolated margin


"orders": [
{
LTCBTC
"orderId":2,
Kk7sqHb9J6mJWTMDVW7Vos
},
{
LTCBTC
"orderId":3,
xTXKaGYd4bluPVp78IVRvl
}
(continues on next page)

102 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


],
"orderReports": [
{
LTCBTC
"orderId":2,
"orderListId":0,
Kk7sqHb9J6mJWTMDVW7Vos
"transactTime":1563417480525,
0.000000
0.624363
0.000000
0.000000
NEW
GTC
STOP_LOSS
BUY
0.960664
},
{
LTCBTC
"orderId":3,
"orderListId":0,
xTXKaGYd4bluPVp78IVRvl
"transactTime":1563417480525,
0.036435
0.624363
0.000000
0.000000
NEW
GTC
LIMIT_MAKER
BUY
}
]
}

Raises Binance Request Exception, Binance API Exception, Binance Order Exception, Binance Order...
derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_margin_order(**params)
Post a new order for margin account.
Unable to access external links. Please provide the text you want translated.
Parameters
required
isIsolated(str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)
required
•type(str) – required
•quantity(decimal) – required
required

6.1. Contents 103


python-binance Documentation, Release 0.2.0

•stopPrice(str) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT,


and TAKE_PROFIT_LIMIT orders.
required if limit order GTC, IOC, FOK
•newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
iceberg quantity (string)
– Used with LIMIT, STOP_LOSS_LIMIT, and
TAKE_PROFIT_LIMIT for creating an iceberg order.
Set the response JSON. ACK, RESULT, or FULL;
KET and LIMIT order types default to FULL, all other orders default to ACK.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
Response ACK:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595
}

Response RESULT:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
1.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
}

Response FULL:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
1.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
"fills": [
(continues on next page)

104 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


{
4000.00000000
1.00000000
4.00000000
USDT
},
{
3999.00000000
5.00000000
19.99500000
USDT
},
{
3998.00000000
2.00000000
7.99600000
USDT
},
{
3997.00000000
1.00000000
3.99700000
USDT
},
{
3995.00000000
1.00000000
3.99500000
USDT
}
]
}

Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


MinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_oco_order(**params)
Send in a new OCO order
Unable to access or retrieve content from the provided URL.
Parameters
required
A unique id for the list order. Automatically generated
if not sent.
required
required
limitClientOrderId(str) – A unique id for the limit order. Automatically generated.
ated if not sent.
required

6.1. Contents 105


python-binance Documentation, Release 0.2.0

limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an iceberg


order.
A unique id for the stop order. Automatically generated.
if not sent.
required
If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) - Used with STOP_LOSS_LIMIT leg to make an ice-
mount order.
•stopLimitTimeInForce(str) –Valid values are GTC/FOK/IOC.
•newOrderRespType(str) – Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
Response ACK:

{
}

Response RESULT:

{
}

Response FULL:

{
}

Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_order(**params)
Send in a new order
Any order with an icebergQty MUST have timeInForce set to GTC.
Unable to access external links or content.
Parameters
required
required
•type(str) – required
required if limit order
required
quoteOrderQty(decimal) – amount the user wants to spend (when buying) or re-
receive (when selling) of the quote asset, applicable to MARKET orders
required

106 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

•newClientOrderId(str) – A unique id for the order. Automatically generated if not


sent.
icebergQty(decimal) – Used with LIMIT, STOP_LOSS_LIMIT, and
TAKE_PROFIT_LIMIT to create an iceberg order.
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
Response ACK:

{
LTCBTC
"orderId":1,
myOrder1Will be newClientOrderId
"transactTime":1499827319559
}

Response RESULT:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
0.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
}

Response FULL:

{
BTCUSDT
"orderId":28,
6gCrw2kRUAF9CvJDGP16IP
"transactTime":1507725176595,
0.00000000
10.00000000
10.00000000
10.00000000
FILLED
GTC
MARKET
SELL
"fills": [
{
4000.00000000
1.00000000
4.00000000
(continues on next page)

6.1. Contents 107


python-binance Documentation, Release 0.2.0

(continued from previous page)


USDT
},
{
3999.00000000
5.00000000
19.99500000
USDT
},
{
3998.00000000
2.00000000
7.99600000
USDT
},
{
3997.00000000
1.00000000
3.99700000
USDT
},
{
3995.00000000
1.00000000
3.99500000
USDT
}
]
}

Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_sub_account_futures_transfer(**params)
Execute sub-account Futures transfer
Invalid input. Please provide text for translation.
wapi-api.md#sub-account-transfer-for-master-account
Parameters
Sender email
required - Recipient email
int – required
required
required
recvWindow(int) - optional
ReturnsAPI response

{
"success":true,
2934662589
}

108 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Raises BinanceRequestException, BinanceAPIException

create_test_order(**params)
Test new order creation and signature/recvWindow long. Creates and validates a new order but does not
send it into the matching engine.
Unable to access external URLs or content.
Parameters
required
required
•type(str) – required
required if limit order
decimal - required
required
•newClientOrderId(str) – A unique id for the order. Automatically generated if not
sent.
Used with iceberg orders
Set the response JSON. ACK, RESULT, or FULL;
fault: RESULT.
recvWindow(int) – The number of milliseconds the request is valid for
ReturnsAPI response

{}

Raises BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOr-


derMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalExcep-
tion, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

disable_fast_withdraw_switch(**params)
Disable Fast Withdraw Switch
Unable to access the provided URL for translation.
Parameters recvWindow(int) – optional
ReturnsAPI response
RaisesBinanceRequestException, BinanceAPIException
disable_isolated_margin_account(**params)
Disable isolated margin account for a specific symbol. Each trading pair can only be deactivated once.
every 24 hours.
The requested link cannot be translated as it is not provided text.
Parameter symbol–
ReturnsAPI response

6.1. Contents 109


python-binance Documentation, Release 0.2.0

{
"success": true,
BTCUSDT
}

enable_fast_withdraw_switch(**params)
Enable Fast Withdraw Switch
This is a link to the Binance API documentation regarding enabling the fast withdrawal switch for user data.
Parameters recvWindow(int) – optional
ReturnsAPI response
RaisesBinanceRequestException, BinanceAPIException
enable_isolated_margin_account(**params)
Enable isolated margin account for a specific symbol.
Unable to access the provided link for translation.
Parameter symbol–
ReturnsAPI response

{
"success": true,
BTCUSDT
}

enable_subaccount_futures(**params)
Enable Futures for Sub-account (For Master Account)
Unable to access external links or documents.
Parameters
required - Sub account email
recvWindow(int) – optional
ReturnsAPI response

[email protected]

"isFuturesEnabled": true //trueorfalse

RaisesBinanceRequestException, BinanceAPIException

enable_subaccount_margin(**params)
Enable Margin for Sub-account (For Master Account)
Unable to access the provided URL
Parameters
required - Sub account email
•recvWindow(int) – optional

110 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

ReturnsAPI response

[email protected]

"isMarginEnabled": true

RaisesBinanceRequestException, BinanceAPIException

(**params)
Get current account information.
The provided link is not text that can be translated. Please provide specific text to translate.
(**params)
Get futures account balance
The provided link does not contain translatable text.
futures_account_trades(**params)
Get trades for the authenticated account and symbol.
Unable to access external URLs to fetch content. Please provide the text you want translated.
futures_account_transfer(**params)
Execute transfer between spot account and futures account.
New Future Account Transfer
futures_adl_quantile_estimate(**params)
Get Position ADL Quantile Estimate
Unable to access the provided URL. Please provide the text you would like to translate.
futures_aggregate_trades(**params)
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price.
will have the quantity aggregated.
Unable to access the provided URL.
**params
Cancel all open futures orders
Cancel all open orders (trade)
futures_cancel_order(**params)
Cancel an active futures order.
Unable to access external links for content translation.
futures_cancel_orders(**params)
Cancel multiple futures orders
https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade
(**params)
Change user's initial leverage of specific symbol market
The provided text is a URL link and does not contain translatable text.

6.1. Contents 111


python-binance Documentation, Release 0.2.0

futures_change_margin_type(**params)
Change the margin type for a symbol
https://binance-docs.github.io/apidocs/futures/en/#change-margin-type-trade
futures_change_multi_assets_mode(multiAssetsMargin: bool)
Change user's Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol
Invalid URL provided for translation.
futures_change_position_margin(**params)
Change the position margin for a symbol
Unable to access external links or documents.
futures_change_position_mode(**params)
Change position mode for authenticated account
The provided link is a URL and does not contain any translatable text. Please provide text for translation.
futures_coin_account(**params)
Get current account information.
Unable to access external content.
futures_coin_account_balance(**params)
Get futures account balance
Unable to access external links or documents.
futures_coin_account_trades(**params)
Get trades for the authenticated account and symbol.
Invalid input. Please provide the text you want to translate.
futures_coin_aggregate_trades(**params)
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price.
will have the quantity aggregated.
Unable to access external links.
futures_coin_cancel_all_open_orders(**params)
Cancel all open futures orders
Unable to access the provided URL.
futures_coin_cancel_order(**params)
Cancel an active futures order.
The provided link does not contain any translatable text.
**params
Cancel multiple futures orders
Unable to access the provided link.
futures_coin_change_leverage(**params)
Change user’s initial leverage of specific symbol market
Unable to process the URL. Please provide text for translation.
futures_coin_change_margin_type(**params)
Change the margin type for a symbol
https://binance-docs.github.io/apidocs/delivery/en/#change-margin-type-trade

112 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

futures_coin_change_position_margin(**params)
Change the position margin for a symbol
https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
futures_coin_change_position_mode(**params)
Change the user's position mode (Hedge Mode or One-way Mode) on EVERY symbol.
Unable to access the content of the URL.
futures_coin_continuous_klines(**params)
Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.
Unable to access external URLs for translation.
futures_coin_create_order(**params)
Send in a new order.
Unable to access the URL provided to extract the text for translation.
futures_coin_exchange_info()
Current exchange trading rules and symbol information
The provided link is not text to be translated.
futures_coin_funding_rate(**params)
Get funding rate history
Invalid input. Please provide text to be translated.
futures_coin_get_all_orders(**params)
Get all futures account orders; active, canceled, or filled.
Unable to access external links for translation.
futures_coin_get_open_orders(**params)
Get all open orders on a symbol.
Unable to access the content of the provided URL.
futures_coin_get_order(**params)
Check an order’s status.
The URL provided cannot be translated as it is not text.
futures_coin_get_position_mode(**params)
Get user’s position mode (Hedge Mode or One-way Mode) on EVERY symbol
Invalid input. Please provide the specific text you would like to translate.
futures_coin_historical_trades(**params)
Get older market historical trades.
Unable to access the content of the provided link.
(**params)
Get income history for authenticated account
Invalid input. Please provide the text you would like to have translated.
futures_coin_index_price_klines(**params)
Kline/candlestick bars for the index price of a pair.
Invalid request. Please provide text for translation.

6.1. Contents 113


python-binance Documentation, Release 0.2.0

futures_coin_klines(**params)
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Unable to access the content of the URL.
futures_coin_leverage_bracket(**params)
Notional and Leverage Brackets
Unable to access the URL provided.
**params**
Get all liquidation orders
Unable to access the content of the given URL.
futures_coin_mark_price(**params)
Get Mark Price and Funding Rate
Unable to translate content from a URL. Please provide the text directly.
futures_coin_mark_price_klines(**params)
Kline/candlestick bars for the index price of a pair.
The provided text is a URL and cannot be translated.
futures_coin_open_interest(**params)
Get present open interest of a specific symbol.
Unable to access or retrieve content from the provided URL.
futures_coin_open_interest_hist(**params)
Get open interest statistics of a specific symbol.
Unable to access the content of the provided URL.
futures_coin_order_book(**params)
Get the Order Book for the market
Invalid URL provided for translation.
futures_coin_orderbook_ticker(**params)
Best price/qty on the order book for a symbol or symbols.
Invalid input. Please provide a text for translation.
futures_coin_ping()
Test connectivity to the Rest API
Unable to access the specified URL.
futures_coin_place_batch_order(**params)
Send in new orders.
Unable to access the provided link.
To avoid modifying the existing signature generation and parameter order logic, the URL encoding is done
on the special query param, batchOrders, in the early stage.
futures_coin_position_information(**params)
Get position information
Unable to access external links. Please provide the text you would like translated.
futures_coin_position_margin_history(**params)
Get position margin change history
The provided text is a URL and does not contain translatable content.

114 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

futures_coin_recent_trades(**params)
Get recent trades (up to last 500).
Invalid input. Please provide text for translation.
futures_coin_stream_close(listenKey)
futures_coin_stream_get_listen_key()
futures_coin_stream_keepalive(listenKey)
futures_coin_symbol_ticker(**params)
Latest price for a symbol or symbols.
Unable to access external links.
futures_coin_ticker(**params)
24 hour rolling window price change statistics.
The provided text is a URL and cannot be translated.
futures_coin_time()
Test connectivity to the Rest API and get the current server time.
Invalid URL
futures_continous_klines(**params)
Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.
Unable to access external links for translation.
futures_create_order(**params)
Send in a new order.
The link provided is a URL to the Binance API documentation for new order trade and does not contain translatable text.
futures_exchange_info()
Current exchange trading rules and symbol information
Unable to access external websites.
futures_funding_rate(**params)
Get funding rate history
Unable to retrieve or translate content from external links.
(**params)
Get all futures account orders; active, canceled, or filled.
Unable to access external links. Please provide the text you'd like translated.
futures_get_multi_assets_mode()
Get user’s Multi-Assets mode (Multi-Assets Mode or Single-Asset Mode) on Every symbol
https://binance-docs.github.io/apidocs/futures/en/#get-current-multi-assets-mode-user_data
futures_get_open_orders(**params)
Get all open orders on a symbol.
Invalid input. Please provide a text to be translated.
futures_get_order(**params)
Check an order's status.
Unable to access the content from the provided link.

6.1. Contents 115


python-binance Documentation, Release 0.2.0

futures_get_position_mode(**params)
Get position mode for authenticated account
https://binance-docs.github.io/apidocs/futures/en/#get-current-position-mode-user_data
futures_global_longshort_ratio(**params)
Get the current global long to short ratio of a specific symbol.
The provided link does not contain translatable text.
futures_historical_klines(symbol, interval, start_str, end_str=None, limit=500)
Get historical futures klines from Binance
Parameters
Name of symbol pair e.g BNBBTC
Binance Kline interval
Start date string in UTC format or timestamp in milliseconds
optional - end date string in UTC format or timestamp in milliseconds
milliseconds (default will fetch everything up to now)
•limit(int) – Default 500; max 1000.
Returns a list of OHLCV values (Open time, Open, High, Low, Close, Volume, Close time, Quote)
asset volume
Ignore)
futures_historical_klines_generator(symbol, interval, start_str, end_str=None)
Get historical futures klines generator from Binance
Parameters
Name of symbol pair e.g BNBBTC
•interval(str) – Binance Kline interval
Start date string in UTC format or timestamp in milliseconds
•end_str(str|int) – optional - end date string in UTC format or timestamp in mil-
milliseconds (default will fetch everything up to now)
Returns generator of OHLCV values
futures_historical_trades(**params)
Get older market historical trades.
The provided text is a URL and cannot be translated.
futures_income_history(**params)
Get income history for authenticated account
The provided text is a URL and does not contain translatable content. Please provide a text that needs translation.
futures_klines(**params)
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Invalid input. Please provide text for translation.
futures_leverage_bracket(**params)
Notional and Leverage Brackets
Unable to access the content of the URL provided.

116 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

futures_liquidation_orders(**params)
Get all liquidation orders
The provided text is a URL and does not contain translatable content.
futures_mark_price(**params)
Get Mark Price and Funding Rate
The provided link points to the Binance API documentation and does not contain translatable text.
(**params)
Get present open interest of a specified symbol.
The provided text is a URL and does not contain translatable content.
(**params)
Get open interest statistics of a specific symbol.
Unable to access external links for translation.
futures_order_book(**params)
Get the Order Book for the market
Unable to access the provided URL for translation.
futures_orderbook_ticker(**params)
Best price/qty on the order book for a symbol or symbols.
Link provided is not text to be translated.
futures_ping()
Test connectivity to the Rest API
Please provide the text you would like to translate.
futures_place_batch_order(**params)
Send in new orders.
Unable to directly access or translate external links.
To avoid modifying the existing signature generation and parameter order logic, the url encoding is done
on the special query param, batchOrders, in the early stage.
(**params)
Get position information
https://binance-docs.github.io/apidocs/futures/en/#position-information-user_data
(**params)
Get position margin change history
The provided link does not contain translatable text.
futures_recent_trades(**params)
Get recent trades (up to last 500).
The provided text is a URL and does not contain translatable content.
futures_stream_close(listenKey)
futures_stream_get_listen_key()
futures_stream_keepalive(listenKey)
futures_symbol_ticker(**params)
Latest price for a symbol or symbols.

6.1. Contents 117


python-binance Documentation, Release 0.2.0

Unable to access the provided URL. Please provide text to translate.


(**params)
24 hour rolling window price change statistics.
The provided text is a URL and cannot be translated.
futures_time()
Test connectivity to the Rest API and get the current server time.
Invalid URL. No text to translate.
futures_top_longshort_account_ratio(**params)
Get present long to short ratio for top accounts of a specific symbol.
The provided text is a URL and does not contain any translatable content.
futures_top_longshort_position_ratio(**params)
Get the current long to short ratio for the top positions of a specific symbol.

The provided link appears to be a URL that directs to a document rather than text to translate. Please provide the text you would like translated.
get_account(**params)
Get current account information.
Unable to access external URLs.
int – the number of milliseconds the request is valid for
ReturnsAPI response

{
"makerCommission":15,
"takerCommission":15,
"buyerCommission":0,
"sellerCommission":0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"balances": [
{
BTC
4723846.89208129
0.00000000
},
{
LTC
4763368.68006011
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_account_api_permissions(**params)
Fetch API key permissions.
Unable to access the content at the provided URL.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

118 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{
"ipRestrict": false,
"createTime":1623840271000,
"enableWithdrawals": false, This option allows you to withdraw via
˓→ API. You must apply the IP Access Restriction filter.inorder to enable

˓→ withdrawals

"enableInternalTransfer": true, //This option authorizes this key to


˓→ transfer funds between your master accountandyour sub account instantly

"permitsUniversalTransfer": true, //Authorizes this key to be usedfora


˓→ dedicated universal transfer API to transfer multiple supported currencies.

˓→ Each business's own transfer API rights are not affected by this

˓→ authorization

"enableVanillaOptions": false, //Authorizes this key to Vanilla options


˓→ trading

"enableReading": true,
"enableFutures": false, //API Key created before your futures account
˓→ opened doesnotsupport futures API service

"enableMargin": false, This option can be adjusted after the Cross


˓→ Margin account transferiscompleted

"enableSpotAndMarginTrading": false,//Spotandmargin trading


"tradingAuthorityExpirationTime":1628985600000//Expiration timefor
˓→ spotandmargin trading permission

get_account_api_trading_status(**params)
Fetch account API trading status detail.
Unable to access the content from the provided URL.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
"data": { API trading status detail
"isLocked": false, //API trading functionislockedor not
"plannedRecoverTime":0,//If API trading functionislocked, this
˓→ isthe planned recovery time

"triggerCondition": {
"GCR":150,//Number of GTC orders
"IFER":150,//Number of FOK/IOC orders
"UFR":300 Number of orders
},
"indicators": { //The indicators updated every30seconds
The symbol
{
UFR
"c":20, Count of all orders
"v":0.05, //Current UFR value
"t":0.995 //Trigger UFR value
},
{
IFER
"c":20, Count of FOK/IOC orders
"v":0.99, Current IFER value
"t":0.99 Trigger IFER value
},
{
(continues on next page)

6.1. Contents 119


python-binance Documentation, Release 0.2.0

(continued from previous page)


GCR
"c":20, Count of GTC orders
"v":0.99, Current GCR value
"t":0.99 Trigger GCR value
}
],
"ETHUSDT": [
{
UFR
"c":20,
"v":0.05,
"t":0.995
},
{
IFER
"c":20,
"v":0.99,
"t":0.99
},
{
GCR
"c":20,
"v":0.99,
"t":0.99
}
]
},
"updateTime":1547630471725
}
}

get_account_snapshot(**params)
Get daily account snapshot of specific type.
Unable to access the content of the URL provided.
Parameters
•type(string) – required. Valid values are SPOT/MARGIN/FUTURES.
optional (int)
integer - optional
optional
recvWindow(int) – optional
ReturnsAPI response

{
"code":200,//200forsuccess; others are error codes
msg
"snapshotVos":[
{
"data":{
"balances":[
{
BTC
(continues on next page)

120 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.09905021
0.00000000
},
{
USDT
1.89109409
0.00000000
}
],
0.09942700
},
spot
"updateTime":1576281599000
}
]
}

OR
{
"code":200,//200forsuccess; others are error codes
msg
"snapshotVos":[
{
"data":{
2748.02909813
0.00274803
0.00000100
0.00274750
"userAssets":[
{
XRP
0.00000000
1.00000000
0.00000000
0.00000000
1.00000000
}
]
},
margin
"updateTime":1576281599000
}
]
}

OR
{
"code":200,//200forsuccess; others are error codes
msg
"snapshotVos":[
{
"data":{
"assets":[
{
USDT
(continues on next page)

6.1. Contents 121


python-binance Documentation, Release 0.2.0

(continued from previous page)


118.99782335
120.23811389
}
],
"position":[
{
7130.41000000
7257.66239673
0.01000000
BTCUSDT
1.24029054
}
]
},
futures
"updateTime":1576281599000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_account_status(**params)
Get account status detail.
The provided link does not contain translatable text.
Parameters recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
Normal
}

get_aggregate_trades
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price.
will have the quantity aggregated.
Unable to access external links. Please provide the text you want me to translate.
Parameters
required
fromId(str) – ID to get aggregate trades from INCLUSIVE.
Timestamp in ms to get aggregate trades from INCLUSIVE.
endTime(int) – Timestamp in ms to get aggregate trades until INCLUSIVE.
•limit(int) – Default 500; max 1000.
ReturnsAPI response

[
{
"a":26129, Aggregate tradeId
0.01633102Price
(continues on next page)

122 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


4.70443515Quantity
"f":27781, First tradeId
"l":27781, Last tradeId
"T":1498793709153,Timestamp
"m": true, Was the buyer the maker?
"M": true Was the trade the best price match?
}
]

RaisesBinanceRequestException, BinanceAPIException

get_all_coins_info(**params)
Get information of coins (available for deposit and withdraw) for user.
The provided input does not contain translatable text.
Parameters recvWindow(int) – optional
ReturnsAPI response
{
BTC
"depositAllEnable": true,
"withdrawAllEnable": true,
Bitcoin
0
0
0
0
0
0
0
"isLegalMoney": false,
"trading": true,
"networkList": [
{
BNB
BTC
0.00000001
"isDefault": false,
"depositEnable": true,
"withdrawEnable": true,
depositDesc
withdrawDesc
Both a MEMO and an Address are required to
˓→ successfully deposit your BEP2-BTCB tokens to Binance.

BEP2
"resetAddressStatus": false,
^(bnb1)[0-9a-z]{38}$",
^[0-9A-Za-z-_]{1,120}$
0.0000026
0.0000052
0
"minConfirm":1,
"unLockConfirm":0
},
{
(continues on next page)

6.1. Contents 123


python-binance Documentation, Release 0.2.0

(continued from previous page)


BTC
BTC
0.00000001
"isDefault": true,
"depositEnable": true,
"withdrawEnable": true,
depositDesc
withdrawDesc
specialTips
BTC
"resetAddressStatus": false,
^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-
˓→ z]{39,59}$
memoRegex
0.0005
0.001
0
"minConfirm":1,
"unLockConfirm":2
}
]
}

Raises BinanceRequestException, BinanceAPIException

get_all_isolated_margin_symbols(**params)
Query isolated margin symbol info for all pairs
Unable to access the link provided.

client.get_all_isolated_margin_symbols()

ReturnsAPI response

[
{
BNB
"isBuyAllowed": true,
"isMarginTrade": true,
"isSellAllowed": true,
BTC
BNBBTC
},
{
TRX
"isBuyAllowed": true,
"isMarginTrade": true,
"isSellAllowed": true,
BTC
TRXBTC
}
]

RaisesBinanceRequestException, BinanceAPIException

124 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

get_all_margin_orders(**params)
Query all margin accounts orders
If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
For some historical orders, cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
Invalid URL
Parameters
required
set to 'TRUE' for isolated margin (default 'FALSE')
optional
optional
•endTime(str) – optional
•limit(int) – Default 500; max 1000
recvWindow(int) - the number of milliseconds the request is valid for
Returns
API response
[
{“id”: 43123876, “price”: “0.00395740”, “qty”: “4.06000000”, “quoteQty”:
0.01606704
}, {
”id”: 43123877, “price”: “0.00395740”, “qty”: “0.77000000”, “quoteQty”:
0.00304719
}, {
”id”: 43253549, “price”: “0.00428930”, “qty”: “23.30000000”, “quoteQty”:
0.09994069
}
]
Raises BinanceRequestException, BinanceAPIException
get_all_orders(**params)
Get all account orders; active, canceled, or filled.
Unable to access external links.
Parameters
required
The unique order id
•startTime(int) – optional
optional (int)
•limit(int) – Default 500; max 1000.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

6.1. Contents 125


python-binance Documentation, Release 0.2.0

[
{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
0.0
NEW
GTC
LIMIT
BUY
0.0
0.0
1499827319559
}
]

RaisesBinanceRequestException, BinanceAPIException

List[Dict[str, str]]
Latest price for all symbols.
Unable to access the provided URL.
Returns List of market tickers

[
{
LTCBTC
4.00000200
},
{
ETHBTC
0.07946600
}
]

RaisesBinanceRequestException, BinanceAPIException

get_asset_balance(asset, **params)
Get current asset balance.
Parameters
required
recvWindow(int) – the number of milliseconds the request is valid for
Returns dictionary or None if not found

{
BTC
4723846.89208129
0.00000000
}

RaisesBinanceRequestException, BinanceAPIException

126 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

get_asset_details(**params)
Fetch details on assets.
Invalid input, please provide the text that needs to be translated.
Parameters
optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
{
"CTR": {
70.00000000
"depositStatus": false,//deposit status (falseifALL of networks
˓→ are false)

"withdrawFee":35,//withdraw fee
"withdrawStatus": true,//withdraw status (falseif ALL of
˓→ networks' are false)

Delisted, Deposit Suspended


},
"SKY": {
0.02000000
"depositStatus": true,
"withdrawFee":0.01,
"withdrawStatus": true
}
}

get_asset_dividend_history(**params)
Query asset dividend record.
The provided text is a URL and not translatable content.
Parameters
•asset(str) – optional
long - optional
long – optional
recvWindow(int) – the number of milliseconds the request is valid for
client.get_asset_dividend_history()

ReturnsAPI response

{
"rows":[
{
10.00000000
BHFT
"divTime":1563189166000,
BHFT distribution
"tranId":2968885920
},
{
10.00000000
(continues on next page)

6.1. Contents 127


python-binance Documentation, Release 0.2.0

(continued from previous page)


BHFT
"divTime":1563189165000,
BHFT distribution
"tranId":2968885920
}
],
"total":2
}

RaisesBinanceRequestException, BinanceAPIException

get_avg_price(**params)
Current average price for a symbol.
Unable to access external links.
Parameterssymbol(str) –
ReturnsAPI response

{
"mins":5,
9.35751834
}

get_bnb_burn_spot_margin(**params)
Get BNB Burn Status
Invalid request. No text provided for translation.

client.get_bnb_burn_spot_margin()

ReturnsAPI response

{
"spotBNBBurn":true,
"interestBNBBurn": false
}

RaisesBinanceRequestException, BinanceAPIException

get_c2c_trade_history(**params)
Get C2C Trade History
The provided link is not text that can be translated.
Parameters
required - BUY, SELL
optional
optional (int)
optional - default 1
•rows(int) – optional - default 100, max 100
recvWindow(int) - optional

128 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Returns
API response
000000
20219644646554779648 advNo
11218246497340923904
CNY
33400.00000000
COMPLETED
DISTRIBUTING
createTime commission
0
TAKER
}
], “total”: 1, “success”: true
}
get_cross_margin_data(**params)
Query Cross Margin Fee Data (USER_DATA)
Invalid URL or text format. Please provide text for translation.vipLevel
User’s current specific margin data will be returned if vipLevel is omitted :type vipLevel: int :param coin
str
API response (example):
[
{“vipLevel”: 0, “coin”: “BTC”, “transferIn”: true, “borrowable”: true, “dailyInter-
0.00026125
Pairs”: [
BNBBTC
]
}
]
get_deposit_address(coin: str, network: Optional[str] = None, **params)
Fetch a deposit address for a symbol
The link you provided is a documentation page from Binance's API, and I am unable to access external links or content from them. Please provide specific text that you would like me to translate.
Parameters
required
optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv
BTC
tag
https://btc.com/1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv
}

6.1. Contents 129


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException, BinanceAPIException

get_deposit_history(**params)
Fetch deposit history.
Invalid input. Please provide text for translation.
Parameters
optional
long - optional
endTime(long) – optional
•offset(long) – optional - default:0
•limit(long) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
0.00999800
PAXG
ETH
"status":1,
0x788cabe9236ce061e5a892e1a59395a81fc8d62c
addressTag
txId
˓→ 0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3

"insertTime":1599621997000,
"transferType":0,
12/12
},
{
0.50000000
IOTA
IOTA
"status":1,
address
˓→ SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLN

˓→ ",

addressTag
txId
˓→ ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999

˓→ ",

"insertTime":1599620082000,
"transferType":0,
1/1
}
]

RaisesBinanceRequestException, BinanceAPIException

get_dust_assets(**params)
Get assets that can be converted into BNB
Unable to access the content of the provided link.

130 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

ReturnsAPI response

{
"details": [
{
ADA
ADA
6.21 Convertible amount
0.00016848
0.01777302
0.01741756
˓→ commission fee

0.00035546
}
],
0.00016848
0.01777302
0.02 Commission fee
}

get_dust_log(**params)
Get log of small amounts exchanged for BNB.
Unable to access the provided URL.
Parameters
optional
endTime(int) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
"total":8, Total counts of exchange
"userAssetDribblets": [
{
0.00132256 Total transferred BNB
˓→ amountforthis exchange.

0.00002699 Total service


˓→ charge amountforthis exchange.

"transId":45178372831,
"userAssetDribbletDetails": [ Details of this
˓→ exchange.

{
"transId":4359321,
0.000009
0.0009
"operateTime":1615985535000,
0.000441
USDT
},
{
"transId":4359321,
0.00001799
0.0009
2018-05-03 17:07:04
0.00088156
(continues on next page)

6.1. Contents 131


python-binance Documentation, Release 0.2.0

(continued from previous page)


ETH
}
]
},
{
"operateTime":1616203180000,
0.00058795
0.000012
"transId":4357015,
"userAssetDribbletDetails": [
{
"transId":4357015,
0.00001
0.001
"operateTime":1616203180000,
0.00049
USDT
},
{
"transId":4357015,
0.000002
0.0001
"operateTime":1616203180000,
0.00009795
ETH
}
]
}
]
}

Dict[KT, VT]
Return rate limits and list of symbols
List of product dictionaries
{
UTC
"serverTime":1508631584636,
"rateLimits": [
{
REQUESTS
MINUTE
"limit":1200
},
{
ORDERS
SECOND
"limit":10
},
{
ORDERS
DAY
"limit":100000
}
],
"exchangeFilters": [],
(continues on next page)

132 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


"symbols": [
{
ETHBTC
TRADING
ETH
"baseAssetPrecision":8,
BTC
"quotePrecision":8,
"orderTypes": ["LIMIT","MARKET"],
"icebergAllowed": false,
"filters": [
{
PRICE_FILTER
0.00000100
100000.00000000
0.00000100
}, {
LOT_SIZE
0.00100000
100000.00000000
0.00100000
}, {
MIN_NOTIONAL
0.00100000
}
]
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_fiat_deposit_withdraw_history(**params)
Get Fiat Deposit/Withdraw History
The provided text is a URL and does not contain translatable content.
Parameters
required - 0-deposit, 1-withdraw
optional (int)
(int) - optional
•page(int) – optional - default 1
•rows(int) – optional - default 100, max 500
recvWindow(int) – optional
get_fiat_payments_history(**params)
Get Fiat Payments History
Unable to access external links.
Parameters
string - required - 0-buy, 1-sell
optional

6.1. Contents 133


python-binance Documentation, Release 0.2.0

optional (int)
optional - default 1
•rows(int) – optional - default 100, max 500
•recvWindow(int) – optional
get_fixed_activity_project_list(**params)
Get Fixed and Activity Project List
Unable to access external links.
Parameters
optional
•type(str) – required - “ACTIVITY”, “CUSTOMIZED_FIXED”
optional - "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE";
default "ALL"
•sortBy(str) – optional - “START_TIME”, “LOT_SIZE”, “INTEREST_RATE”,
default START_TIME
current(int) – optional - Currently querying page. Start from 1. Default: 1
•size(int) – optional - Default:10, Max:100
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
USDT
"displayPriority":1,
"duration":90,
1.35810000
0.05510000
100.00000000
"lotsLowLimit":1,
"lotsPurchased":74155,
"lotsUpLimit":80000,
"maxLotsPerUser":2000,
needKycFalse,
CUSDT90DAYSS001
USDT
PURCHASING
CUSTOMIZED_FIXED
with Area LimitationFalse
}
]

RaisesBinanceRequestException, BinanceAPIException

get_historical_klines(symbol, interval, start_str=None, end_str=None, limit=1000,


binance.enums.HistoricalKlinesType = <HistoricalK-
1>)
Get Historical Klines from Binance
Parameters

134 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Name of symbol pair e.g BNBBTC


Binance Kline interval
optional - start date string in UTC format or timestamp
in milliseconds
•end_str(str|int) – optional - end date string in UTC format or timestamp in
milliseconds (default will fetch everything up to now)
•limit(int) – Default 1000; max 1000.
Historical klines type: SPOT or
FUTURES
Returns list of OHLCV values (Open time, Open, High, Low, Close, Volume, Close time)
Quote asset volume, Number of trades, Taker buy base asset volume, Taker buy quote
asset volume, Ignore)
get_historical_klines_generator(symbol, interval start_str=None,
end_str=None limit=1000, klines_type bi-
nance.enums.HistoricalKlinesType = <HistoricalK-
linesType.SPOT: 1>)
Get Historical Klines generator from Binance
Parameters
Name of symbol pair e.g BNBBTC
•interval(str) – Binance Kline interval
optional - Start date string in UTC format or timestamp
in milliseconds
end_str(str|int) – optional - end date string in UTC format or timestamp in
milliseconds (default will fetch everything up to now)
amount of candles to return per request (default 1000)
Historical klines type: SPOT or
FUTURES
Returns generator of OHLCV values
get_historical_trades(**params)→Dict[KT, VT]
Get older trades.
Unable to access the content of the provided link.
Parameters
required
•limit(int) – Default 500; max 1000.
•fromId(str) – TradeId to fetch from. Default gets most recent trades.
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
"time":1499865549590,
(continues on next page)

6.1. Contents 135


python-binance Documentation, Release 0.2.0

(continued from previous page)


"isBuyerMaker": true,
"isBestMatch": true
}
]

RaisesBinanceRequestException, BinanceAPIException

get_isolated_margin_account(**params)
Query isolated margin account details
Invalid URL. Please provide text for translation.
Parameters symbols – optional up to 5 margin pairs as a comma separated string

client.get_isolated_margin_account()
client.get_isolated_margin_account(symbols="BTCUSDT,ETHUSDT")

ReturnsAPI response

If "symbols"is not

{
[
{
baseAsset
{
BTC
"borrowEnabled": true,
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
"repayEnabled": true,
0.00000000
},
quoteAsset
{
USDT
"borrowEnabled": true,
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
"repayEnabled": true,
0.00000000
},
BTCUSDT
"isolatedCreated": true,
0.00000000
EXCESSIVE
˓→ MARGIN CALL

(continues on next page)

136 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.00000000
10000.00000000
1000.00000000
1.00000000
"tradeEnabled": true
}
],
0.00000000
0.00000000
0.00000000
}

If 'symbols'is

{
"assets":[
{
baseAsset
{
BTC
"borrowEnabled": true,
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
"repayEnabled": true,
0.00000000
},
quoteAsset
{
USDT
"borrowEnabled": true,
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
"repayEnabled": true,
0.00000000
},
BTCUSDT
"isolatedCreated": true,
0.00000000
EXCESSIVE
˓→ MARGIN CALL

0.00000000
10000.00000000
1000.00000000
1.00000000
"tradeEnabled": true
}
]
}

6.1. Contents 137


python-binance Documentation, Release 0.2.0

get_isolated_margin_symbol(**params)
Query isolated margin symbol info
Invalid request. The provided URL is not translatable text.
name of the symbol pair

client.get_isolated_margin_symbol(symbol='BTCUSDT')

ReturnsAPI response

{
BTCUSDT
BTC
USDT
"isMarginTrade":true,
"isBuyAllowed":true,
"isSellAllowed":true
}

Raises BinanceRequestException, BinanceAPIException

get_isolated_margin_transfer_history(**params)
Get transfers to isolated margin account.
The requested URL could not be translated as it is a link to documentation. Please provide the text you'd like translated.
Parameters
name of the asset
pair required
transFrom– optional SPOT, ISOLATED_MARGIN
•transFrom– str SPOT, ISOLATED_MARGIN
transTo– optional
transTo– str
optional (int)
optional (int)
Currently querying page. Start from 1. Default:1
•size(int) – Default:10 Max:100
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_spot_to_isolated_margin(symbol='ETHBTC')

ReturnsAPI response

{
"rows": [
{
0.10000000
BNB
(continues on next page)

138 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


CONFIRMED
"timestamp":1566898617000,
"txId":5240372201,
SPOT
ISOLATED_MARGIN
},
{
5.00000000
USDT
CONFIRMED
"timestamp":1566888436123,
"txId":5239810406,
ISOLATED_MARGIN
SPOT
}
],
"total":2
}

RaisesBinanceRequestException, BinanceAPIException

get_klines(**params)→Dict[KT, VT]
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Unable to access the provided URL.
Parameters
(str) - required
•interval(str) –

int
–Default 500; max 1000.
int
int
ReturnsAPI response

[
[
1499040000000 Open time
0.01634790 Open
0.80000000 High
0.01575800 Low
0.01577100 Close
148976.11427815Volume
1499644799999 Close time
2434.19055334 Quote asset volume
308 Number of trades
1756.87402397 Taker buy base asset volume
28.46694368 Taker buy quote asset volume
17928899.62484339Can be ignored
]
]

6.1. Contents 139


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException, BinanceAPIException

get_lending_account(**params)
Get Lending Account Details
Invalid URL. Please provide the text you would like to be translated.
get_lending_daily_quota_left(**params)
Get Left Daily Purchase Quota of Flexible Product.
Get the left daily purchase quota of a flexible product.
data
get_lending_daily_redemption_quota(**params)
Get Left Daily Redemption Quota of Flexible Product
The provided link does not contain translatable text.
data
get_lending_interest_history(**params)
Get Lending Interest History
The provided link does not contain translatable text.
get_lending_position(**params)
Get Flexible Product Position
Unable to access the provided link. Please provide the text you would like translated.
get_lending_product_list(**params)
Get Lending Product List
The link provided does not contain text to translate. Please provide the text you would like to have translated.
get_lending_purchase_history(**params)
Get Lending Purchase History
Unable to access the content of the link provided.
get_lending_redemption_history(**params)
Get Lending Redemption History
Unable to fetch content from the provided link.
get_margin_account(**params)
Query cross-margin account details
Unable to access external links.
ReturnsAPI response

{
"borrowEnabled": true,
11.64405625
6.82728457
0.58633215
6.24095242
"tradeEnabled": true,
"transferEnabled": true,
"userAssets": [
{
BTC
0.00000000
(continues on next page)

140 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.00499500
0.00000000
0.00000000
0.00499500
},
{
BNB
201.66666672
2346.50000000
0.00000000
0.00000000
2144.83333328
},
{
ETH
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
},
{
USDT
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_margin_all_assets(**params)
Get All Margin Assets (MARKET_DATA)
This is a URL link and cannot be translated.

client.get_margin_all_assets()

ReturnsAPI response

[
{
USD Coin
USDC
"isBorrowable": true,
"isMortgageable": true,
0.00000000
0.00000000
},
{
BNB-coin
BNB
(continues on next page)

6.1. Contents 141


python-binance Documentation, Release 0.2.0

(continued from previous page)


"isBorrowable": true,
"isMortgageable": true,
1.00000000
0.00000000
}
]

Raises BinanceRequestException, BinanceAPIException

get_margin_all_pairs(**params)
Get All Cross Margin Pairs (MARKET_DATA)
The provided input is a URL and does not contain translatable text.

client.get_margin_all_pairs()

ReturnsAPI response

[
{
BNB
"id":351637150141315861,
"isBuyAllowed": true,
"isMarginTrade": true,
"isSellAllowed": true,
BTC
BNBBTC
},
{
TRX
"id":351637923235429141,
"isBuyAllowed": true,
"isMarginTrade": true,
"isSellAllowed": true,
BTC
TRXBTC
}
]

RaisesBinanceRequestException, BinanceAPIException

get_margin_asset(**params)
Query cross-margin asset
URL provided is not translatable text.
Parametersasset(str) – name of the asset

client.get_margin_asset(asset='BNB')

ReturnsAPI response

142 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{
Binance Coin
BNB
"isBorrowable": false,
"isMortgageable": true,
0.00000000
0.00000000
}

RaisesBinanceRequestException, BinanceAPIException

get_margin_force_liquidation_rec(**params)
Get Force Liquidation Record (USER_DATA)
Invalid request. No translatable text found.
Parameters
(str)
endTime(str)
isolated symbol (if querying isolated margin)
Currently querying page. Start from 1. Default: 1
•size(int) – Default:10 Max:100
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
{
“rows”: [
0.00388359
180015097
BNBBTC
1558941374745
}
], “total”: 1
}
get_margin_interest_history(**params)
Get Interest History (USER_DATA)
Unable to access the provided link.
Parameters
str
isolated symbol (if querying isolated margin)
str
endTime(str)
Currently querying page. Start from 1. Default: 1

6.1. Contents 143


python-binance Documentation, Release 0.2.0

•size(int) – Default:10 Max:100


•archived(bool) – Default: false. Set to true for archived data from 6 months ago
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
{
“rows”:[
BNBUSDT
BNB
curedTime”: 1566813600000, “interestRate”: “0.01600000”, “principal”:
36.22000000
}
], “total”: 1
}
get_margin_loan_details(**params)
Query loan record
txId or startTime must be sent. txId takes precedence.
Unable to access external content.
Parameters
required
•isolatedSymbol(str) – isolated symbol (if querying isolated margin)
the tranId in of the created loan
earliest timestamp to filter transactions
endTime(str) – Used to uniquely identify this cancel. Automatically generated by
default.
Currently querying page. Start from 1. Default: 1
•size(int) – Default:10 Max:100
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
{
“rows”: [
BNB
//one of PENDING (pending to execution), CONFIRMED (successfully loaned),
FAILED (execution failed, nothing happened to your account); “status”: “CON-
FIRMED
}
], “total”: 1
}

144 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException, BinanceAPIException
get_margin_oco_order(**params)
Retrieves a specific OCO based on provided optional parameters
Unable to access external URLs.
Parameters
•isIsolated– for isolated margin or not, “TRUE”, “FALSE”default “FALSE”
•symbol(str) – mandatory for isolated margin, not supported for cross margin
•orderListId(int) – Either orderListId or listClientOrderId must be provided
•listClientOrderId(str) – Either orderListId or listClientOrderId must be
provided
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
orderListId 27 contingencyType OCO listStatusType
EXEC_STARTED EXECUTING
h2USkA5YQpaXHPIrkd96xE
LTCBTC
symbol LTCBTC orderId 4 clientOrderId
qD1gy3kc3Gx0rihm9Y3xwS
}, {
symbol LTCBTC orderId 5 clientOrderId
ARzZ9I00CPM8i3NhmU9Ega
}
]
}
get_margin_order(**params)
Query margin accounts order
Either orderId or origClientOrderId must be sent.
For some historical orders, cumulativeQuoteQty will be < 0, meaning the data is not available at this time.
time.
The provided link does not contain any translatable text.
Parameters
required
isIsolated(str) – set to 'TRUE' for isolated margin (default 'FALSE')
str
string
recvWindow(int) - the number of milliseconds the request is valid for
Returns
API response

6.1. Contents 145


python-binance Documentation, Release 0.2.0

clientOrderId ZwfQzuDIGpceVhKW5DvCmO, cummulativeQuoteQty:


0.00000000 0.00000000 0.00000000
“isWorking”: true, “orderId”: 213205622, “origQty”: “0.30000000”, “price”:
0.00493630
BNBBTC
LIMIT
}
Raises Binance Request Exception, Binance API Exception
get_margin_price_index
Query margin priceIndex
The provided link does not contain translatable text.
Parameterssymbol(str) – name of the symbol pair

client.get_margin_price_index(symbol='BTCUSDT')

{
"calcTime":1562046418000,
0.00333930
BNBBTC
}

RaisesBinanceRequestException, BinanceAPIException

get_margin_repay_details(**params)
Query repay record
txId or startTime must be sent. txId takes precedence.
Unable to access external URLs.
Parameters
required
isolated symbol (if querying isolated margin)
the tranId of the created loan
string
•endTime(str) – Used to uniquely identify this cancel. Automatically generated by
default.
Currently querying page. Start from 1. Default: 1
•size(int) – Default:10 Max:100
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
{
“rows”: [

146 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

14.00000000
0.01866667
//one of PENDING (pending to execution), CONFIRMED (successfully loaned),
CON-
FIRMED
}
], “total”: 1
}
RaisesBinanceRequestException, BinanceAPIException
get_margin_symbol(**params)
Query cross-margin symbol info
Unable to access the specified URL.
Parameterssymbol(str) – name of the symbol pair

client.get_margin_symbol(symbol='BTCUSDT')

ReturnsAPI response

{
"id":323355778339572400,
BTCUSDT
BTC
USDT
"isMarginTrade":true,
"isBuyAllowed":true,
"isSellAllowed":true
}

RaisesBinanceRequestException, BinanceAPIException

get_margin_trades(**params)
Query margin accounts trades
If fromId is set, it will get orders ≥ that fromId. Otherwise, the most recent orders are returned.
Unable to access the content of the provided URL.
Parameters
required
set to 'TRUE' for isolated margin (default 'FALSE')
optional
optional
optional
•limit(int) – Default 500; max 1000
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response

6.1. Contents 147


python-binance Documentation, Release 0.2.0

[
0.00006000
BestMatch”: true, “isBuyer”: false, “isMaker”: false, “orderId”: 39324,
0.02000000
1561973357171
0.00002950
BestMatch”: true, “isBuyer”: false, “isMaker”: true, “orderId”: 39319,
0.00590000
1561964645345
}
]
Raises BinanceRequestException, BinanceAPIException
get_max_margin_loan(**params)
Query maximum borrow amount for an asset
Unable to access or retrieve the specified URL for translation.
Parameters
required
isolated symbol (if querying isolated margin)
recvWindow(int) - the number of milliseconds the request is valid for
Returns
API response
1.69248805
}
RaisesBinanceRequestException, BinanceAPIException
get_max_margin_transfer(**params)
Query max transfer-out amount
Unable to access the provided link.
Parameters
required
isolated symbol (if querying isolated margin)
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
3.59498107
}
RaisesBinanceRequestException, BinanceAPIException
get_my_trades(**params)
Get trades for a specific symbol.
Invalid URL or content. Please provide a text for translation.

148 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Parameters
required
optional
optional
•limit(int) – Default 500; max 1000.
•fromId(int) – TradeId to fetch from. Default gets most recent trades.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
10.10000000
BNB
"time":1499865549590,
"isBuyer": true,
"isMaker": false,
"isBestMatch": true
}
]

RaisesBinanceRequestException, BinanceAPIException

get_open_margin_oco_orders(**params)
Retrieves open OCO trades
Unable to access the specified URL to retrieve content for translation.
Parameters
•isIsolated– for isolated margin or not, “TRUE”, “FALSE”default “FALSE”
•symbol(str) – mandatory for isolated margin, not supported for cross margin
•fromId(int) – If supplied, neither startTime nor endTime can be provided
optional
optional
•limit(int) – optional DefaultValue: 500; MaxValue: 1000
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
[
orderListId 29, contingencyType OCO listStatusType
EXEC_STARTED
amEEAXryFzFwYF1FeRpUoZ
LTCBTC

6.1. Contents 149


python-binance Documentation, Release 0.2.0

symbol LTCBTC orderId clientOrderId


oD7aesZqjEGlZrbtRpy5zB
}, {
symbol LTCBTC orderId 5 clientOrderId
Jr1h6xirOxgeJOUuYQS7V3
}
]
}, {
orderListId 28, “contingencyType”: OCO
EXEC_STARTED listOrderStatus EXECUTING, list-
ClientOrderId hG7hFNxJV6cZy3Ze4AUT4d
1565245913407, “symbol”: “LTCBTC”, “orders”: [
LTCBTC orderId clientOrderId
j6lFOfbmFMRjTYA7rRJ0LP
}, {
symbol LTCBTC clientOrderId
z0KCjOdditiLS5ekAFtK81
}
]
}
]
get_open_margin_orders(**params)
Query margin accounts open orders
If the symbol is not sent, orders for all symbols will be returned in an array (cross-margin only).
If querying isolated margin orders, both the isIsolated='TRUE' and symbol=symbol_name must be set.
When all symbols are returned, the number of requests counted against the rate limiter is equal to the
number of symbols currently trading on the exchange.
Unable to access the content from the provided URL.
Parameters
optional
set to 'TRUE' for isolated margin (default 'FALSE')
recvWindow(int) – the number of milliseconds the request is valid for
Returns
API response
[
qhcZw71gAkCCTv0t0k8LUK
0.00000000
“isWorking”: true, “orderId”: 211842552, “origQty”: “0.30000000”,
0.00475010
0.00000000
GTC

150 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

}
]
Raises BinanceRequestException, BinanceAPIException
get_open_orders(**params)
Get all open orders on a symbol.
Unable to access external links.
Parameters
optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
0.0
NEW
GTC
LIMIT
BUY
0.0
0.0
"time":1499827319559
}
]

RaisesBinanceRequestException, BinanceAPIException

get_order(**params)
Check an order’s status. Either orderId or origClientOrderId must be sent.
Unable to access the provided URL.
Parameters
required
The unique order id
optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
LTCBTC
"orderId":1,
myOrder1
0.1
1.0
(continues on next page)

6.1. Contents 151


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.0
NEW
GTC
LIMIT
BUY
0.0
0.0
"time":1499827319559
}

RaisesBinanceRequestException, BinanceAPIException

get_order_book(**params)→Dict[KT, VT]
Get the Order Book for the market
Invalid input. Please provide text to translate.
Parameters
required
•limit(int) – Default 100; max 1000
ReturnsAPI response
{
"lastUpdateId":1027024,
"bids": [
[
4.00000000 PRICE
431.00000000 # QTY
[] Can be ignored
]
],
"asks": [
[
4.00000200
12.00000000
[]
]
]
}

RaisesBinanceRequestException, BinanceAPIException

get_orderbook_ticker(**params)
Latest price for a symbol or symbols.
The request URL you provided is not translatable text.
Parameters symbol (str) -
ReturnsAPI response
{
LTCBTC
4.00000000
431.00000000
(continues on next page)

152 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


4.00000200
9.00000000
}

OR

[
{
LTCBTC
4.00000000
431.00000000
4.00000200
9.00000000
},
{
ETHBTC
0.07946700
9.00000000
100000.00000000
1000.00000000
}
]

Raises BinanceRequestException, BinanceAPIException

get_orderbook_tickers()→Dict[KT, VT]
Best price/qty on the order book for all symbols.
Invalid input. Please provide text for translation.
Parameters symbol (str) – optional
Returns List of order book market entries

[
{
LTCBTC
4.00000000
431.00000000
4.00000200
9.00000000
},
{
ETHBTC
0.07946700
9.00000000
100000.00000000
1000.00000000
}
]

RaisesBinanceRequestException, BinanceAPIException

Dict[KT, VT]
Return list of products currently listed on Binance
Use get_exchange_info() call instead

6.1. Contents 153


python-binance Documentation, Release 0.2.0

List of product dictionaries


RaisesBinanceRequestException, BinanceAPIException
get_recent_trades(**params)→Dict[KT, VT]
Get recent trades (up to last 500).
Invalid input. Please provide the text you want translated.
Parameters
required
•limit(int) – Default 500; max 1000.
ReturnsAPI response

[
{
"id":28457,
4.00000100
12.00000000
"time":1499865549590,
"isBuyerMaker": true,
"isBestMatch": true
}
]

Raises BinanceRequestException, BinanceAPIException

Dict[KT, VT]
Test connectivity to the Rest API and get the current server time.
Unable to access the provided URL.
Returns Current server time

{
"serverTime":1499827319559
}

RaisesBinanceRequestException, BinanceAPIException

get_sub_account_assets(**params)
Fetch sub-account assets
Unable to access the content of the provided URL for translation.
Parameters
required
recvWindow(int) – optional
ReturnsAPI response

{
"balances":[
{
ADA
"free":10000,
(continues on next page)

154 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


"locked":0
},
{
BNB
"free":10003,
"locked":0
},
{
BTC
"free":11467.6399,
"locked":0
},
{
ETH
"free":10004.995,
"locked":0
},
{
USDT
"free":11652.14213,
"locked":0
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_sub_account_futures_transfer_history(**params)
Query Sub-account Futures Transfer History.
Unable to access the provided link.
Parameters
required
int - required
optional
optional
(int) - optional
•limit(int) – optional
•recvWindow(int) – optional
ReturnsAPI response

{
"success":true,
"futuresType":2,
"transfers":[
{
[email protected]
[email protected]
BTC
1
(continues on next page)

6.1. Contents 155


python-binance Documentation, Release 0.2.0

(continued from previous page)


"time":1544433328000
},
{
[email protected]
[email protected]
ETH
2
"time":1544433328000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_sub_account_list(**params)
Query Sub-account List.
Unable to access the content of the provided URL.
Parameters
•email(str) – optional - Sub-account email
str – optional
•page(int) – optional - Default value: 1
•limit(int) – optional - Default value: 1, Max value: 200
•recvWindow(int) – optional
ReturnsAPI response

{
"subAccounts":[
{
[email protected]
"isFreeze":false,
"createTime":1544433328000
},
{
[email protected]
"isFreeze":false,
"createTime":1544433328000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_sub_account_transfer_history(**params)
Query Sub-account Transfer History.
Unable to access the content of the provided link.
Parameters
optional
optional

156 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

startTime(int) – optional
(int) – optional
•page(int) – optional - Default value: 1
optional - Default value: 500
recvWindow(int) – optional
ReturnsAPI response

[
{
[email protected]
[email protected]
BTC
10
SUCCESS
"tranId":6489943656,
"time":1544433328000
},
{
[email protected]
[email protected]
ETH
2
SUCCESS
"tranId":6489938713,
"time":1544433328000
}
]

RaisesBinanceRequestException, BinanceAPIException

**params
Get Sub-account Deposit Address (For Master Account)
Invalid input. Please provide the text you want to be translated.
Parameters
required - Sub account email
required
(str) - optional
(int) - optional
ReturnsAPI response

{
TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV
USDT
tag
https://tronscan.org/#/address/TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV
˓→ "
}

Raises BinanceRequestException, BinanceAPIException

6.1. Contents 157


python-binance Documentation, Release 0.2.0

get_subaccount_deposit_history(**params)
Get Sub-account Deposit History (For Master Account)
Invalid link provided.
Parameters
required - Sub account email
optional
•status(int) – optional - (0:pending,6: credited but cannot withdraw, 1:success)
optional
optional
•limit(int) – optional
•offset(int) – optional - default:0
recvWindow(int) – optional
ReturnsAPI response

[
{
0.00999800
PAXG
ETH
"status":1,
0x788cabe9236ce061e5a892e1a59395a81fc8d62c
addressTag
txId
˓→ 0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3

"insertTime":1599621997000,
"transferType":0,
12/12
},
{
0.50000000
IOTA
IOTA
"status":1,
address
˓→ SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLN

˓→ ",

addressTag
txId
˓→ ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999

˓→ ",

"insertTime":1599620082000,
"transferType":0,
1/1
}
]

Raises BinanceRequestException, BinanceAPIException

get_subaccount_futures_details(**params)
Get Detail on Sub-account’s Futures Account (For Master Account)

158 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Unable to retrieve content from the provided URL.


Parameters
required - Sub account email
recvWindow(int) – optional
ReturnsAPI response

{
[email protected]
USDT
"assets":[
{
USDT
0.00000000
0.00000000
0.88308000
0.88308000
0.00000000
0.00000000
0.00000000
0.88308000
}
],
"canDeposit": true,
"canTrade": true,
"canWithdraw": true,
"feeTier":2,
0.88308000
0.00000000
0.00000000
0.88308000
0.00000000
0.00000000
0.00000000
0.88308000
"updateTime":1576756674610
}

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_futures_margin_status(**params)
Get Sub-account’s Status on Margin/Futures (For Master Account)
Invalid request. Please provide text for translation.
Parameters
optional - Sub account email
recvWindow(int) – optional
ReturnsAPI response

[
{
[email protected] //user email
"isSubUserEnabled": true, trueorfalse
(continues on next page)

6.1. Contents 159


python-binance Documentation, Release 0.2.0

(continued from previous page)


"isUserActive": true, //trueorfalse
"insertTime":1570791523523//sub account create time
"isMarginEnabled": true, trueorfalseformargin
"isFutureEnabled": true trueorfalseforfutures.
"mobile":1570791523523 //user mobile number
}
]

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_futures_positionrisk(**params)
Get Futures Position-Risk of Sub-account (For Master Account)
The provided input is a URL and does not contain any translatable text.
Parameters
required - Sub account email
recvWindow(int) – optional
ReturnsAPI response
[
{
9975.12000
50 current initial leverage
1000000 notional value limit of current
˓→ initial leverage

7963.54
9973.50770517
0.010
BTCUSDT
-0.01612295
}
]

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_futures_summary(**params)
Get Summary of Sub-account’s Futures Account (For Master Account)
The provided text is a URL and does not contain any translatable content.
(int) - optional
ReturnsAPI response
{
9.83137400
0.41568700
23.03235621
9.00000000
0.83137400
0.03219710
22.15879444
USDT
"subAccountList":[
(continues on next page)

160 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


{
[email protected]
9.00000000
0.00000000
22.12659734
9.00000000
0.00000000
0.00000000
22.12659734
USDT
},
{
[email protected]
0.83137400
0.41568700
0.90575887
0.00000000
0.83137400
0.03219710
0.87356177
USDT
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_margin_details(**params)
Get Detail on Sub-account’s Margin Account (For Master Account)
Invalid input, please provide the text you want to be translated into English.
Parameters
Sub account email
recvWindow(int) – optional
ReturnsAPI response
{
[email protected]
11.64405625
6.82728457
0.58633215
6.24095242
marginTradeCoeffVo
{
1.10000000
˓→ ratio
1.50000000 //Margin call margin
˓→ ratio
2.00000000 Initial margin ratio
},
"marginUserAssetVoList": [
{
BTC
0.00000000
(continues on next page)

6.1. Contents 161


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.00499500
0.00000000
0.00000000
0.00499500
},
{
BNB
201.66666672
2346.50000000
0.00000000
0.00000000
2144.83333328
},
{
ETH
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
},
{
USDT
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_margin_summary(**params)
Get Summary of Sub-account’s Margin Account (For Master Account)
The provided text is a URL and cannot be translated.
ParametersrecvWindow(int) – optional
ReturnsAPI response
{
4.33333333
2.11111112
2.22222221
"subAccountList":[
{
[email protected]
2.11111111
1.11111111
1.00000000
},
{
[email protected]
2.22222222
(continues on next page)

162 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


1.00000001
1.22222221
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_subaccount_transfer_history(**params)
Sub-account Transfer History (For Sub-account)
https://binance-docs.github.io/apidocs/spot/en/#transfer-to-master-for-sub-account
Parameters
required - The asset being transferred, e.g., USDT
optional - 1: transfer in, 2: transfer out
optional
optional
•limit(int) – optional - Default 500
recvWindow(int) - optional
ReturnsAPI response

[
{
master
[email protected]
"type":1,//1fortransferin,2fortransfer out
BTC
1
SUCCESS
"tranId":11798835829,
"time":1544433325000
},
{
subAccount
[email protected]
"type":2,
ETH
2
SUCCESS
"tranId":11798829519,
"time":1544433326000
}
]

RaisesBinanceRequestException, BinanceAPIException

get_symbol_info(symbol)→Optional[Dict[KT, VT]]
Return information about a symbol
Parameters symbol(str) – required e.g BNBBTC
ReturnsDict if found, None if not

6.1. Contents 163


python-binance Documentation, Release 0.2.0

{
ETHBTC
TRADING
ETH
"baseAssetPrecision":8,
BTC
"quotePrecision":8,
"orderTypes": ["LIMIT","MARKET"],
"icebergAllowed": false,
"filters": [
{
PRICE_FILTER
0.00000100
100000.00000000
0.00000100
}, {
LOT_SIZE
0.00100000
100000.00000000
0.00100000
}, {
MIN_NOTIONAL
0.00100000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

get_symbol_ticker(**params)
Latest price for a symbol or symbols.
This is a URL and does not contain translatable text.
Parameterssymbol(str) –
ReturnsAPI response

{
LTCBTC
4.00000200
}

OR

[
{
LTCBTC
4.00000200
},
{
ETHBTC
0.07946600
}
]

RaisesBinanceRequestException, BinanceAPIException

164 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

get_system_status()
Get system status detail.
Unable to access the content of the provided link.
ReturnsAPI response
{
"status":0, normal system maintenance
normal normal or System maintenance.
}

RaisesBinanceAPIException

get_ticker(**params)
24 hour price change statistics.
Unable to access external links. Please provide text for translation.
Parameterssymbol(str) –
ReturnsAPI response
{
-94.99999800
-95.960
0.29628482
0.10002000
4.00000200
4.00000000
4.00000200
99.00000000
100.00000000
0.10000000
8913.30000000
"openTime":1499783499040,
"closeTime":1499869899040,
"fristId":28385, First tradeId
"lastId":28460, Last tradeId
"count":76 Trade count
}

OR

[
{
-94.99999800
-95.960
0.29628482
0.10002000
4.00000200
4.00000000
4.00000200
99.00000000
100.00000000
0.10000000
8913.30000000
"openTime":1499783499040,
"closeTime":1499869899040,
(continues on next page)

6.1. Contents 165


python-binance Documentation, Release 0.2.0

(continued from previous page)


"fristId":28385, First tradeId
"lastId":28460, Last tradeId
"count":76 Trade count
}
]

Raises BinanceRequestException, BinanceAPIException

get_trade_fee(**params)
Get trade fee.
Invalid URL provided.
Parameters
•symbol(str) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
ADABNB
0.001
0.001
},
{
BNBBTC
0.001
0.001
}
]

get_universal_transfer_history(**params)
Universal Transfer (For Master Account)
Unable to access external links for content translation.
Parameters
optional
optional
optional
optional (int)
•page(int) – optional
•limit(int) – optional
recvWindow(int) - optional
ReturnsAPI response

[
{
"tranId":11945860693,
[email protected]
(continues on next page)

166 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


[email protected]
BTC
0.1
SPOT
COIN_FUTURE
SUCCESS
"createTimeStamp":1544433325000
},
{
"tranId":11945857955,
[email protected]
[email protected]
ETH
0.2
SPOT
USDT_FUTURE
SUCCESS
"createTimeStamp":1544433326000
}
]

Raises BinanceRequestException, BinanceAPIException

get_withdraw_history(**params)
Fetch withdraw history.
Invalid input. Please provide a text for translation.
Parameters
(str) – optional
•offset(int) – optional - default:0
•limit(int) – optional
optional - Default: 90 days from current timestamp
•endTime(int) – optional - Default: present timestamp
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

[
{
0x94df8b352de7f46f64b01d3666bf6e936e44ce60
8.91000000
2019-10-12 11:12:02
USDT
b6ae22b3aa844210a7041aee7589627c
WITHDRAWtest123notbe returnedif
˓→ there's no withdrawOrderId for this withdraw.

ETH
"transferType":0, //1forinternal transferforexternal
˓→ transfer

"status":6,
txId
˓→ 0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268

(continues on next page)

6.1. Contents 167


python-binance Documentation, Release 0.2.0

(continued from previous page)


},
{
1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB
0.00150000
2019-09-24 12:43:45
BTC
156ec387f49b41df8724fa744fa82719
BTC
"status":6,
txId
˓→ 60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354

}
]

RaisesBinanceRequestException, BinanceAPIException

get_withdraw_history_id(withdraw_id,**params)
Fetch withdraw history.
The provided input is a URL and does not contain translatable text.
Parameters
required
optional
long - optional
•endTime(long) – optional
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
7213fea8e94b4a5593d507237e5a555b
withdrawOrderIdNone,
"amount":0.99,
"transactionFee":0.01,
0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b
ETH
txId
˓→ 0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1

"applyTime":1508198532000,
"status":4
}

RaisesBinanceRequestException, BinanceAPIException

isolated_margin_stream_close(symbol, listenKey)
Close out an isolated margin data stream.
The provided link does not contain translatable text.
Parameters
required - symbol for the isolated margin account
required

168 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

isolated_margin_stream_get_listen_key(symbol)
Start a new isolated margin data stream and return the listen key. If a stream already exists, it should return.
the same key. If the stream becomes invalid a new key is returned.
Can be used to keep the stream alive.
The provided link does not contain translatable text.
Parameterssymbol(str) – required - symbol for the isolated margin account
ReturnsAPI response

{
listenKey
˓→ T3ee22BIYuWqmvne0HNq2A2WsFlEtLhvWCtItw6ffhhdmjifQ2tRbuKkTHhr
}

RaisesBinanceRequestException, BinanceAPIException

isolated_margin_stream_keepalive(symbol,listenKey)
PING an isolated margin data stream to prevent a time out.
Unable to access external URLs.
Parameters
•symbol(str) – required - symbol for the isolated margin account
str - required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

make_subaccount_futures_transfer(**params)
Futures Transfer for Sub-account (For Master Account)
The provided link is not a text that can be translated.
Parameters
required - Sub account email
required - The asset being transferred, e.g., USDT
required - The amount to be transferred
•type(int) – required - 1: transfer from subaccount’s spot account to its USDT-
margined futures account 2: transfer from subaccount’s USDT-margined futures
transfer from subaccount’s spot account to its COIN-
margined futures account 4: transfer from subaccount’s COIN-margined futures
account to its spot account

6.1. Contents 169


python-binance Documentation, Release 0.2.0

ReturnsAPI response

{
2966662589
}

RaisesBinanceRequestException, BinanceAPIException

make_subaccount_margin_transfer(**params)
Margin Transfer for Sub-account (For Master Account)
Invalid request. No text provided for translation.
Parameters
required - Sub account email
required - The asset being transferred, e.g., USDT
required - The amount to be transferred
required - 1: transfer from subaccount’s spot account to margin
account 2: transfer from subaccount’s margin account to its spot account
ReturnsAPI response

{
2966662589
}

RaisesBinanceRequestException, BinanceAPIException

make_subaccount_to_master_transfer(**params)
Transfer to Master (For Sub-account)
Invalid URL, unable to translate.
Parameters
The asset being transferred, e.g., USDT
required - The amount to be transferred
recvWindow(int) – optional
ReturnsAPI response

{
2966662589
}

Raises Binance Request Exception, Binance API Exception

make_subaccount_to_subaccount_transfer(**params)
Transfer to Sub-account of Same Master (For Sub-account)
The provided link does not contain translatable text.
Parameters
Sub account email

170 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

required - The asset being transferred, e.g., USDT


The amount to be transferred
recvWindow(int) – optional
ReturnsAPI response

{
2966662589
}

Raises BinanceRequestException, BinanceAPIException

(params)
Universal Transfer (For Master Account)
Unable to access the link provided. Please provide text for translation.
Parameters
optional
toEmail(str) – optional
•fromAccountType(str) – required - “SPOT”,”USDT_FUTURE”,”COIN_FUTURE”
•toAccountType(str) – required - “SPOT”,”USDT_FUTURE”,”COIN_FUTURE”
The asset being transferred, e.g., USDT
required
recvWindow(int) - optional
ReturnsAPI response

{
"tranId":11945860693
}

RaisesBinanceRequestException, BinanceAPIException

make_universal_transfer(**params)
User Universal Transfer
The provided link does not contain translatable text. Please provide actual text for translation.
Parameters
type(str (ENUM)) – required
required
required
recvWindow(int) – the number of milliseconds the request is valid for

client.make_universal_transfer(params)

ReturnsAPI response

6.1. Contents 171


python-binance Documentation, Release 0.2.0

{
"tranId":13526853623
}

RaisesBinanceRequestException, BinanceAPIException

margin_stream_close(listenKey)
Close out a cross-margin data stream.
The provided text is a URL and does not contain translatable text.
ParameterslistenKey(str) – required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

margin_stream_get_listen_key()
Start a new cross-margin data stream and return the listen key. If a stream already exists it should return.
the same key. If the stream becomes invalid a new key is returned.
Can be used to keep the stream alive.
Unable to access the provided link.
ReturnsAPI response

{
listenKey
˓→ pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1
}

RaisesBinanceRequestException, BinanceAPIException

margin_stream_keepalive(listenKey)
PING a cross-margin data stream to prevent a time out.
Unable to access external links or web content.
ParameterslistenKey(str) – required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

new_transfer_history(**params)
Get future account transaction history list
Unable to access the content of the provided URL.
options_account_info(**params)
Account asset info (USER_DATA)
Unable to access external links.

172 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

Parameters recvWindow(int) – optional


(**params)
Account funding flow (USER_DATA)
Invalid input. Please provide text for translation instead of a URL.
Parameters
required - Asset type - USDT
•recordId(int) – optional - Return the recordId and subsequent data, the latest
data is returned by default - 100000
optional - Start Time - 1593511200000
optional - End Time - 1593511200000
•limit(int) – optional - Number of result sets returned Default:100 Max:1000 -
100
recvWindow(int) – optional
options_cancel_all_orders(**params)
Cancel all Option orders (TRADE)
The provided link does not contain translatable text.
Parameters
BTC-200730-9000-C
recvWindow(int) – optional
**params
Cancel Multiple Option orders (TRADE)
Invalid URL for translation; please provide text instead.
Parameters
BTC-200730-9000-C
optional - Order ID - [4611875134427365377, 4611875134427365378]
list – optional - User-defined order ID -
[“my_id_1”,”my_id_2”]
recvWindow(int) – optional
(**params)
Cancel Option order (TRADE)
https://binance-docs.github.io/apidocs/voptions/en/#cancel-option-order-trade
Parameters
BTC-200730-9000-C
optional - Order ID - 4611875134427365377
optional - User-defined order ID - 10000
recvWindow(int) – optional
options_exchange_info()
Get current limit info and trading pair info
URL provided is not translatable text.

6.1. Contents 173


python-binance Documentation, Release 0.2.0

options_funds_transfer(**params)
Funds transfer (USER_DATA)
https://binance-docs.github.io/apidocs/voptions/en/#funds-transfer-user_data
Parameters
USDT
•type(str (ENUM)) – required - IN: Transfer from spot account to option account-
count OUT: Transfer from option account to spot account - IN
10000
recvWindow(int) – optional
options_historical_trades(**params)
Query trade history
The provided link does not contain translatable text. Please provide specific text that needs to be translated.
Parameters
BTC-200730-9000-C
fromId(int) – optional - The deal ID from which to return. The latest deal
record is returned by default - 1592317127349
•limit(int) – optional - Number of records Default:100 Max:500 - 100
options_index_price(**params)
Get the spot index price
Unable to access external links for translation.
Parametersunderlying(str) – required - Spot pairOption contract underlying asset-
BTCUSDT
options_info()
Get current trading pair info
The link provided leads to the Binance API documentation for retrieving current trading pair information.
options_klines(**params)
Candle data
Unable to access the provided URL.
Parameters
BTC-200730-9000-C
required - Time interval - 5m
optional - Start Time - 1592317127349
•endTime(int) – optional - End Time - 1592317127349
•limit(int) – optional - Number of records Default:500 Max:1500 - 500
options_mark_price(**params)
Get the latest mark price
https://binance-docs.github.io/apidocs/voptions/en/#get-the-latest-mark-price
Parameterssymbol(str) – optional - Option trading pair - BTC-200730-9000-C

174 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

options_order_book(**params)
Depth information
Unable to access content from the provided URL.
Parameters
BTC-200730-9000-C
•limit(int) – optional - Default:100 Max:1000.Optional value:[10, 20, 50, 100,
500, 1000] - 100
options_ping()
Test connectivity
Unable to access the link provided. Please provide text for translation.
options_place_batch_order(**params)
Place Multiple Option orders (TRADE)
The provided link does not contain any text to translate.
Parameters
•orders(list) – required - order list. Max 5 orders - [{“symbol”:”BTC-210115-
35000-C
recvWindow(int) – optional
options_place_order(**params)
Option order (TRADE)
Unable to access external links.
Parameters
BTC-200730-9000-C
BUY
Order Type: LIMIT, MARKET - LIMIT
Order Quantity - 3
•price(float) – optional - Order Price - 1000
time in force method (default GTC)
GTC
•reduceOnly(bool) – optional - Reduce Only (Default false) - false
•postOnly(bool) – optional - Post Only (Default false) - false
•newOrderRespType(str (ENUM)) – optional - “ACK”, “RESULT”, Default
ACK
optional - User-defined order ID cannot be repeated
in pending orders - 10000
(int) - optional
options_positions(**params)
Option holdings info (USER_DATA)
Unable to access external links.
Parameters

Contents 175
python-binance Documentation, Release 0.2.0

BTC-200730-9000-C
•recvWindow(int) – optional
options_price(**params)
Get the latest price
The provided link does not contain text to translate.
Parameterssymbol(str) – optional - Option trading pair - BTC-200730-9000-C
options_query_order(**params)
Query Option order (TRADE)
The provided content is a URL and does not contain translatable text.
Parameters
Option trading pair - BTC-200730-9000-C
optional - Order ID - 4611875134427365377
•clientOrderId(str) – optional - User-defined order ID - 10000
recvWindow(int) – optional
options_query_order_history(**params)
Query Option order history (TRADE)
Invalid request, no translatable text provided.
Parameters
required - Option trading pair - BTC-200730-9000-C
•orderId(str) – optional - Returns the orderId and subsequent orders, the most
recent order is returned by default - 100000
optional - Start Time - 1593511200000
optional - End Time - 1593511200000
•limit(int) – optional - Number of result sets returned Default:100 Max:1000 -
100
recvWindow(int) – optional
options_query_pending_orders(**params)
Query current pending Option orders (TRADE)
Unable to access external links for content translation.
Parameters
BTC-200730-9000-C
•orderId(str) – optional - Returns the orderId and subsequent orders, the most
recent order is returned by default - 100000
optional - Start Time - 1593511200000
•endTime(int) – optional - End Time - 1593511200000
•limit(int) – optional - Number of result sets returned Default:100 Max:1000 -
100
recvWindow(int) – optional

176 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

options_recent_trades(**params)
Recently completed Option trades
The provided link does not contain translatable text.
Parameters
BTC-200730-9000-C
•limit(int) – optional - Number of records Default:100 Max:500 - 100
options_time()
Get server time
Unable to access the provided URL to extract text for translation.
options_user_trades(**params)
Option Trade List (USER_DATA)
The provided link does not contain text to translate.
Parameters
Option trading pair - BTC-200730-9000-C
•fromId(int) – optional - Trade id to fetch from. Default gets most recent trades.
4611875134427365376
optional - Start Time - 1593511200000
•endTime(int) – optional - End Time - 1593511200000
•limit(int) – optional - Number of result sets returned Default:100 Max:1000 -
100
recvWindow(int) – optional
order_limit(timeInForce='GTC', **params)
Send in a new limit order
Any order with an icebergQty MUST have timeInForce set to GTC.
Parameters
required
required
decimal - required
str – required
default Good till cancelled
•newClientOrderId(str) – A unique id for the order. Automatically generated.
ated if not sent.
icebergQty(decimal) – Used with LIMIT, STOP_LOSS_LIMIT, and
TAKE_PROFIT_LIMIT to create an iceberg order.
Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options

6.1. Contents 177


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException BinanceAPIException BinanceOrderException,


BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_limit_buy(timeInForce='GTC', **params)
Send in a new limit buy order
Any order with an icebergQty MUST have timeInForce set to GTC.
Parameters
required
required
required
default Good till cancelled
A unique id for the order. Automatically generated.
ated if not sent.
decimal - Used with stop orders
icebergQty(decimal) – Used with iceberg orders
Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises Binance Request Exception BinanceAPIException BinanceOrderException
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_limit_sell(timeInForce='GTC', **params)
Send in a new limit sell order
Parameters
required
•quantity(decimal) – required
required
default Good till cancelled
newClientOrderId(str) – A unique id for the order. Automatically generated.
ated if not sent.
Used with stop orders
iceberg quantity (decimal) – Used with iceberg orders

Set the response JSON. ACK, RESULT, or


FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

178 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

See order endpoint for full response options


Raises Binance Request Exception BinanceAPIException BinanceOrderException,
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_market(**params)
Send in a new market order
Parameters
required
required
required
amount the user wants to spend (when buying)
or receive (when selling) of the quote asset
•newClientOrderId(str) – A unique id for the order. Automatically generated.
ated if not sent.
newOrderRespType(str) – Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
RaisesBinanceRequestException BinanceAPIException BinanceOrderException
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_market_buy(**params)
Send in a new market buy order
Parameters
required
required
quoteOrderQty(decimal) – the amount the user wants to spend of the quote
asset
newClientOrderId(str) – A unique id for the order. Automatically generated.
ated if not sent.
newOrderRespType(str) – Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
Raises Binance Request Exception BinanceAPIException BinanceOrderException
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException

6.1. Contents 179


python-binance Documentation, Release 0.2.0

order_market_sell(**params)
Send in a new market sell order
Parameters
required
decimal - required
quoteOrderQty(decimal) – the amount the user wants to receive of the quote
asset
•newClientOrderId(str) – A unique id for the order. Automatically generated.
ated if not sent.
newOrderRespType(str) – Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See order endpoint for full response options
RaisesBinanceRequestException BinanceAPIException BinanceOrderException
Binance Order Minimum Amount Exception, Binance Order Minimum Price Exception, Binance Or-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_oco_buy(**params)
Send in a new OCO buy order
Parameters
required
listClientOrderId(str) – A unique id for the list order. Automatically
generated if not sent.
decimal - required
A unique id for the limit order. Automatically
generated if not sent.
(str) - required
limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an
iceberg order.
•stopClientOrderId(str) – A unique id for the stop order. Automatically
generated if not sent.
string - required
stopLimitPrice(str) – If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make
an iceberg order.
Valid values are GTC/FOK/IOC.
•newOrderRespType(str) – Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

180 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

See OCO order endpoint for full response options


Raises BinanceRequestException, BinanceAPIException BinanceOrderException
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
order_oco_sell(**params)
Send in a new OCO sell order
Parameters
required
listClientOrderId(str) – A unique id for the list order. Automatically
generated if not sent.
quantity(decimal) – required
•limitClientOrderId(str) – A unique id for the limit order. Automatically
generated if not sent.
required
•limitIcebergQty(decimal) – Used to make the LIMIT_MAKER leg an
iceberg order.
stopClientOrderId(str) – A unique id for the stop order. Automatically
generated if not sent.
required
If provided, stopLimitTimeInForce is required.
stopIcebergQty(decimal) – Used with STOP_LOSS_LIMIT leg to make
an iceberg order.
Valid values are GTC/FOK/IOC.
Set the response JSON. ACK, RESULT, or
FULL; default: RESULT.
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response
See OCO order endpoint for full response options
RaisesBinanceRequestException, BinanceAPIException, BinanceOrderException,
BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOr-
derMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInac-
tiveSymbolException
ping()→Dict[KT, VT]
Test connectivity to the Rest API.
The URL you provided does not contain any translatable text. Please provide a specific text for translation.
Returns empty array

{}

Raises Binance Request Exception, Binance API Exception

6.1. Contents 181


python-binance Documentation, Release 0.2.0

purchase_lending_product(**params)
Purchase Flexible Product
Unable to access the provided URL.
query_subaccount_spot_summary(**params)
Query Sub-account Spot Assets Summary (For Master Account)
Unable to access the given URL. Please provide text to translate.
Parameters
optional - Sub account email
•page(int) – optional - default 1
•size(int) – optional - default 10, max 20
recvWindow(int) – optional
ReturnsAPI response

{
"totalCount":2,
0.23231201
"spotSubUserAssetBtcVoList":[
{
[email protected]
9999.00000000
},
{
[email protected]
0.00000000
}
]
}

RaisesBinanceRequestException, BinanceAPIException

universal_transfer_history
Query User Universal Transfer History
Query User Universal Transfer History
Parameters
•type(str (ENUM)) – required
optional
(int) - optional
optional - Default 1
•size(int) – required - Default 10, Max 100
recvWindow(int) – the number of milliseconds the request is valid for

client.query_universal_transfer_history(params)

ReturnsAPI response

182 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{
"total":2,
"rows":[
{
USDT
1
MAIN_UMFUTURE
CONFIRMED
"tranId":11415955596,
"timestamp":1544433328000
},
{
USDT
2
MAIN_UMFUTURE
CONFIRMED
"tranId":11366865406,
"timestamp":1544433328000
}
]
}

Raises BinanceRequestException, BinanceAPIException

redeem_lending_product(**params)
Redeem Flexible Product
The provided text is a URL and cannot be translated.
repay_margin_loan(**params)
Repay loan in cross-margin or isolated-margin account.
If the amount is more than the amount borrowed, the full loan will be repaid.
https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
Parameters
name of the asset
amount to transfer
•isIsolated(str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)
Isolated margin symbol (default blank for cross-margin)
recvWindow(int) – the number of milliseconds the request is valid for

client.margin_repay_loan(asset='BTC', amount='1.1')

client.margin_repay_loan(asset='BTC', amount='1.1')
TRUE

ReturnsAPI response

{
"tranId":100000001
}

6.1. Contents 183


python-binance Documentation, Release 0.2.0

RaisesBinanceRequestException, BinanceAPIException

stream_close(listenKey)
Close out a user data stream.
Invalid request. Please provide text to translate.
str - required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

stream_get_listen_key()
Start a new user data stream and return the listen key. If a stream already exists, it should return the same.
key. If the stream becomes invalid a new key is returned.
Can be used to keep the user stream alive.
Unable to access external content.
ReturnsAPI response

{
listenKey
˓→ pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1
}

RaisesBinanceRequestException, BinanceAPIException

stream_keepalive(listenKey)
PING a user data stream to prevent a time out.
Unable to access the provided URL.
str - required
ReturnsAPI response

{}

RaisesBinanceRequestException, BinanceAPIException

toggle_bnb_burn_spot_margin(**params)
Toggle BNB Burn On Spot Trade And Margin Interest
The provided text is a URL link and does not contain translatable content.
data
Parameters
Determines whether to use BNB to pay for trading fees
on SPOT
•interestBNBBurn(bool) – Determines whether to use BNB to pay for margin
loan's interest

184 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

client.toggle_bnb_burn_spot_margin()

ReturnsAPI response

{
"spotBNBBurn":true,
"interestBNBBurn": false
}

RaisesBinanceRequestException, BinanceAPIException

transfer_dust(**params)
Convert dust assets to BNB.
Unable to access the content from the provided URL.
Parameters
The asset being converted. e.g: ‘ONE’
recvWindow(int) - the number of milliseconds the request is valid for

client.transfer_dust(asset='ONE')

ReturnsAPI response

{
0.02102542
1.05127099
"transferResult":[
{
0.03000000
ETH
"operateTime":1563368549307,
0.00500000
"tranId":2970932918,
0.25000000
}
]
}

Raises Binance Request Exception, Binance API Exception

transfer_history(**params)
Get future account transaction history list
Invalid input. Please provide the text to be translated.
transfer_isolated_margin_to_spot(**params)
Execute transfer between isolated margin account and spot account.
The provided link is not a text to translate. Please provide the text you want me to translate.
Parameters
name of the asset
pair symbol

6.1. Contents 185


python-binance Documentation, Release 0.2.0

amount to transfer
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_isolated_margin_to_spot(asset='BTC')
ETHBTC
˓→ 1.1

ReturnsAPI response

{
"tranId":100000001
}

RaisesBinanceRequestException, BinanceAPIException

(**params)
Execute transfer between cross-margin account and spot account.
Unable to access external links.
Parameters
name of the asset
amount to transfer
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_margin_to_spot(asset='BTC', amount='1.1')

ReturnsAPI response

{
"tranId":100000001
}

RaisesBinanceRequestException, BinanceAPIException

transfer spot to isolated margin


Execute transfer between spot account and isolated margin account.
The provided text is a URL link and does not contain translatable text.
Parameters
name of the asset
pair symbol
amount(str) – amount to transfer
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_spot_to_isolated_margin(asset='BTC')
ETHBTC
˓→ 1.1

ReturnsAPI response

186 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

{
"tranId":100000001
}

RaisesBinanceRequestException, BinanceAPIException

transfer_spot_to_margin(**params)
Execute transfer between spot account and cross-margin account.
Unable to access external links.
Parameters
name of the asset
amount to transfer
recvWindow(int) – the number of milliseconds the request is valid for

client.transfer_spot_to_margin(asset='BTC', amount='1.1')

ReturnsAPI response

{
"tranId":100000001
}

RaisesBinanceRequestException, BinanceAPIException

universal_transfer(**params)
Universal transfer API across different Binance account types
Unable to access content from the provided URL.
withdraw(**params)
Submit a withdrawal request.
Unable to access the provided link for translation.
Assumptions:
You must have Withdraw permissions enabled on your API key
You must have withdrawn to the address specified through the website and approved the transaction.
via email

Parameters
required
optional - client id for withdraw
optional
optional
required
required - When making internal transfer
true for returning the fee to the destination account; false for returning the fee back
to the departure account. Default false.

6.1. Contents 187


python-binance Documentation, Release 0.2.0

optional - Description of the address, default asset value passed will


be used
recvWindow(int) – the number of milliseconds the request is valid for
ReturnsAPI response

{
7213fea8e94b4a5593d507237e5a555b
}

RaisesBinanceRequestException, BinanceAPIException

depthcache module

classbinance.depthcache.BaseDepthCacheManager(client, symbol loop=None, re-


fresh_interval=None, bm=None,
limit=10, conv_type=<class 'float'>
Bases: object
DEFAULT_REFRESH = 1800
TIMEOUT = 60
__init__(client,symbol,loop=None,refresh_interval=None,bm=None,limit=10,conv_type=<class
’float’>
Create a DepthCacheManager instance
Parameters
•client(binance.Client) – Binance API client
loop
•symbol(string) – Symbol to create depth cache for
refresh_interval(int) – Optional number of seconds between cache re-
fresh, use 0 or None to disable
•bm(BinanceSocketManager) - Optional BinanceSocketManager
•limit(int) – Optional number of orders to get from orderbook
•conv_type(function.) – Optional type to represent price, and amount, de-
fault is float.
close()
Close the open socket for this manager
Returns
get_depth_cache()
Get the current depth cache
ReturnsDepthCache object
get_symbol()
Get the symbol
Return symbol
recv()

188 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

classbinance.depthcache.DepthCache(symbol, conv_type=<class 'float'>)


Bases: object
__init__(symbol,conv_type=<class ’float’>)
Initialize the DepthCache
Parameters
symbol(string) – Symbol to create depth cache for
•conv_type(function.) – Optional type to represent price, and amount, de-
fault is float.
add_ask(ask)
Add an ask to the cache
Parametersask–
Returns
add_bid(bid)
Add a bid to the cache
Parameters bid–
Returns
get_asks()
Get the current asks
Returns list of asks with price and quantity as conv_type.

[
[
0.0001955Price
57.0' Quantity
],
[
0.00019699
778.0
],
[
0.000197
64.0
],
[
0.00019709
1130.0
],
[
0.0001971
385.0
]
]

get_bids()
Get the current bids
Returns list of bids with price and quantity as conv_type

[
[
(continues on next page)

6.1. Contents 189


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.0001946Price
45.0 Quantity
],
[
0.00019459
2384.0
],
[
0.00019158
5219.0
],
[
0.00019157
1180.0
],
[
0.00019082
287.0
]
]

static sort_depth(vals, reverse=False, conv_type=<class 'float'>)


Sort bids or asks by price
classbinance.depthcache.DepthCacheManager(client, symbol loop=None re-
fresh_interval=None, bm=None,
limit=500,conv_type=<class 'float'>
ws_interval=None)
Bases:binance.depthcache.BaseDepthCacheManager
__init__(client, symbol, loop=None, refresh_interval=None, bm=None, limit=500
<class 'float'>
Initialize the DepthCacheManager
Parameters
Binance API client
•loop– asyncio loop
•symbol(string) – Symbol to create depth cache for
refresh_interval(int) – Optional number of seconds between cache refreshes.
fresh, use 0 or None to disable
•limit(int) – Optional number of orders to get from orderbook
•conv_type(function.) – Optional type to represent price, and amount, de-
fault is float.
ws_interval(int) – Optional interval for updates on websocket, default None.
If not set, updates happen every second. Must be 0, None (1s) or 100 (100ms).
classbinance.depthcache.FuturesDepthCacheManager(client,symbol,loop=None,re-
fresh_interval=None, bm=None,
limit=10 conv_type=<class
float
Bases:binance.depthcache.BaseDepthCacheManager

190 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

classbinance.depthcache.OptionsDepthCacheManager(client,symbol,loop=None,re-
fresh_interval=None, bm=None,
limit=10 <class
’float’>)
Bases:binance.depthcache.BaseDepthCacheManager
class binance.depthcache.ThreadedDepthCacheManager(api_key: Optional[str] = None,
Optional[str] = None
Dict[str,str] =
None, tld: str = 'com', testnet:
bool = False
Bases: binance.threaded_stream.ThreadedApiManager
__init__(api_key: Optional[str] = None,api_secret: Optional[str] = None,requests_params:
Dict[str,str] = None,tld: str = ’com’,testnet: bool = False)
Initialize the BinanceSocketManager
start_depth_cache(callback: Callable, symbol: str, refresh_interval=None, bm=None, limit=10,
conv_type=<class 'float'>,ws_interval=0)→str
start_futures_depth_socket(callback: Callable, symbol: str, refresh_interval=None)
bm=None,limit=10,conv_type=<class 'float'>)→str
start_options_depth_socket(callback: Callable, symbol: str, refresh_interval=None,
bm=None, limit=10, conv_type=<class 'float'>)→str

exceptions module

BinanceAPIException
Bases: Exception
initialize
Initialize self. See help(type(self)) for accurate signature.
exceptionbinance.exceptions.BinanceOrderException
Bases: Exception
__init__
Initialize self. See help(type(self)) for accurate signature.
BinanceOrderInactiveSymbolException
Bases:binance.exceptions.BinanceOrderException
__init__(value)
Initialize self. See help(type(self)) for accurate signature.
BinanceOrderMinAmountException
Bases:binance.exceptions.BinanceOrderException
__init__(value)
Initialize self. See help(type(self)) for accurate signature.
exceptionbinance.exceptions.BinanceOrderMinPriceException(value)
Bases:binance.exceptions.BinanceOrderException
__init__(value)
Initialize self. See help(type(self)) for accurate signature.
exceptionbinance.exceptions.BinanceOrderMinTotalException(value)
Bases:binance.exceptions.BinanceOrderException

6.1. Contents 191


python-binance Documentation, Release 0.2.0

__init__(value)
Initialize self. See help(type(self)) for accurate signature.
BinanceOrderUnknownSymbolException
Bases:binance.exceptions.BinanceOrderException
__init__(value)
Initialize self. See help(type(self)) for accurate signature.
binance.exceptions.BinanceRequestException
Bases: Exception
__init__(message)
Initialize self. See help(type(self)) for accurate signature.
BinanceWebsocketUnableToConnect
Bases:Exception
NotImplementedException
Bases: Exception
__init__(value)
Initialize self. See help(type(self)) for accurate signature.

helpers module

binance.helpers.convert_ts_str(ts_str)
binance.helpers.date_to_milliseconds(date_str: str)→int
Convert UTC date to milliseconds
If using offset strings add 'UTC' to date string e.g. 'now UTC', '11 hours ago UTC'
See dateparse docs for formatshttp://dateparser.readthedocs.io/en/latest/
date in readable format, i.e. 'January 01, 2018', '11 hours ago UTC'
now UTC
binance.helpers.interval_to_milliseconds(interval: str)→Optional[int]
Convert a Binance interval string to milliseconds
Parameters interval– Binance interval string, e.g.: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h,
8h, 12h, 1d, 3d, 1w
Returns int value of interval in milliseconds None if interval prefix is not a decimal integer None
if interval suffix is not one of m, h, d, w
binance.helpers.round_step_size(quantity: Union[float, decimal.Decimal step_size
Union[float, decimal.Decimal])→float
Rounds a given quantity to a specific step size
Parameters
required
required
Returns decimal

websockets module

classbinance.streams.BinanceSocketManager(client: binance.client.AsyncClient,
user_timeout=300)
Bases: object

192 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

wss://dstream.binancefuture.com/
wss://dstream.binance.{}/
wss://stream.binancefuture.com/
wss://fstream.binance.{}/
wss://testnet.binance.vision/
wss://stream.binance.{}:9443/
wss://testnetws.binanceops.{}/
wss://vstream.binance.{}/
10
20
5
__init__(client: binance.client.AsyncClient,user_timeout=300)
Initialize the BinanceSocketManager
Parameters client (binance.AsyncClient) – Binance API client
aggtrade_futures_socket(symbol: str, futures_type: binance.enums.FuturesType = <Fu-
turesType.USD_M: 1>)
Start a websocket for aggregate symbol trade data for the futures stream
Parameters
•symbol– required
use USD-M or COIN-M futures default USD-M
Returns connection key string if successful, False otherwise
Message Format

{
aggTrade
"E": 123456789, Event time
BTCUSDT // Symbol
"a": 5933014, Aggregate trade ID
0.001 Price
100 Quantity
"f": 100, First trade ID
"l": 105, last_trade_id
"T": 123456785, Trade time
"m": true, Is the buyer the market maker?
}

aggtrade_socket(symbol: str)
Start a websocket for symbol trade data
The provided link is not translatable text.
aggregate-trade-streams
str - required
Returns connection key string if successful, False otherwise
Message Format

6.1. Contents 193


python-binance Documentation, Release 0.2.0

{
aggTrade event_type
"E":1499405254326, event time
ETHBTC # symbol
"a":70232, aggregated tradeid
0.10281118 price
8.15632997 quantity
"f":77489, first breakdown trade id
"l":77489, last breakdown trade id
"T":1499405254324, trade time
"m": false, whether buyer is a maker
"M": true can be ignored
}

all_mark_price_socket(fast: bool = True, futures_type: binance.enums.FuturesType = <Fu-


turesType.USD_M: 1>)
Start a websocket for all futures mark price data By default all symbols are included in an array.
//binance-docs.github.io/apidocs/futures/en/#mark-price-stream-for-all-market param fast: use faster or
1s default :param futures_type: use USD-M or COIN-M futures default USD-M :returns: connection key
string if successful, False otherwise Message Format .. code-block:: python
[
markPriceUpdate
CUSDT
T
}
]
all_ticker_futures_socket(futures_type: binance.enums.FuturesType = Fu-
turesType.USD_M: 1>)
Start a websocket for all ticker data. By default, all markets are included in an array.Invalid URL format. Please provide a text for translation.
github.io/apidocs/futures/en/#all-book-tickers-stream use USD-M or COIN-M futures
tures default USD-M :returns: connection key string if successful, False otherwise Message Format ..
code-block:: python
[
{“u”:400900217, // order book updateId “s”:”BNBUSDT”, // symbol
25.35190000
25.36520000
}
]
book_ticker_socket()
Start a websocket for the best bid or ask price or quantity for all symbols.
Unable to access external links.
all-book-tickers-stream
Returns connection key string if successful, False otherwise
Message Format

{
Sameas<symbol>@bookTickerpayload
}

194 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

coin_futures_socket()
Start a websocket for coin futures data
Invalid input, please provide text for translation.

Returns connection key string if successful, False otherwise

Message Format - see Binance API docs for all types


depth_socket(symbol: str,depth: Optional[str] = None,interval: Optional[int] = None)
Start a websocket for symbol market depth returning either a diff or a partial book
The provided link appears to be a URL and does not contain any text to translate.
partial book depth streams
Parameters
str - required
optional Number of depth entries to return, default None. If passed
returns a partial book instead of a diff
•interval(int) – optional interval for updates, default None. If not set, updates
happen every second. Must be 0, None (1s) or 100 (100ms)
Returns connection key string if successful, False otherwise
Partial Message Format

{
"lastUpdateId":160,Last update ID
"bids": [ Bids to be updated
[
0.0024 price level to be updated
10 quantity
[] translatedText

]
],
"asks": [ Asks to be updated
[
0.0026 price level to be updated
100 quantity
[] # ignore
]
]
}

Diff Message Format

{
depthUpdateevent_type
"E":123456789, Event time
BNBBTC # Symbol
"U":157, First update ID in event
"u":160, Final update ID in event
"b": [ Bids to be updated
[
0.0024 price level to be updated
10 quantity
[] # ignore
(continues on next page)

6.1. Contents 195


python-binance Documentation, Release 0.2.0

(continued from previous page)


]
],
"a": [ Asks to be updated
[
0.0026 price level to be updated
100 quantity
[] # ignore
]
]
}

futures_depth_socket(symbol: str,depth: str = ’10’,futures_type=<FuturesType.USD_M: 1>)


Subscribe to a futures depth data stream
Invalid request. Please provide text for translation.
Parameters
required
optional Number of depth entries to return, default 10.
use USD-M or COIN-M futures default USD-M
futures_multiplex_socket(streams: List[str], futures_type: binance.enums.FuturesType =
<FuturesType.USD_M: 1>
Start a multiplexed socket using a list of socket names. User stream sockets cannot be included.
Symbols in socket name must be lowercase i.ebnbbtc@aggTrade, neobtc@ticker
<streamName>
Unable to access the content from the given URL.
Parameters
list of stream names in lower case
use USD-M or COIN-M futures default USD-M
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
futures_socket()
Start a websocket for futures data
Unable to access the content at the provided URL.

Returns connection key string if successful, False otherwise

Message Format - see Binance API docs for all types


futures_user_socket()
Start a websocket for coin futures user data
The provided text is a URL and does not contain translatable content.
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types

196 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

index_price_socket(symbol: str,fast: bool = True)


Start a websocket for a symbol’s futures mark priceUnable to access or retrieve content from the provided link.
#index-price-stream required
key string if successful, False otherwise
Message Format .. code-block:: python
{
indexPriceUpdate
BTCUSD
}
individual_symbol_ticker_futures_socket(symbol: str futures_type bi-
nance.enums.FuturesType =
turesType.USD_M: 1>)
Start a futures websocket for a single symbol’s ticker dataThe provided text is a URL, and there is no text to translate.
en/#individual-symbol-ticker-streams required
use USD-M or COIN-M futures default USD-M :returns: connection key string if successful, False otherwise
otherwise .. code-block:: python
24hrTicker
p
}
isolated_margin_socket(symbol: str)
Start a websocket for isolated margin data
Unable to access the link provided to translate the content.
Parameterssymbol(str) – required - symbol for the isolated margin account
Returns the connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
kline_futures_socket(symbol: str, interval='1m', futures_type: binance.enums.FuturesType =
USD_M
perpetual
Start a websocket for symbol kline data for the perpetual futures stream
Invalid input. Please provide text for translation.
Parameters
required
Kline interval, default KLINE_INTERVAL_1MINUTE
use USD-M or COIN-M futures default USD-M
contract_type – use PERPETUAL or CURRENT_QUARTER or
NEXT_QUARTER default PERPETUAL
Returns connection key string if successful, False otherwise
Message Format
{
continuous_kline Event type
"E":1607443058651, Event time
BTCUSDT Pair
PERPETUAL Contract type
(continues on next page)

Contents 197
python-binance Documentation, Release 0.2.0

(continued from previous page)


"k":{
"t":1607443020000, Kline start time
"T":1607443079999, Kline close time
1m Interval
"f":116467658886, First trade ID
"L":116468012423, Last trade ID
18787.00 Open price
18804.04 Close price
18804.04 High price
18786.54 Low price
197.664 volume
"n": 543, Number of trades
"x":false, Is this kline closed?
3715253.19494 Quote asset volume
184.769 Taker buy volume
3472925.84746 Taker buy quote asset volume
0
}
}
<pair>_<contractType>@continuousKline_<interval>

kline_socket(symbol: str, interval='1m')


Start a websocket for symbol kline data
Unable to access the provided URL for translation.
kline candlestick streams
Parameters
required
Kline interval, default KLINE_INTERVAL_1MINUTE
Returns connection key string if successful, False otherwise
Message Format
{
kline event_type
"E":1499404907056, event_time
ETHBTC # symbol
"k": {
"t":1499404860000, start time of this bar
"T":1499404919999, end time of this bar
ETHBTC # symbol
1m interval
"f":77462, first trade id
"L":77465, last_trade_id
0.10278577 open
0.10278645 close
0.10278712 high
0.10278518 low
17.47929838 volume
"n":4, number of
˓→ trades

"x": false, whether this bar is


˓→ final

1.79662878 quote volume


2.34879839 volume of active buy
(continues on next page)

198 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.24142166 quote volume of active buy
13279784.01349473 can be ignored
}
}

margin_socket()
Start a websocket for cross-margin data
The provided input is a URL and does not contain translatable text.
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
miniticker_socket(update_time: int = 1000)
Start a miniticker websocket for all trades
This is not in the official Binance API docs, but this is what feeds the right column on a ticker page on
Binance.
time between callbacks in milliseconds, must be 1000
or greater
Returns connection key string if successful, False otherwise
Message Format

[
{
24hrMiniTickerEvent type
'E':1515906156273, Event time
QTUMETH # Symbol
0.03836900 close
0.03953500 open
0.04400000 high
0.03756000 low
147435.80000000volume
5903.84338533quote volume
}
]

multiplex_socket(streams: List[str])
Start a multiplexed socket using a list of socket names. User stream sockets cannot be included.
Symbols in socket name must be lowercase i.ebnbbtc@aggTrade, neobtc@ticker
<streamName>
Invalid input format. Please provide text for translation.
Parametersstreams(list) – list of stream names in lower case
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
options_depth_socket(symbol: str,depth: str = ’10’)
Subscribe to a depth data stream
Unable to access external links or content.
Parameters

6.1. Contents 199


python-binance Documentation, Release 0.2.0

required
optional Number of depth entries to return, default 10.
options_kline_socket(symbol: str,interval=’1m’)
Subscribe to a candlestick data stream
Unable to access external links for translation.
Parameters
required
Kline interval, default KLINE_INTERVAL_1MINUTE
options_multiplex_socket(streams: List[str])
Start a multiplexed socket using a list of socket names. User stream sockets cannot be included.
Symbols in socket name must be lowercase i.ebnbbtc@aggTrade, neobtc@ticker
<streamName>
Unable to access or translate external URLs.
Parametersstreams(list) – list of stream names in lower case
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
options_recent_trades_socket(symbol: str)
Subscribe to a latest completed trades stream
Unable to access external links.
Parameterssymbol(str) – required
options_ticker_socket(symbol: str)
Subscribe to a 24-hour ticker info stream
Invalid input. Please provide a text to be translated.
Parameterssymbol(str) – required
symbol_book_ticker_socket(symbol: str)
Start a websocket for the best bid or ask's price or quantity for a specified symbol.
Unable to access external URLs.
individual symbol book ticker streams
str – required
Returns connection key string if successful, False otherwise
Message Format

{
"u":400900217, order book updateId
BNBUSDT //symbol
25.35190000
31.21000000
25.36520000
40.66000000
}

200 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

symbol_mark_price_socket(symbol: str,fast: bool = True, futures_type bi-


FuturesType.USD_M: 1
Start a websocket for a symbol’s futures mark priceThe provided text is a URL and cannot be translated.
#mark-price-streamrequired
USD-M or COIN-M futures default USD-M :returns: connection key string if successful, False otherwise
Message Format .. code-block:: python
markPriceUpdate
CUSDT
Next funding time: 1562306400000
}
symbol_miniticker_socket(symbol: str)
Start a websocket for a symbol’s miniTicker data
Unable to access external links.
Parameters symbol (str) - required
Returns connection key string if successful, False otherwise
Message Format

{
24hrMiniTicker
"E":123456789, Event time
BNBBTC Symbol
0.0025 Close price
0.0010 Open price
0.0025 High price
0.0010 Low price
10000 Total traded base asset volume
18 Total traded quote asset volume
}

symbol_ticker_futures_socket(symbol: str, futures_type: binance.enums.FuturesType =


FuturesType.USD_M: 1
Start a websocket for a symbol's ticker data. By default all markets are included in an array.The provided text is not translatable as it appears to be a URL.
https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-book-ticker-streams re-
required :param futures_type: use USD-M or COIN-M futures default USD-M :returns: connection key
string if successful, False otherwise .. code-block:: python
[
{“u”:400900217, // order book updateId “s”:”BNBUSDT”, // symbol
25.35190000
25.36520000
}
]
symbol_ticker_socket(symbol: str)
Start a websocket for a symbol’s ticker data
Unable to access external links.
individual-symbol-ticker-streams
Parameterssymbol(str) – required
Returns connection key string if successful, False otherwise

6.1. Contents 201


python-binance Documentation, Release 0.2.0

Message Format
{
24hrTickerEvent type
"E":123456789, Event time
BNBBTC Symbol
0.0015 Price change
250.00 Price change percent
0.0018 Weighted average price
0.0009 Previous day's close price
0.0025 Current day's close price
10 Close trade's quantity
0.0024 Best bid price
10 Bid bid quantity
0.0026 Best ask price
100 Best ask quantity
0.0010 Open price
0.0025 High price
0.0010 Low price
10000 Total traded base asset volume
18 Total traded quote asset volume
"O":0, Statistics open time
"C":86400000, Statistics close time
"F":0, First trade ID
"L":18150, Last trade Id
"n":18151 Total number of trades
}

ticker_socket()
Start a websocket for all ticker data
By default all markets are included in an array.
Unable to access the content of the provided URL.
all-market-tickers-stream
Parameterscoro(function) – callback function to handle messages
Returns connection key string if successful, False otherwise
Message Format
[
{
'F':278610,
0.07393000
BCCBTC
'C':1509622420916,
0.07800800
0.07160300
0.08199900
'L':287722,
6.694
0.10000000
1202.67106335
0.00494900
'O':1509536020916,
0.07887800
'n':9113,
1.00000000
(continues on next page)

202 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

(continued from previous page)


0.07887900
0.07399600
0.07639068
2.41900000
15743.68900000
}
]

trade_socket(symbol: str)
Start a websocket for symbol trade data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#
trade-streams
Parameterssymbol(str) – required
Returns connection key string if successful, False otherwise
Message Format

{
trade Event type
"E":123456789, Event time
BNBBTC Symbol
"t":12345, Trade ID
0.001 Price
100 Quantity
"b":88, Buyer order Id
"a":50, Seller order Id
"T":123456785, Trade time
"m": true, Is the buyer the market maker?
"M": true #
}

user_socket()
Start a websocket for user data
Unable to access the content of the provided URL.https://
binance-docs.github.io/apidocs/spot/en/#listen-key-spot
Returns connection key string if successful, False otherwise
Message Format - see Binance API docs for all types
classbinance.streams.BinanceSocketType
Bases: str, enum.Enum
An enumeration.
Account
Coin_M_Futures
Vanilla_Options
Spot
USD_M_Futures

6.1. Contents 203


python-binance Documentation, Release 0.2.0

classbinance.streams.KeepAliveWebsocket(client: binance.client.AsyncClient, url


ws/
exit_coro=None,user_timeout=None)
Bases:binance.streams.ReconnectingWebsocket
__init__(client: binance.client.AsyncClient, url, keepalive_type, prefix='ws/', is_binary=False,
exit_coro=None,user_timeout=None)
Initialize self. See help(type(self)) for accurate signature.
class binance.streams.ReconnectingWebsocket(url: str, path: Optional[str] = None, pre-
ws/
exit_coro=None)
Bases: object
MAX_QUEUE_SIZE = 100
MAX_RECONNECTS = 5
MAX_RECONNECT_SECONDS = 60
MIN_RECONNECT_WAIT = 0.1
NO_MESSAGE_RECONNECT_TIMEOUT = 60
TIMEOUT = 10
__init__(url: str, path: Optional[str] = None, prefix: str = 'ws/', is_binary: bool = False,
exit_coro=None)
Initialize self. See help(type(self)) for accurate signature.
before_reconnect()
connect()
recv()
classbinance.streams.ThreadedWebsocketManager(api_key: Optional[str] = None
api_secret Optional[str] = None
requests_params: Dict[str,str] = None,
com
Bases:binance.threaded_stream.ThreadedApiManager
__init__(api_key: Optional[str] = None,api_secret: Optional[str] = None,requests_params:
Dict[str,str] = None, tld: str = 'com', testnet: bool = False)
Initialize the BinanceSocketManager
start_aggtrade_futures_socket(callback: Callable,symbol: str,futures_type: bi-
FuturesType.USD_M: 1
→str
start_aggtrade_socket(callback: Callable, symbol: str) → str
start_all_mark_price_socket(callback: Callable, fast: bool = True, futures_type: bi-
nance.enums.FuturesType = <FuturesType.USD_M: 1>)→
str
start_all_ticker_futures_socket(callback: Callable, futures_type bi-
nance.enums.FuturesType = FuturesType.USD_M
1>)→str
start_book_ticker_socket(callback: Callable)→str
start_coin_futures_socket(callback: Callable)→str
start_depth_socket(callback: Callable, symbol: str, depth: Optional[str] = None, interval: Op-
tional[int] = None)→str

204 Chapter 6. Other Exchanges


python-binance Documentation, Release 0.2.0

start_futures_depth_socket(callback: Callable, symbol: str, depth: str = '10', fu-


futures_type=<FuturesType.USD_M: 1>)→str
start_futures_multiplex_socket(callback: Callable, streams: List[str], futures_type: bi-
USD_M
→str
start_futures_socket(callback: Callable)→str
start_futures_user_socket(callback: Callable) → str
start_index_price_socket(callback: Callable, symbol: str, fast: bool = True) → str
start_individual_symbol_ticker_futures_socket(callback: Callable, sym-
bullet str bi-
nance.enums.FuturesType =
<FuturesType.USD_M: 1>)→str
start_isolated_margin_socket(callback: Callable, symbol: str) → str
start_kline_futures_socket(callback: Callable, symbol: str, interval='1m', futures_type:
binance.enums.FuturesType = <FuturesType.USD_M: 1>
binance.enums.ContractType = Contract
Type.PERPETUAL: 'perpetual'>)→str
start_kline_socket(callback: Callable, symbol: str, interval='1m') -> str
start_margin_socket(callback: Callable)→str
start_miniticker_socket(callback: Callable, update_time: int = 1000) → str
start_multiplex_socket(callback: Callable, streams: List[str])→str
start_options_depth_socket(callback: Callable, symbol: str, depth: str = '10') -> str
start_options_kline_socket(callback: Callable, symbol: str, interval='1m') -> str
start_options_multiplex_socket(callback: Callable, streams: List[str])→str
start_options_recent_trades_socket(callback: Callable, symbol: str) → str
start_options_ticker_socket(callback: Callable, symbol: str) → str
start_symbol_book_ticker_socket(callback: Callable, symbol: str) → str
start_symbol_mark_price_socket(callback: Callable,symbol: str,fast: bool =
True, futures_type: binance.enums.FuturesType = <Fu-
turesType.USD_M: 1>)→str
start_symbol_miniticker_socket(callback: Callable, symbol: str) → str
start_symbol_ticker_futures_socket(callback: Callable, symbol: str, futures_type: bi-
<FuturesType.USD_M:
1>)→str
start_symbol_ticker_socket(callback: Callable, symbol: str) → str
start_ticker_socket(callback: Callable)→str
start_trade_socket(callback: Callable, symbol: str) → str
start_user_socket(callback: Callable)→str
classbinance.streams.WSListenerState
Bases: enum.Enum
An enumeration.
Exiting

6.1. Contents 205


python-binance Documentation, Release 0.2.0

Initialising
Reconnecting
Streaming
binance.streams.random()→x in the interval [0, 1).

6.2 Index

genindex

206 Chapter 6. Other Exchanges


Python Module Index

b
binance.client,56
binance.depthcache188
binance.exceptions191
binance.helpers,192
binance.streams,192

207
python-binance Documentation, Release 0.2.0

208 Python Module Index


Index

Symbols A
__init__()(binance.client.AsyncClient method),56 ACCOUNT(binance.streams.BinanceSocketType at-
(binance.client.BaseClient method)97 tribute)203
binance.client.Client method97 add_ask()(binance.depthcache.DepthCache method)
__init__()(binance.depthcache.BaseDepthCacheManager 189
method),188 add_bid()(binance.depthcache.DepthCache method)
__init__() binance.depthcache.DepthCache 189
method),189 AGG_BEST_MATCH(binance.client.BaseClient at-
__init__()(binance.depthcache.DepthCacheManager tribute),94
method)190 AGG_BUYER_MAKES(binance.client.BaseClient at-
__init__()(binance.depthcache.ThreadedDepthCacheManager tribute),95
method),191 AGG_FIRST_TRADE_ID(binance.client.BaseClient at-
BinanceAPIException tribute95
method),191 AGG_ID(binance.client.BaseClient attribute)95
BinanceOrderException AGG_LAST_TRADE_ID(binance.client.BaseClient at-
method)191 tribute),95
BinanceOrderInactiveSymbolException AGG_PRICE(binance.client.BaseClient attribute)95
method),191 AGG_QUANTITY(binance.client.BaseClient attribute)
BinanceOr exception occurred.derMinAmountException 95
method)191 AGG_TIME(attribute of binance.client.BaseClient)95
BinanceOrderMinPriceException aggregate_trade_iter() (bi-
method),191 nance.client.AsyncClient method)56
BinanceOrderMinTotalException aggregate_trade_iter()(binance.client.Client
method)191 method),98
BinanceOrderUnknownSymbolException aggregate trade futures socket() (bi-
method)192 nance.streams.BinanceSocketManager
BinanceRequestException method)193
method),192 aggtrade_socket() (bi-
NotImplementedException nance.streams.BinanceSocketManager
method),192 method)193
__init__()(binance.streams.BinanceSocketManager all_mark_price_socket() (bi-
method),193 nance.streams.BinanceSocketManager
__init__() (binance.streams.KeepAliveWebsocket method),194
method),204 all_ticker_futures_socket() (bi-
__init__()(binance.streams.ReconnectingWebsocket nance.streams.BinanceSocketManager
method)204 method)194
__init__()(binance.streams.ThreadedWebsocketManager API_TESTNET_URL(binance.client.BaseClient at-
method),204 tribute)95
API_URL (binance.client.BaseClient attribute)95

209
python-binance Documentation, Release 0.2.0

AsyncClient(class in binance.client)56 COIN_FUTURE_TO_SPOT(binance.client.BaseClient


attribute)95
B coin_futures_socket() (bi-
BaseClient(class in binance.client)94 nance.streams.BinanceSocketManager
BaseDepthCacheManager (class in bi- method)194
nance.depthcache)188 COIN_M_FUTURES (bi-
before_reconnect() (bi- nance.streams.BinanceSocketType attribute)
nance.streams.ReconnectingWebsocket 203
method),204 connect()(binance.streams.ReconnectingWebsocket
binance.client(module),56 method)204
binance.depthcache(module),188 convert_ts_str()(in module binance.helpers),192
binance.exceptions(module),191 create()(binance.client.AsyncClient class method)
binance.helpers(module)192 57
binance.streams(module),192 create_isolated_margin_account() (bi-
BinanceAPIException191 nance.client.AsyncClient method),57
BinanceOrderException191 create_isolated_margin_account() (bi-
BinanceOrderInactiveSymbolException191 nance.client.Client method)100
BinanceOrderMinAmountException191 create_margin_loan() (bi-
BinanceOrderMinPriceException,191 nance.client.AsyncClient method)57
BinanceOrderMinTotalException191 create_margin_loan() (binance.client.Client
BinanceOrderUnknownSymbolException192 method)101
BinanceRequestException,192 create_margin_oco_order()
BinanceSocketManager (class in binance.streams) nance.client.AsyncClient method),57
192 create_margin_oco_order() (bi-
BinanceSocketType (class in binance.streams),203 nance.client.Client method),101
Binance Websocket Unable To Connect192 create_margin_order() (bi-
book_ticker_socket() (bi- nance.client.AsyncClient method)57
nance.streams.BinanceSocketManager create_margin_order() binance.client.Client
method),194 method),103
create_oco_order()(binance.client.AsyncClient
C method),57
cancel_margin_oco_order() (bi- create_oco_order() (binance.client.Client
nance.client.AsyncClient method),56 method),105
cancel_margin_oco_order() (bi- create_order() (binance.client.AsyncClient
nance.client.Client method),98 method),58
cancel_margin_order() (bi- create_order()(binance.client.Client method),106
nance.client.AsyncClient method56 create_sub_account_futures_transfer()
cancel_margin_order() (binance.client.Client (binance.client.AsyncClient method)60
method),99 create_sub_account_futures_transfer()
cancel_order() binance.client.AsyncClient (binance.client.Client method)108
method)56 create_test_order()(binance.client.AsyncClient
cancel_order()(binance.client.Client method),100 method)60
change_fixed_activity_to_daily_position() create_test_order() binance.client.Client
(binance.client.AsyncClient method)57 method)109
change_fixed_activity_to_daily_position()
(binance.client.Client method)100
D
Client(class in binance.client)97 date_to_milliseconds() (in module bi-
close()(binance.depthcache.BaseDepthCacheManager nance.helpers)192
method)188 DEFAULT_REFRESH (bi-
close_connection()(binance.client.AsyncClient nance.depthcache.BaseDepthCacheManager
method)57 attribute),188
close_connection() binance.client.Client depth_socket() (bi-
method),100 nance.streams.BinanceSocketManager
method)195

210 Index
python-binance Documentation, Release 0.2.0

DepthCache(class in binance.depthcache)188 FUTURE_ORDER_TYPE_MARKET (bi-


DepthCacheManager(class in binance.depthcache) nance.client.BaseClient attribute),95
190 FUTURE_ORDER_TYPE_STOP (bi-
disable_fast_withdraw_switch() (bi- nance.client.BaseClient attribute)95
nance.client.AsyncClient method),61 FUTURE_ORDER_TYPE_STOP_MARKET (bi-
disable_fast_withdraw_switch() (bi- nance.client.BaseClient attribute),95
nance.client.Client method),109 FUTURE_ORDER_TYPE_TAKE_PROFIT (bi-
disable_isolated_margin_account() (bi- nance.client.BaseClient attribute),95
nance.client.AsyncClient method),61 FUTURE_ORDER_TYPE_TAKE_PROFIT_MARKET
disable_isolated_margin_account() (bi- (binance.client.BaseClient attribute),95
nance.client.Client method),109 futures_account() (binance.client.AsyncClient
DSTREAM_TESTNET_URL (bi- method)61
nance.streams.BinanceSocketManager at-futures_account()(binance.client.Client method)
tribute)192 111
DSTREAM_URL(binance.streams.BinanceSocketManagerfutures_account_balance() (bi-
attribute)193nance.client.AsyncClient method),61
futures_account_balance() (bi-
E nance.client.Client method),111
enable_fast_withdraw_switch() (bi- futures_account_trades() (bi-
nance.client.AsyncClient method),61 nance.client.AsyncClient method)61
enable_fast_withdraw_switch() (bi- futures_account_trades() (bi-
nance.client.Client method),110 nance.client.Client method),111
enable_isolated_margin_account() (bi- futures_account_transfer() (bi-
nance.client.AsyncClient method),61 nance.client.AsyncClient method),61
enable_isolated_margin_account() (bi- futures_account_transfer() (bi-
nance.client.Client method)110 nance.client.Client method),111
enable_subaccount_futures() (bi- futures_adl_quantile_estimate() bi-
nance.client.AsyncClient method),61 nance.client.AsyncClient method),61
enable_subaccount_futures() (bi- futures_adl_quantile_estimate() (bi-
nance.client.Client method),110 nance.client.Client method)111
enable_subaccount_margin() (bi- futures_aggregate_trades() (bi-
nance.client.AsyncClient method),61 nance.client.AsyncClient method),61
enable_subaccount_margin() (bi- futures_aggregate_trades() (bi-
nance.client.Client method),110 nance.client.Client method)111
EXITING(binance.streams.WSListenerState attribute) FUTURES_API_VERSION(binance.client.BaseClient
205 attribute),95
FUTURES_API_VERSION2(binance.client.BaseClient
F attribute),95
FIAT_TO_MINING(binance.client.BaseClient at- futures_cancel_all_open_orders() (bi-
tribute)95 nance.client.AsyncClient method)61
FIAT_TO_SPOT(binance.client.BaseClient attribute) futures_cancel_all_open_orders() (bi-
95 nance.client.Client method),111
FIAT_TO_USDT_FUTURE(binance.client.BaseClient futures_cancel_order() (bi-
attribute)95 nance.client.AsyncClient method),61
FSTREAM_TESTNET_URL (bi- futures_cancel_order()(binance.client.Client
nance.streams.BinanceSocketManager at method),111
tribute193 futures_cancel_orders() (bi-
FSTREAM_URL(binance.streams.BinanceSocketManager nance.client.AsyncClient method)61
attribute)193 futures_cancel_orders()(binance.client.Client
FUTURE_ORDER_TYPE_LIMIT (bi- method)111
nance.client.BaseClient attribute),95 futures_change_leverage() (bi-
FUTURE_ORDER_TYPE_LIMIT_MAKER (bi- nance.client.AsyncClient method),61
nance.client.BaseClient attribute),95 futures_change_leverage() (bi-
nance.client.Client method),111

Index 211
python-binance Documentation, Release 0.2.0

futures_change_margin_type() (bi-futures_coin_change_position_margin()
nance.client.AsyncClient method),61 (binance.client.Client method)112
futures_change_margin_type() (bi-futures_coin_change_position_mode()(bi-
nance.client.Client method),111 nance.client.AsyncClient method),61
futures_change_multi_assets_mode() futures_coin_change_position_mode()(bi-
(binance.client.AsyncClient method)61 nance.client.Client method),113
futures_change_multi_assets_mode() futures_coin_continuous_klines()
(binance.client.Client method)112 nance.client.AsyncClient method),61
futures_change_position_margin() (bi-futures_coin_continous_klines() (bi-
nance.client.AsyncClient method)61 nance.client.Client method),113
futures_change_position_margin() (bi-futures_coin_create_order() (bi-
nance.client.Client method),112 nance.client.AsyncClient method),62
futures_change_position_mode() (bi-futures_coin_create_order() (bi-
nance.client.AsyncClient method),61 nance.client.Client method)113
futures_change_position_mode() (bi-FUTURES_COIN_DATA_TESTNET_URL bi-
nance.client.Client method),112 nance.client.BaseClient attribute),95
futures_coin_account() (bi-FUTURES_COIN_DATA_URL (bi-
nance.client.AsyncClient method),61 nance.client.BaseClient attribute),95
futures_coin_account()(binance.client.Clientfutures_coin_exchange_info() (bi-
method)112 nance.client.AsyncClient method)62
futures_coin_account_balance() bi-futures_coin_exchange_info() (bi-
nance.client.AsyncClient method),61 nance.client.Client method)113
futures_coin_account_balance() (bi-futures_coin_funding_rate() (bi-
nance.client.Client method)112 nance.client.AsyncClient method)62
futures_coin_account_trades() (bi-futures_coin_funding_rate() (bi-
nance.client.AsyncClient method),61 nance.client.Client method),113
futures_coin_account_trades() (bi-futures_coin_get_all_orders() (bi-
nance.client.Client method),112 nance.client.AsyncClient method)62
futures_coin_aggregate_trades() (bi-futures_coin_get_all_orders() (bi-
nance.client.AsyncClient method)61 nance.client.Client method),113
futures_coin_aggregate_trades() (bi-futures_coin_get_open_orders() (bi-
nance.client.Client method),112 nance.client.AsyncClient method),62
futures_coin_cancel_all_open_orders() futures_coin_get_open_orders() (bi-
AsyncClient method of binance.client61 nance.client.Client method),113
futures_coin_cancel_all_open_orders() futures_coin_get_order() (bi-
(binance.client.Client method)112 nance.client.AsyncClient method),62
futures_coin_cancel_order() bi-futures_coin_get_order() (bi-
nance.client.AsyncClient method),61 nance.client.Client method),113
futures_coin_cancel_order() (bi-futures_coin_get_position_mode() (bi-
nance.client.Client method),112 nance.client.AsyncClient method),62
futures_coin_cancel_orders() bi-futures_coin_get_position_mode() (two-
nance.client.AsyncClient method),61 nance.client.Client method)113
futures_coin_cancel_orders() (bi-futures_coin_historical_trades() (bi-
nance.client.Client method)112 nance.client.AsyncClient method),62
futures_coin_change_leverage() (bi-futures_coin_historical_trades() (bi-
nance.client.AsyncClient method),61 nance.client.Client method),113
futures_coin_change_leverage() (bi-futures_coin_income_history() (bi-
nance.client.Client method),112 nance.client.AsyncClient method),62
futures_coin_change_margin_type() (bi-futures_coin_income_history() (bi-
nance.client.AsyncClient method),61 nance.client.Client method),113
futures_coin_change_margin_type() (bi-futures_coin_index_price_klines() (bi-
nance.client.Client method),112 nance.client.AsyncClient method),62
futures_coin_change_position_margin() futures_coin_index_price_klines()
(binance.client.AsyncClient method)61 nance.client.Client method),113

212 Index
python-binance Documentation, Release 0.2.0

futures_coin_klines() (bi-futures_coin_recent_trades()
nance.client.AsyncClient method),62 nance.client.Client method),114
futures_coin_klines() (binance.client.Clientfutures_coin_stream_close() (bi-
method)113 nance.client.AsyncClient method),62
futures_coin_leverage_bracket() (bi-futures_coin_stream_close() (bi-
nance.client.AsyncClient method)62 nance.client.Client method),115
futures_coin_leverage_bracket() (bi-futures_coin_stream_get_listen_key()
nance.client.Client method),114 (binance.client.AsyncClient method)62
futures_coin_liquidation_orders() (bi-futures_coin_stream_get_listen_key()
nance.client.AsyncClient method),62 (binance.client.Client method)115
futures_coin_liquidation_orders() (bi-futures_coin_stream_keepalive()
nance.client.Client method)114 nance.client.AsyncClient method),62
futures_coin_mark_price() (bi-futures_coin_stream_keepalive() (bi-
nance.client.AsyncClient method),62 nance.client.Client method),115
futures_coin_mark_price() bi-futures_coin_symbol_ticker() (bi-
nance.client.Client method),114 nance.client.AsyncClient method),62
futures_coin_mark_price_klines() (bi-futures_coin_symbol_ticker() (bi-
nance.client.AsyncClient method),62 nance.client.Client method)115
futures_coin_mark_price_klines() (bi-FUTURES_COIN_TESTNET_URL (bi-
nance.client.Client method),114 nance.client.BaseClient attribute),95
futures_coin_open_interest() (bi-futures_coin_ticker() (bi-
nance.client.AsyncClient method),62 nance.client.AsyncClient method)62
futures_coin_open_interest() (bi-futures_coin_ticker() (binance.client.Client
nance.client.Client method),114 method)115
futures_coin_open_interest_hist()
nance.client.AsyncClient method),62
futures_coin_open_interest_hist()
nance.client.Client method),114
futures_coin_order_book()
nance.client.AsyncClient method),62
futures_coin_order_book()
nance.client.Client method),114
futures_coin_orderbook_ticker()
nance.client.AsyncClient method),62
futures_coin_orderbook_ticker()
nance.client.Client method),114
futures_coin_ping()(binance.client.AsyncClientfutures_create_order()(binance.client.Client
method),62 method),115
futures_coin_ping() (binance.client.ClientFUTURES_DATA_TESTNET_URL (bi-
method),114 nance.client.BaseClient attribute),95
futures_coin_place_batch_order() (bi-FUTURES_DATA_URL(binance.client.BaseClient at-
nance.client.AsyncClient method)62 tribute),95
futures_coin_place_batch_order() (bi-futures_depth_socket() bi-
nance.client.Client method),114 nance.streams.BinanceSocketManager
futures_coin_position_information() method)196
nance.client.AsyncClient method),62 futures_exchange_info() (bi-
futures_coin_position_information()( nance.client.AsyncClient method),62
nance.client.Client method)114 futures_exchange_info()(binance.client.Client
futures_coin_position_margin_history() method)115
(binance.client.AsyncClient method)62 futures_funding_rate() (bi-
futures_coin_position_margin_history() nance.client.AsyncClient method),62
(binance.client.Client method)114 futures_funding_rate()(binance.client.Client
futures_coin_recent_trades() (bi- method),115
nance.client.AsyncClient method),62 futures_get_all_orders() (bi-

Index 213
python-binance Documentation, Release 0.2.0

nance.client.AsyncClient method),62 method)117


futures_get_all_orders() (bi-futures_multiplex_socket() (bi-
nance.client.Client method),115 nance.streams.BinanceSocketManager
futures_get_multi_assets_mode() (bi- method)196
nance.client.AsyncClient method),62 futures_open_interest() (bi-
futures_get_multi_assets_mode() (bi- nance.client.AsyncClient method),63
nance.client.Client method),115 The provided text seems to be a code snippet or a function call and not a translatable text.

futures_get_open_orders() (bi- method)117


nance.client.AsyncClient method),63 futures_open_interest_hist() (bi-
futures_get_open_orders() (bi- nance.client.AsyncClient method),63
nance.client.Client method),115 futures_open_interest_hist() (bi-
futures_get_order()(binance.client.AsyncClient nance.client.Client method)117
method),63 futures_order_book() (bi-
futures_get_order() binance.client.Client nance.client.AsyncClient method),63
method),115 futures_order_book() (binance.client.Client
futures_get_position_mode() (bi- method)117
nance.client.AsyncClient method),63 futures_orderbook_ticker() (bi-
futures_get_position_mode() (bi- nance.client.AsyncClient method),63
nance.client.Client method),115 futures_orderbook_ticker() (bi-
futures_global_longshort_ratio() (bi- nance.client.Client method)117
nance.client.AsyncClient method),63 futures_ping() (binance.client.AsyncClient
futures_global_longshort_ratio() (bi- method),63
nance.client.Client method),116 futures_ping()(binance.client.Client method)117
futures_historical_klines() (bi-futures_place_batch_order() (bi-
nance.client.AsyncClient method)}63 nance.client.AsyncClient method)63
futures_historical_klines() (bi-futures_place_batch_order() (bi-
nance.client.Client method),116 nance.client.Client method)117
futures_historical_klines_generator() futures_position_information() (bi-
(binance.client.AsyncClient method)63 nance.client.AsyncClient method),63
futures_historical_klines_generator() futures_position_information() (bi-
(binance.client.Client method)116 nance.client.Client method),117
futures_historical_trades() (bi-futures_position_margin_history() (bi-
nance.client.AsyncClient method),63 nance.client.AsyncClient method,63
futures_historical_trades() bi-futures_position_margin_history() (bi-
nance.client.Client method),116 nance.client.Client method),117
futures_income_history() (bi-futures_recent_trades() (bi-
nance.client.AsyncClient method),63 nance.client.AsyncClient method),63
futures_income_history() (bi-futures_recent_trades()(binance.client.Client
nance.client.Client method),116 method)117
futures_klines() (binance.client.AsyncClientfutures_socket() (bi-
method),63 nance.streams.BinanceSocketManager
futures_klines()(binance.client.Client method) method),196
116 futures_stream_close() (bi-
futures_leverage_bracket() (bi- nance.client.AsyncClient method),63
nance.client.AsyncClient method),63 futures_stream_close()(binance.client.Client
futures_leverage_bracket() bi- method)117
nance.client.Client method),116 futures_stream_get_listen_key() (bi-
futures_liquidation_orders() (bi- nance.client.AsyncClient method),63
nance.client.AsyncClient method),63 futures_stream_get_listen_key() bi-
futures_liquidation_orders (bi- nance.client.Client method),117
nance.client.Client method)116 futures_stream_keepalive()
futures_mark_price() (bi- nance.client.AsyncClient method)63
nance.client.AsyncClient method),63 futures_stream_keepalive() (bi-
futures_mark_price() binance.client.Client nance.client.Client method),117

214 Index
python-binance Documentation, Release 0.2.0

futures_symbol_ticker() (bi-get_all_coins_info() (binance.client.Client


nance.client.AsyncClient method),63 method)123
futures_symbol_ticker()(binance.client.Clientget_all_isolated_margin_symbols() (bi-
method)117nance.client.AsyncClient method,66
FUTURES_TESTNET_URL(binance.client.BaseClientget_all_isolated_margin_symbols() (bi-
attribute)95 nance.client.Client method)124
futures_ticker() Invalid input (bi-
method),63 nance.client.AsyncClient method)66
futures_ticker()(binance.client.Client method),get_all_margin_orders()(binance.client.Client
118 method)124
futures_time() (binance.client.AsyncClientget_all_orders() binance.client.AsyncClient
method)63 method)66
futures_time()(binance.client.Client method),118get_all_orders()(binance.client.Client method)
futures_top_longshort_account_ratio() 125
(binance.client.AsyncClient method)63 get_all_tickers() (binance.client.AsyncClient
futures_top_longshort_account_ratio() method),67
(binance.client.Client method)118 get_all_tickers()(binance.client.Client method)
futures_top_longshort_position_ratio() 126
(binance.client.AsyncClient method)63 get_asks() (binance.depthcache.DepthCache
futures_top_longshort_position_ratio() method),189
(binance.client.Client method)118 get_asset_balance()(binance.client.AsyncClient
FUTURES_URL (binance.client.BaseClient attribute)95 method)67
futures_user_socket() (bi-get_asset_balance() (binance.client.Client
nance.streams.BinanceSocketManager method)126
method),196
FuturesDepthCacheManager(class in bi-
nance.depthcache),190
method)127
G get_asset_dividend_history() (bi-
get_account()(binance.client.AsyncClient method) nance.client.AsyncClient method)68
63 get_asset_dividend_history() (bi-
get_account()(binance.client.Client method)118 nance.client.Client method),127
get_account_api_permissions() (bi- get_avg_price() (binance.client.AsyncClient
nance.client.AsyncClient method),64 method)69
get_account_api_permissions() (bi- get_avg_price()(binance.client.Client method),
nance.client.Client method),118 128
get_account_api_trading_status() (bi- get_bids() binance.depthcache.DepthCache
nance.client.AsyncClient method),64 method)189
get_account_api_trading_status() (bi- get_bnb_burn_spot_margin() (bi-
nance.client.Client method),119 nance.client.AsyncClient method),69
get_account_snapshot() (bi- get_bnb_burn_spot_margin() (bi-
nance.client.AsyncClient method),66 nance.client.Client method,128
get_account_snapshot()(binance.client.Client get_c2c_trade_history() (bi-
method),120 nance.client.AsyncClient method)69
get_account_status() (bi- get_c2c_trade_history()(binance.client.Client
nance.client.AsyncClient method),66 method)128
get_account_status() (binance.client.Client get_cross_margin_data() (bi-
method)122 nance.client.AsyncClient method),69
get_aggregate_trades() (bi- get_cross_margin_data()(binance.client.Client
nance.client.AsyncClient method),66 method),129
get_aggregate_trades()(binance.client.Client get_deposit_address() (bi-
method),122 nance.client.AsyncClient method),69
get_all_coins_info() (bi- get_deposit_address() (binance.client.Client
nance.client.AsyncClient method),66 method)129

Index 215
python-binance Documentation, Release 0.2.0

get_deposit_history() (bi-get_klines()(binance.client.Client method),139


nance.client.AsyncClient method),70 get_lending_account()(bi-
get_deposit_history() (binance.client.Client nance.client.AsyncClient method75
method)130 get_lending_account() binance.client.Client
get_depth_cache() (bi- method),140
nance.depthcache.BaseDepthCacheManager get_lending_daily_quota_left() (bi-
method),188 nance.client.AsyncClient method)75
get_dust_assets() Invalid function call (bi-
method)71 nance.client.Client method),140
get_dust_assets() (binance.client.Client method)
130 (binance.client.AsyncClient method)75
get_dust_log() Invalid input.
method)71 (binance.client.Client method)140
get_dust_log()(binance.client.Client method),131get_lending_interest_history() (bi-
get_exchange_info()(binance.client.AsyncClient nance.client.AsyncClient method),75
method),72 get_lending_interest_history() (bi-
get_exchange_info() (binance.client.Client nance.client.Client method)140
method),132 get_lending_position() (bi-
get_fiat_deposit_withdraw_history() nance.client.AsyncClient method)75
nance.client.AsyncClient method),73 get_lending_position()(binance.client.Client
get_fiat_deposit_withdraw_history() method)140
nance.client.Client method),133 get_lending_product_list() (bi-
get_fiat_payments_history() (bi- nance.client.AsyncClient method)76
nance.client.AsyncClient method),73 get_lending_product_list() (bi-
get_fiat_payments_history() (bi- nance.client.Client method)140
nance.client.Client method),133 get_lending_purchase_history() (bi-
get_fixed_activity_project_list() (bi- nance.client.AsyncClient method),76
nance.client.AsyncClient method),73 get_lending_purchase_history() bi-
get_fixed_activity_project_list() (bi- nance.client.Client method),140
nance.client.Client method),134 get_lending_redemption_history() (bi-
get_historical_klines() (bi- nance.client.AsyncClient method)76
nance.client.AsyncClient method),73 get_lending_redemption_history() (bi-
get_historical_klines()(binance.client.Client nance.client.Client method),140
method)134 get_margin_account() (bi-
get_historical_klines_generator() (bi-
nance.client.AsyncClient method),74
get_historical_klines_generator() (bi-
nance.client.Client method),135 (bi-
get_historical_trades() (bi-
nance.client.AsyncClient method)74 get_margin_all_assets()(binance.client.Client
get_historical_trades()(binance.client.Client method)141
method)135 get_margin_all_pairs() (bi-
get_isolated_margin_account() (bi- nance.client.AsyncClient method),77
nance.client.AsyncClient method)75 get_margin_all_pairs()(binance.client.Client
get_isolated_margin_account() (bi- method),142
nance.client.Client method),136 get_margin_asset()(binance.client.AsyncClient
get_isolated_margin_symbol() (bi- method),77
nance.client.AsyncClient method)75 get_margin_asset() (binance.client.Client
get_isolated_margin_symbol() (bi- method),142
nance.client.Client method),137 get_margin_force_liquidation_rec()
get_isolated_margin_transfer_history() (binance.client.AsyncClient method)77
(binance.client.Client method)138 get_margin_force_liquidation_rec()
get_klines()(binance.client.AsyncClient method) (binance.client.Client method),143
75 get_margin_interest_history() (bi-

216 Index
python-binance Documentation, Release 0.2.0

nance.client.AsyncClient method),77 151


get_margin_interest_history() (bi-get_order()(binance.client.AsyncClient method),78
nance.client.Client method),143 get_order()(binance.client.Client method),151
get_margin_loan_details() (bi-get_order_book() (binance.client.AsyncClient
nance.client.AsyncClient method),77 method)79
get_margin_loan_details() (bi-get_order_book()(binance.client.Client method),
nance.client.Client method),144 152
get_margin_oco_order() (bi-get_orderbook_ticker() (bi-
nance.client.AsyncClient method),77 nance.client.AsyncClient method),79
get_margin_oco_order()(binance.client.Clientget_orderbook_ticker()(binance.client.Client
method),145method)152
get_margin_order()(binance.client.AsyncClientget_orderbook_tickers() (bi-
method)77 nance.client.AsyncClient method,80
get_margin_order() binance.client.Clientget_orderbook_tickers()(binance.client.Client
method)145 method)153
get_margin_price_index() (bi-get_products() (binance.client.AsyncClient
nance.client.AsyncClient method77 method)80
get_margin_price_index() (bi-get_products()(binance.client.Client method),153
nance.client.Client method),146 get_recent_trades()(binance.client.AsyncClient
get_margin_repay_details() (bi- method),80
nance.client.AsyncClient method)77 get_recent_trades() (binance.client.Client
get_margin_repay_details() (bi- method),154
nance.client.Client method),146 get_server_time() binance.client.AsyncClient
get_margin_symbol()(binance.client.AsyncClient method)81
method),77 get_server_time()(binance.client.Client method)
get_margin_symbol() (binance.client.Client 154
method)147 get_sub_account_assets() (bi-
get_margin_trades()(binance.client.AsyncClient nance.client.AsyncClient method),81
method)77 get_sub_account_assets() (bi-
get_margin_trades() binance.client.Client nance.client.Client method),154
method)147 get_sub_account_futures_transfer_history()
get_max_margin_loan() (bi- (binance.client.AsyncClient method)81
nance.client.AsyncClient method),77 get_sub_account_futures_transfer_history()
get_max_margin_loan() (binance.client.Client (binance.client.Client method)155
method),148 get_sub_account_list() (bi-
get_max_margin_transfer() nance.client.AsyncClient method),81
nance.client.AsyncClient method),77 get_sub_account_list()(binance.client.Client
get_max_margin_transfer() (bi- method),156
nance.client.Client method)148 get_sub_account_transfer_history()
get_my_trades() (binance.client.AsyncClient (binance.client.AsyncClient method)81
method),77 get_sub_account_transfer_history()
get_my_trades()(binance.client.Client method) (binance.client.Client method)156
148 get_subaccount_deposit_address() (bi-
get_open_margin_oco_orders() (bi- nance.client.AsyncClient method),81
nance.client.AsyncClient method),77 get_subaccount_deposit_address() (twice-
get_open_margin_oco_orders() bi- nance.client.Client method)157
nance.client.Client method),149 get_subaccount_deposit_history() (bi-
get_open_margin_orders() (bi- nance.client.AsyncClient method),81
nance.client.AsyncClient method),77 get_subaccount_deposit_history() (bi-
get_open_margin_orders() (bi- nance.client.Client method)157
nance.client.Client method)150 get_subaccount_futures_details() (bi-
get_open_orders() (binance.client.AsyncClient nance.client.AsyncClient method)81
method)77 get_subaccount_futures_details() (bi-
get_open_orders()(binance.client.Client method) nance.client.Client method),158

Index 217
python-binance Documentation, Release 0.2.0

get_subaccount_futures_margin_status() nance.client.AsyncClient method),85


(binance.client.AsyncClient method)81 get_withdraw_history_id() (bi-
get_subaccount_futures_margin_status() nance.client.Client method)168
(binance.client.Client method)159
get_subaccount_futures_positionrisk() I
(binance.client.AsyncClient method)81 index_price_socket() (bi-
get_subaccount_futures_positionrisk() nance.streams.BinanceSocketManager
(binance.client.Client method),160 method),196
get_subaccount_futures_summary() (bi- individual_symbol_ticker_futures_socket()
nance.client.AsyncClient method),81 binance.streams.BinanceSocketManager
get_subaccount_futures_summary() (bi- method),197
nance.client.Client method),160 INITIALISING(binance.streams.WSListenerState at-
get_subaccount_margin_details() (bi- tribute)205
nance.client.AsyncClient method),81 interval_to_milliseconds()(in module bi-
get_subaccount_margin_details() (bi- nance.helpers)192
nance.client.Client method),161 isolated_margin_socket() (bi-
get_subaccount_margin_summary() (bi- nance.streams.BinanceSocketManager
nance.client.AsyncClient method),81 method),197
get_subaccount_margin_summary() (bi- isolated_margin_stream_close() (bi-
nance.client.Client method),162 nance.client.AsyncClient method),86
get_subaccount_transfer_history() (bi- isolated_margin_stream_close() (bi-
nance.client.AsyncClient method),81 nance.client.Client method),168
get_subaccount_transfer_history() (bi- isolated_margin_stream_get_listen_key()
nance.client.Client method),163 (binance.client.AsyncClient method)86
get_symbol()(binance.depthcache.BaseDepthCacheManagerisolated_margin_stream_get_listen_key()
method)188 (binance.client.Client method)169
get_symbol_info() (binance.client.AsyncClient isolated_margin_stream_keepalive()
method),81 (binance.client.AsyncClient method)86
get_symbol_info()(binance.client.Client метод) isolated_margin_stream_keepalive()
163 (binance.client.Client method)169
get_symbol_ticker()(binance.client.AsyncClient
method),82 K
get_symbol_ticker() (binance.client.Client KeepAliveWebsocket(class in binance.streams)
method)164 203
get_system_status()(binance.client.AsyncClient kline_futures_socket() bi-
method)83 nance.streams.BinanceSocketManager
get_system_status() (binance.client.Client method),197
method)164 KLINE_INTERVAL_12HOUR (bi-
get_ticker()(binance.client.AsyncClient method) nance.client.BaseClient attribute),95
83 KLINE_INTERVAL_15MINUTE (bi-
get_ticker()(binance.client.Client method),165 nance.client.BaseClient attribute)95
get_trade_fee() (binance.client.AsyncClient KLINE_INTERVAL_1DAY(binance.client.BaseClient
method)84 attribute),95
get_trade_fee()(binance.client.Client method) KLINE_INTERVAL_1HOUR(binance.client.BaseClient
166 attribute)95
get_universal_transfer_history() (bi- KLINE_INTERVAL_1MINUTE (bi-
nance.client.AsyncClient method,84 nance.client.BaseClient attribute),95
get_universal_transfer_history() (bi- KLINE_INTERVAL_1MONTH (bi-
nance.client.Client method),166 nance.client.BaseClient attribute),95
get_withdraw_history() (bi- KLINE_INTERVAL_1WEEK(binance.client.BaseClient
nance.client.AsyncClient method)84 attribute),96
get_withdraw_history()(binance.client.Client KLINE_INTERVAL_2HOUR(binance.client.BaseClient
method),167 attribute)96
get_withdraw_history_id() bi-

218 Index
python-binance Documentation, Release 0.2.0

KLINE_INTERVAL_30MINUTE (bi-margin_stream_close() (bi-


nance.client.BaseClient attribute),96 nance.client.AsyncClient method)86
KLINE_INTERVAL_3DAY(binance.client.BaseClientmargin_stream_close() (binance.client.Client
attribute)96 method),172
KLINE_INTERVAL_3MINUTE (bi-margin_stream_get_listen_key() (bi-
nance.client.BaseClient attribute)96 nance.client.AsyncClient method),86
KLINE_INTERVAL_4HOUR(binance.client.BaseClientmargin_stream_get_listen_key() (bi-
attribute),96 nance.client.Client method)172
KLINE_INTERVAL_5MINUTE (bi-margin_stream_keepalive() (bi-
nance.client.BaseClient attribute),96 nance.client.AsyncClient method),86
KLINE_INTERVAL_6HOUR(binance.client.BaseClientmargin_stream_keepalive() (bi-
attribute),96nance.client.Client method),172
KLINE_INTERVAL_8HOUR(binance.client.BaseClientMAX_QUEUE_SIZE (bi-
attribute)96 nance.streams.ReconnectingWebsocket at-
kline_socket() (bi- tribute204
nance.streams.BinanceSocketManager MAX_RECONNECT_SECONDS (bi-
method)198 nance.streams.ReconnectingWebsocket at-
tribute),204
M MAX_RECONNECTS (bi-
make_subaccount_futures_transfer() nance.streams.ReconnectingWebsocket at-
(binance.client.AsyncClient method)86 tribute),204
make_subaccount_futures_transfer() MIN_RECONNECT_WAIT (bi-
(binance.client.Client method)169 nance.streams.ReconnectingWebsocket at
make_subaccount_margin_transfer() (bi- tribute),204
nance.client.AsyncClient method),86 MINING_TO_FIAT(binance.client.BaseClient at-
make_subaccount_margin_transfer() (bi- tribute)96
nance.client.Client method),170 MINING_TO_SPOT(binance.client.BaseClient at-
make_subaccount_to_master_transfer() tribute),96
(binance.client.AsyncClient method)86 MINING_TO_USDT_FUTURE (bi-
make_subaccount_to_master_transfer() nance.client.BaseClient attribute),96
(binance.client.Client method),170 miniticker_socket() (bi-
make_subaccount_to_subaccount_transfer() nance.streams.BinanceSocketManager
(binance.client.AsyncClient method)86 method)199
make_subaccount_to_subaccount_transfer() multiplex_socket() (bi-
(binance.client.Client method)170 nance.streams.BinanceSocketManager
make_subaccount_universal_transfer() method)199
(binance.client.AsyncClient method)86
make_subaccount_universal_transfer() N
(binance.client.Client method)171 new_transfer_history() (bi-
make_universal_transfer() (bi- nance.client.AsyncClient method)86
nance.client.AsyncClient method)86 new_transfer_history()(binance.client.Client
make_universal_transfer() (bi- method)172
nance.client.Client method),171 NO_MESSAGE_RECONNECT_TIMEOUT (bi-
MARGIN_API_URL(binance.client.BaseClient at- nance.streams.ReconnectingWebsocket at-
tribute),96 tribute)204
MARGIN_API_VERSION(binance.client.BaseClient at- NotImplementedException,192
tribute96
MARGIN_CROSS_TO_SPOT(binance.client.BaseClient O
attribute),96 OPTIONS(binance.streams.BinanceSocketType at-
MARGIN_CROSS_TO_USDT_FUTURE (bi- tribute)203
nance.client.BaseClient attribute),96 options_account_info() (bi-
margin_socket() (bi- nance.client.AsyncClient method),86
nance.streams.BinanceSocketManager options_account_info()(binance.client.Client
method),199 method)172

Index 219
python-binance Documentation, Release 0.2.0

OPTIONS_API_VERSION(binance.client.BaseClient nance.client.AsyncClient method)87


attribute),96 options_order_book()(binance.client.Client
options_bill() binance.client.AsyncClient method),174
method),86 options_ping() binance.client.AsyncClient
options_bill()(binance.client.Client method)173 method)87
options_cancel_all_orders() (bi-options_ping()(binance.client.Client method),175
nance.client.AsyncClient method)86 options_place_batch_order() (bi-
options_cancel_all_orders() (bi- nance.client.AsyncClient method)87
nance.client.Client method),173 options_place_batch_order() (bi-
options_cancel_batch_order() (bi- nance.client.Client method),175
nance.client.AsyncClient method),86 options_place_order() (bi-
options_cancel_batch_order() (bi- nance.client.AsyncClient method),87
nance.client.Client method),173 options_place_order() (binance.client.Client
options_cancel_order() (bi- method)175
nance.client.AsyncClient method),86 options_positions()(binance.client.AsyncClient
options_cancel_order()(binance.client.Client method)87
method)173 options_positions() binance.client.Client
options_depth_socket() (bi-method)175
nance.streams.BinanceSocketManager options_price() binance.client.AsyncClient
method),199 method),87
options_exchange_info() (bi-options_price()(binance.client.Client method),
nance.client.AsyncClient method),87 176
options_exchange_info()(binance.client.Clientoptions_query_order() (bi-
method),173 nance.client.AsyncClient method,87
options_funds_transfer() (bi-options_query_order() binance.client.Client
nance.client.AsyncClient method),87 method)176
options_funds_transfer() (bi-options_query_order_history() (bi-
nance.client.Client method),173 nance.client.AsyncClient method),87
options_historical_trades() (bi-options_query_order_history() (bi-
nance.client.AsyncClient method),87 nance.client.Client method),176
options_historical_trades() bi-options_query_pending_orders() (bi-
nance.client.Client method),174 nance.client.AsyncClient method),87
options index price() bi-options_query_pending_orders() (bi-
nance.client.AsyncClient method),87 nance.client.Client method),176
options_index_price() binance.client.Clientoptions_recent_trades() (bi-
method)174 nance.client.AsyncClient method),87
options_info() (binance.client.AsyncClientoptions_recent_trades()(binance.client.Client
method),87 method),176
options_info()(binance.client.Client method)174options_recent_trades_socket() (bi-
options_kline_socket() (bi- nance.streams.BinanceSocketManager
nance.streams.BinanceSocketManager method),200
method),200 binance.client.BaseClient
options_klines() binance.client.AsyncClient attribute),96
method)87 options_ticker_socket() (bi-
options_klines()(binance.client.Client method) nance.streams.BinanceSocketManager
174 method),200
options_mark_price() (bi-options_time() (binance.client.AsyncClient
nance.client.AsyncClient method),87 method)87
options_mark_price() (binance.client.Clientoptions_time()(binance.client.Client method),177
method)174 OPTIONS_URL(binance.client.BaseClient attribute)96
options_multiplex_socket() (bi-options_user_trades() (bi-
nance.streams.BinanceSocketManager nance.client.AsyncClient method),87
method),200 options_user_trades() (binance.client.Client
options_order_book() (bi- method)177

220 Index
python-binance Documentation, Release 0.2.0

OptionsDepthCacheManager(class in bi- ORDER_TYPE_LIMIT_MAKER (bi-


nance.depthcache),190nance.client.BaseClient attribute),96
order_limit()(binance.client.AsyncClient method), ORDER_TYPE_MARKET(binance.client.BaseClient at-
87 tribute)96
order_limit()(binance.client.Client method)177 ORDER_TYPE_STOP_LOSS
order_limit_buy() (binance.client.AsyncClient attribute)96
method)88 STOP LOSS LIMIT ORDER (bi-
order_limit_buy()(binance.client.Client method) nance.client.BaseClient attribute),96
178 Take Profit Order (bi-
order_limit_sell()(binance.client.AsyncClient nance.client.BaseClient attribute),96
method)88 Take Profit Limit Order (bi-
order_limit_sell() (binance.client.Client , (nance.client.BaseClient attribute)96
method)178
order_market() binance.client.AsyncClient P
method)89 ping() (binance.client.AsyncClient method)91
order_market()(binance.client.Client method)179 ping()(binance.client.Client method),181
order_market_buy()(binance.client.AsyncClient PRIVATE_API_VERSION(binance.client.BaseClient
method)89 attribute),97
order_market_buy() (binance.client.Client PUBLIC_API_VERSION(binance.client.BaseClient at-
method),179 tribute)97
order_market_sell()(binance.client.AsyncClient purchase lending product() (bi-
method),89 nance.client.AsyncClient method),91
order_market_sell() (binance.client.Client purchase_lending_product() (bi-
method)179 nance.client.Client method)181
order_oco_buy() (binance.client.AsyncClient
method)90 Q
order_oco_buy()(binance.client.Client method) (bi-
query_subaccount_spot_summary()
180 nance.client.AsyncClient method),91
order_oco_sell() binance.client.AsyncClient query_subaccount_spot_summary() (bi-
method),90 nance.client.Client method),182
order_oco_sell()(binance.client.Client method)
query_universal_transfer_history()
181 (binance.client.AsyncClient method)91
ORDER_RESP_TYPE_ACK(binance.client.BaseClient
query_universal_transfer_history()
attribute),96 (binance.client.Client method)182
ORDER_RESP_TYPE_FULL(binance.client.BaseClient
attribute)96 R
ORDER_RESP_TYPE_RESULT (bi-
random()(in module binance.streams),206
nance.client.BaseClient attribute)96
RECONNECTING(binance.streams.WSListenerState at-
Order Status Canceled (bi-
tribute)206
nance.client.BaseClient attribute),96
ReconnectingWebsocket (class in bi-
ORDER_STATUS_EXPIRED(binance.client.BaseClient
nance.streams),204
attribute)96
recv()(binance.depthcache.BaseDepthCacheManager
ORDER_STATUS_FILLED(binary.client.BaseClient
method),188
attribute)96
recv() (binance.streams.ReconnectingWebsocket
ORDER_STATUS_NEW(binance.client.BaseClient at-
method),204
tribute)96
redeem_lending_product() (bi-
ORDER_STATUS_PARTIALLY_FILLED (bi-
nance.client.AsyncClient method),92
nance.client.BaseClient attribute),96
redeem_lending_product() (bi-
ORDER_STATUS_PENDING_CANCEL (bi-
nance.client.Client method),183
nance.client.BaseClient attribute),96
repay_margin_loan()(binance.client.AsyncClient
ORDER STATUS REJECTED (bi-
method)92
nance.client.BaseClient attribute),96
repay_margin_loan() (binance.client.Client
ORDER_TYPE_LIMIT(binance.client.BaseClient at-
method)183
tribute),96

Index 221
python-binance Documentation, Release 0.2.0

REQUEST_TIMEOUT(binance.client.BaseClient at- method),205


tribute)97 start_futures_socket() (bi-
round_step_size()(in module binance.helpers), nance.streams.ThreadedWebsocketManager
192 method),205
start_futures_user_socket() (bi-
S nance.streams.ThreadedWebsocketManager
SIDE_BUY (attribute of binance.client.BaseClient)97 method)205
SIDE_SELL (binance.client.BaseClient attribute)97 start_index_price_socket() (bi-
sort_depth() (binance.depthcache.DepthCache nance.streams.ThreadedWebsocketManager
static method),190 method),205
SPOT(binance.streams.BinanceSocketType attribute) start_individual_symbol_ticker_futures_socket()
203 (binance.streams.ThreadedWebsocketManager
SPOT_TO_COIN_FUTURE(binance.client.BaseClient method),205
attribute),97 start_isolated_margin_socket() (bi-
SPOT_TO_FIAT(binance.client.BaseClient attribute) nance.streams.ThreadedWebsocketManager
97 method),205
SPOT_TO_MARGIN_CROSS(binance.client.BaseClient start_kline_futures_socket() (bi-
attribute)97 nance.streams.ThreadedWebsocketManager
SPOT_TO_MINING(binance.client.BaseClient at- method)205
tribute)97 start_kline_socket() (bi-
SPOT_TO_USDT_FUTURE(binance.client.BaseClient nance.streams.ThreadedWebsocketManager
attribute)97 method)205
start_aggtrade_futures_socket() (bi- start_margin_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method)205
start_aggtrade_socket() (bi- start_miniticker_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method)205
start_all_mark_price_socket() bi- start_multiplex_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method)205
start_all_ticker_futures_socket() (bi- start_options_depth_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.depthcache.ThreadedDepthCacheManager
method),204 method)191
start_book_ticker_socket() (bi- start_options_depth_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method),205
start_coin_futures_socket() (bi- start_options_kline_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method)205
start_depth_cache() (bi- start_options_multiplex_socket() (bi-
nance.depthcache.ThreadedDepthCacheManager nance.streams.ThreadedWebsocketManager
method),191 method)205
start_depth_socket() (bi- start_options_recent_trades_socket()
nance.streams.ThreadedWebsocketManager (binance.streams.ThreadedWebsocketManager
method),204 method)205
start_futures_depth_socket() (bi- start_options_ticker_socket() (bi-
nance.depthcache.ThreadedDepthCacheManager nance.streams.ThreadedWebsocketManager
method)191 method)205
start_futures_depth_socket() (bi- start_symbol_book_ticker_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager
method)204 method)205
start_futures_multiplex_socket() (bi- start_symbol_mark_price_socket() (bi-
nance.streams.ThreadedWebsocketManager nance.streams.ThreadedWebsocketManager

222 Index
python-binance Documentation, Release 0.2.0

method)205 T
start_symbol_miniticker_socket() bi- ThreadedDepthCacheManager(class in bi-
nance.streams.ThreadedWebsocketManager nance.depthcache),191
method)205 ThreadedWebsocketManager(class in bi-
start_symbol_ticker_futures_socket() nance.streams)204
binance.streams.ThreadedWebsocketManager ticker_socket() bi-
method),205 nance.streams.BinanceSocketManager
start_symbol_ticker_socket() (bi- method)202
nance.streams.ThreadedWebsocketManager TIME_IN_FORCE_FOK(binance.client.BaseClient at-
method)205 tribute97
start_ticker_socket() (bi- TIME_IN_FORCE_GTC(binance.client.BaseClient at-
nance.streams.ThreadedWebsocketManager tribute),97
method)205 TIME_IN_FORCE_IOC(binance.client.BaseClient at-
start_trade_socket() (bi- tribute97
nance.streams.ThreadedWebsocketManager TIMEOUT(binance.depthcache.BaseDepthCacheManager
method)205 attribute)188
start_user_socket() (bi- TIMEOUT(binance.streams.ReconnectingWebsocket at-
nance.streams.ThreadedWebsocketManager tribute204
method)205 toggle_bnb_burn_spot_margin() (bi-
stream_close() (binance.client.AsyncClient nance.client.AsyncClient method),93
method)92 toggle_bnb_burn_spot_margin() (bi-
stream_close()(binance.client.Client method),184 nance.client.Client method),184
stream_get_listen_key() trade_socket() (bi-
nance.client.AsyncClient method),92 nance.streams.BinanceSocketManager
stream_get_listen_key()(binance.client.Client method)203
method)184 transfer_dust() binance.client.AsyncClient
stream_keepalive()(binance.client.AsyncClient method)93
method),93 transfer_dust()(binance.client.Client method)
stream_keepalive() binance.client.Client 185
method),184 transfer_history()(binance.client.AsyncClient
STREAM_TESTNET_URL (bi- method),94
nance.streams.BinanceSocketManager at transfer_history() binance.client.Client
tribute)193 method),185
STREAM_URL(binance.streams.BinanceSocketManager transfer isolated margin to spot()
attribute),193 (binance.client.AsyncClient method)94
STREAMING(binance.streams.WSListenerState at- transfer isolated margin to spot()
tribute)206 (binance.client.Client method)185
symbol_book_ticker_socket() (bi- transfer_margin_to_spot() (bi-
nance.streams.BinanceSocketManager nance.client.AsyncClient method,94
method)200 transfer_margin_to_spot() (bi-
symbol_mark_price_socket() bi- nance.client.Client method),186
nance.streams.BinanceSocketManager transfer spot to isolated margin()
method),200 (binance.client.AsyncClient method)94
symbol_miniticker_socket() bi- transfer spot to isolated margin()
nance.streams.BinanceSocketManager (binance.client.Client method),186
method)201 transfer_spot_to_margin() (bi-
symbol_ticker_futures_socket() (bi- nance.client.AsyncClient method),94
nance.streams.BinanceSocketManager transfer_spot_to_margin() (bi-
method),201 nance.client.Client method187
symbol_ticker_socket() bi-
nance.streams.BinanceSocketManager U
method),201
universal_transfer() (bi-
SYMBOL_TYPE_SPOT(binance.client.BaseClient at-
nance.client.AsyncClient method),94
tribute)97

Index 223
python-binance Documentation, Release 0.2.0

universal_transfer() (binance.client.Client
method)187
USD_M_FUTURES(binance.streams.BinanceSocketType
attribute)203
USDT_FUTURE_TO_FIAT(binance.client.BaseClient
attribute)97
USDT_FUTURE_TO_MARGIN_CROSS
nance.client.BaseClient attribute),97
USDT_FUTURE_TO_SPOT(binance.client.BaseClient
attribute),97
user_socket() (bi-
nance.streams.BinanceSocketManager
method)203

V
VSTREAM_TESTNET_URL (bi-
nance.streams.BinanceSocketManager at-
tribute)193
VSTREAM_URL(binance.streams.BinanceSocketManager
attribute),193

W
WEBSITE_URL(binance.client.BaseClient attribute)97
WEBSOCKET_DEPTH_10 (bi-
nance.streams.BinanceSocketManager at
tribute)193
WEBSOCKET_DEPTH_20 (bi-
nance.streams.BinanceSocketManager at-
tribute)193
WEBSOCKET_DEPTH_5 (bi-
nance.streams.BinanceSocketManager at-
tribute),193
withdraw()(binance.client.AsyncClient method)94
withdraw()(binance.client.Client method)187
WSListenerState(class in binance.streams)205

224 Index

You might also like