unicorn_binance_rest_api package

Submodules

unicorn_binancerest_api.unicorn_binance_rest_api_enums module

unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions module

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceAPIException(response)

Bases: Exception

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException(code, message)

Bases: Exception

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderInactiveSymbolException(value)

Bases: unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderMinAmountException(value)

Bases: unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderMinPriceException(value)

Bases: unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderMinTotalException(value)

Bases: unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderUnknownSymbolException(value)

Bases: unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceOrderException

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceRequestException(message)

Bases: Exception

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.BinanceWithdrawException(message)

Bases: Exception

exception unicorn_binance_rest_api.unicorn_binance_rest_api_exceptions.UnknownExchange

Bases: Exception

Exception for if the manager class is started with an unkown exchange.

unicorn_binance_rest_api.unicorn_binance_rest_api_helpers module

unicorn_binance_rest_api.unicorn_binance_rest_api_helpers.date_to_milliseconds(date_str)

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 formats http://dateparser.readthedocs.io/en/latest/

Parameters

date_str (str) – date in readable format, i.e. “January 01, 2018”, “11 hours ago UTC”, “now UTC”

unicorn_binance_rest_api.unicorn_binance_rest_api_helpers.interval_to_milliseconds(interval)

Convert a Binance interval string to milliseconds

Parameters

interval (str) – 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

unicorn_binance_rest_api.unicorn_binance_rest_api_manager module

class unicorn_binance_rest_api.unicorn_binance_rest_api_manager.BinanceRestApiManager(api_key=None, api_secret=None, requests_params=None, tld=False, warn_on_update=True, exchange=False, disable_colorama=False, debug=False)

Bases: object

An unofficial Python API to use the Binance REST API`s (com+testnet, com-margin+testnet, com-isolated_margin+testnet, com-futures+testnet, us, jex) in a easy, fast, flexible, robust and fully-featured way.

Binance.com rest API documentation:
Binance.vision (Testnet) rest API documentation:
Binance.us rest API documentation:
TRBinance.com rest API documentation:
Jex.com websocket API documentation:

Binance API Client constructor

Parameters
  • api_key (str.) – Api Key

  • api_secret (str.) – Api Secret

  • requests_params (dict.) – optional - Dictionary of requests params to use for all calls

  • tld (str.) – Top Level Domain of the Binance endpoint, Default is False

  • warn_on_update (bool) – set to False to disable the update warning

  • exchange (str) – Select binance.com, binance.com-testnet, binance.com-margin, binance.com-margin-testnet, binance.com-isolated_margin, binance.com-isolated_margin-testnet, binance.com-futures, binance.com-futures-testnet, binance.com-coin-futures, binance.us, trbinance.com or jex.com (default: binance.com) This overules parameter tld.

  • disable_colorama (bool) – set to True to disable the use of colorama

AGG_BEST_MATCH = 'M'
AGG_BUYER_MAKES = 'm'
AGG_FIRST_TRADE_ID = 'f'
AGG_ID = 'a'
AGG_LAST_TRADE_ID = 'l'
AGG_PRICE = 'p'
AGG_QUANTITY = 'q'
AGG_TIME = 'T'
API_URL = 'https://api.binance.{}/api'
COIN_FUTURE_TO_SPOT = 'CMFUTURE_MAIN'
FIAT_TO_MINING = 'C2C_MINING'
FIAT_TO_SPOT = 'C2C_MAIN'
FIAT_TO_USDT_FUTURE = 'C2C_UMFUTURE'
FUTURES_API_VERSION = 'v1'
FUTURES_API_VERSION2 = 'v2'
FUTURES_COIN_DATA_URL = 'https://dapi.binance.{}/futures/data'
FUTURES_COIN_URL = 'https://fapi.binance.{}/fapi'
FUTURES_DATA_URL = 'https://fapi.binance.{}/futures/data'
FUTURES_URL = 'https://fapi.binance.{}/fapi'
KLINE_INTERVAL_12HOUR = '12h'
KLINE_INTERVAL_15MINUTE = '15m'
KLINE_INTERVAL_1DAY = '1d'
KLINE_INTERVAL_1HOUR = '1h'
KLINE_INTERVAL_1MINUTE = '1m'
KLINE_INTERVAL_1MONTH = '1M'
KLINE_INTERVAL_1WEEK = '1w'
KLINE_INTERVAL_2HOUR = '2h'
KLINE_INTERVAL_30MINUTE = '30m'
KLINE_INTERVAL_3DAY = '3d'
KLINE_INTERVAL_3MINUTE = '3m'
KLINE_INTERVAL_4HOUR = '4h'
KLINE_INTERVAL_5MINUTE = '5m'
KLINE_INTERVAL_6HOUR = '6h'
KLINE_INTERVAL_8HOUR = '8h'
MARGIN_API_URL = 'https://api.binance.{}/sapi'
MARGIN_API_VERSION = 'v1'
MARGIN_CROSS_TO_SPOT = 'MARGIN_MAIN'
MARGIN_CROSS_TO_USDT_FUTURE = 'MARGIN_UMFUTURE'
MINING_TO_FIAT = 'MINING_C2C'
MINING_TO_SPOT = 'MINING_MAIN'
MINING_TO_USDT_FUTURE = 'MINING_UMFUTURE'
ORDER_RESP_TYPE_ACK = 'ACK'
ORDER_RESP_TYPE_FULL = 'FULL'
ORDER_RESP_TYPE_RESULT = 'RESULT'
ORDER_STATUS_CANCELED = 'CANCELED'
ORDER_STATUS_EXPIRED = 'EXPIRED'
ORDER_STATUS_FILLED = 'FILLED'
ORDER_STATUS_NEW = 'NEW'
ORDER_STATUS_PARTIALLY_FILLED = 'PARTIALLY_FILLED'
ORDER_STATUS_PENDING_CANCEL = 'PENDING_CANCEL'
ORDER_STATUS_REJECTED = 'REJECTED'
ORDER_TYPE_LIMIT = 'LIMIT'
ORDER_TYPE_LIMIT_MAKER = 'LIMIT_MAKER'
ORDER_TYPE_MARKET = 'MARKET'
ORDER_TYPE_STOP_LOSS = 'STOP_LOSS'
ORDER_TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT'
ORDER_TYPE_TAKE_PROFIT = 'TAKE_PROFIT'
ORDER_TYPE_TAKE_PROFIT_LIMIT = 'TAKE_PROFIT_LIMIT'
PRIVATE_API_VERSION = 'v3'
PUBLIC_API_VERSION = 'v1'
SIDE_BUY = 'BUY'
SIDE_SELL = 'SELL'
SPOT_TO_COIN_FUTURE = 'MAIN_CMFUTURE'
SPOT_TO_FIAT = 'MAIN_C2C'
SPOT_TO_MARGIN_CROSS = 'MAIN_MARGIN'
SPOT_TO_MINING = 'MAIN_MINING'
SPOT_TO_USDT_FUTURE = 'MAIN_UMFUTURE'
SYMBOL_TYPE_SPOT = 'SPOT'
TIME_IN_FORCE_FOK = 'FOK'
TIME_IN_FORCE_GTC = 'GTC'
TIME_IN_FORCE_IOC = 'IOC'
USDT_FUTURE_TO_FIAT = 'UMFUTURE_C2C'
USDT_FUTURE_TO_MARGIN_CROSS = 'UMFUTURE_MARGIN'
USDT_FUTURE_TO_SPOT = 'UMFUTURE_MAIN'
WEBSITE_URL = 'https://www.binance.{}'
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 formats http://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
Returns

an iterator of JSON objects, one per trade. The format of each object is identical to Client.aggregate_trades().

cancel_all_open_orders(**params)

Cancel all open orders of a symbol.

https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#cancel-all-open-orders-on-a-symbol-trade

Parameters
  • symbol (str) – required

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

Returns

API response

[
  {
    "symbol": "BTCUSDT",
    "origClientOrderId": "E6APeyTJvkMvLMYMqu1KQ4",
    "orderId": 11,
    "orderListId": -1,
    "clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
    "price": "0.089853",
    "origQty": "0.178622",
    "executedQty": "0.000000",
    "cummulativeQuoteQty": "0.000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY"
  },
  {
    "symbol": "BTCUSDT",
    "origClientOrderId": "A3EF2HCwxgZPFMrfwbgrhv",
    "orderId": 13,
    "orderListId": -1,
    "clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
    "price": "0.090430",
    "origQty": "0.178622",
    "executedQty": "0.000000",
    "cummulativeQuoteQty": "0.000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY"
  },
  {
    "orderListId": 1929,
    "contingencyType": "OCO",
    "listStatusType": "ALL_DONE",
    "listOrderStatus": "ALL_DONE",
    "listClientOrderId": "2inzWQdDvZLHbbAmAozX2N",
    "transactionTime": 1585230948299,
    "symbol": "BTCUSDT",
    "orders": [
      {
        "symbol": "BTCUSDT",
        "orderId": 20,
        "clientOrderId": "CwOOIPHSmYywx6jZX77TdL"
      },
      {
        "symbol": "BTCUSDT",
        "orderId": 21,
        "clientOrderId": "461cPg51vQjV3zIMOXNz39"
      }
    ],
    "orderReports": [
      {
        "symbol": "BTCUSDT",
        "origClientOrderId": "CwOOIPHSmYywx6jZX77TdL",
        "orderId": 20,
        "orderListId": 1929,
        "clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
        "price": "0.668611",
        "origQty": "0.690354",
        "executedQty": "0.000000",
        "cummulativeQuoteQty": "0.000000",
        "status": "CANCELED",
        "timeInForce": "GTC",
        "type": "STOP_LOSS_LIMIT",
        "side": "BUY",
        "stopPrice": "0.378131",
        "icebergQty": "0.017083"
      },
      {
        "symbol": "BTCUSDT",
        "origClientOrderId": "461cPg51vQjV3zIMOXNz39",
        "orderId": 21,
        "orderListId": 1929,
        "clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
        "price": "0.008791",
        "origQty": "0.690354",
        "executedQty": "0.000000",
        "cummulativeQuoteQty": "0.000000",
        "status": "CANCELED",
        "timeInForce": "GTC",
        "type": "LIMIT_MAKER",
        "side": "BUY",
        "icebergQty": "0.639962"
      }
    ]
  }
]
Raises

BinanceRequestException, BinanceAPIException

cancel_margin_order(**params)

Cancel an active order for margin account.

Either orderId or origClientOrderId must be sent.

https://binance-docs.github.io/apidocs/spot/en/#margin-account-cancel-order-trade

Parameters
  • symbol (str) – required

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • orderId (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

{
    "symbol": "LTCBTC",
    "orderId": 28,
    "origClientOrderId": "myOrder1",
    "clientOrderId": "cancelMyOrder1",
    "transactTime": 1507725176595,
    "price": "1.00000000",
    "origQty": "10.00000000",
    "executedQty": "8.00000000",
    "cummulativeQuoteQty": "8.00000000",
    "status": "CANCELED",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "SELL"
}
Raises

BinanceRequestException, BinanceAPIException

cancel_order(**params)

Cancel an active order. Either orderId or origClientOrderId must be sent.

https://binance-docs.github.io/apidocs/spot/en/#cancel-order-trade

Parameters
  • symbol (str) – required

  • orderId (int) – The unique order id

  • origClientOrderId (str) – optional

  • 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

{
    "symbol": "LTCBTC",
    "origClientOrderId": "myOrder1",
    "orderId": 1,
    "clientOrderId": "cancelMyOrder1"
}
Raises

BinanceRequestException, BinanceAPIException

change_fixed_activity_to_daily_position(**params)

Change Fixed/Activity Position to Daily Position

https://binance-docs.github.io/apidocs/spot/en/#change-fixed-activity-position-to-daily-position-user_data

create_isolated_margin_account(**params)

Create isolated margin account for symbol

https://binance-docs.github.io/apidocs/spot/en/#create-isolated-margin-account-margin

Parameters
  • base (str) – Base asset of symbol

  • quote (str) – Quote asset of symbol

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

API response

{
    "success": true,
    "symbol": "BTCUSDT"
}
Raises

BinanceRequestException, BinanceAPIException

create_margin_loan(**params)

Apply for a loan in cross-margin or isolated-margin account.

https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin

Parameters
  • asset (str) – name of the asset

  • amount (str) – amount to transfer

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • symbol (str) – Isolated margin symbol (default blank for cross-margin)

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

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

transaction = client.margin_create_loan(asset='BTC', amount='1.1', 
                                        isIsolated='TRUE', symbol='ETHBTC')
Returns

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

create_margin_order(**params)

Post a new order for margin account.

https://binance-docs.github.io/apidocs/spot/en/#margin-account-new-order-trade

Parameters
  • symbol (str) – required

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • side (str) – required

  • type (str) – required

  • quantity (decimal) – required

  • price (str) – required

  • stopPrice (str) – Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.

  • timeInForce (str) – required if limit order GTC,IOC,FOK

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

  • icebergQty (str) – Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order.

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; MARKET and LIMIT order types default to FULL, all other orders default to ACK.

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

Returns

API response

Response ACK:

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

Response RESULT:

{
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "transactTime": 1507725176595,
    "price": "1.00000000",
    "origQty": "10.00000000",
    "executedQty": "10.00000000",
    "cummulativeQuoteQty": "10.00000000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "MARKET",
    "side": "SELL"
}

Response FULL:

{
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "transactTime": 1507725176595,
    "price": "1.00000000",
    "origQty": "10.00000000",
    "executedQty": "10.00000000",
    "cummulativeQuoteQty": "10.00000000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "MARKET",
    "side": "SELL",
    "fills": [
        {
            "price": "4000.00000000",
            "qty": "1.00000000",
            "commission": "4.00000000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3999.00000000",
            "qty": "5.00000000",
            "commission": "19.99500000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3998.00000000",
            "qty": "2.00000000",
            "commission": "7.99600000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3997.00000000",
            "qty": "1.00000000",
            "commission": "3.99700000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3995.00000000",
            "qty": "1.00000000",
            "commission": "3.99500000",
            "commissionAsset": "USDT"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_oco_order(**params)

Send in a new OCO order

https://binance-docs.github.io/apidocs/spot/en/#new-oco-trade

Parameters
  • symbol (str) – required

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

  • side (str) – required

  • quantity (decimal) – required

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

  • price (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.

  • stopPrice (str) – required

  • stopLimitPrice (str) – If provided, stopLimitTimeInForce is required.

  • stopIcebergQty (decimal) – Used with STOP_LOSS_LIMIT leg to make an iceberg order.

  • stopLimitTimeInForce (str) – 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

Returns

API response

Response ACK:

{
}

Response RESULT:

{
}

Response FULL:

{
}
Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_order(**params)

Send in a new order

Any order with an icebergQty MUST have timeInForce set to GTC.

https://binance-docs.github.io/apidocs/spot/en/#new-order–trade

Parameters
  • symbol (str) – required

  • side (str) – required

  • type (str) – required

  • timeInForce (str) – required if limit order

  • quantity (decimal) – required

  • quoteOrderQty (decimal) – amount the user wants to spend (when buying) or receive (when selling) of the quote asset, applicable to MARKET orders

  • price (str) – required

  • 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.

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

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

Returns

API response

Response ACK:

{
    "symbol":"LTCBTC",
    "orderId": 1,
    "clientOrderId": "myOrder1" # Will be newClientOrderId
    "transactTime": 1499827319559
}

Response RESULT:

{
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "transactTime": 1507725176595,
    "price": "0.00000000",
    "origQty": "10.00000000",
    "executedQty": "10.00000000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "MARKET",
    "side": "SELL"
}

Response FULL:

{
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "transactTime": 1507725176595,
    "price": "0.00000000",
    "origQty": "10.00000000",
    "executedQty": "10.00000000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "MARKET",
    "side": "SELL",
    "fills": [
        {
            "price": "4000.00000000",
            "qty": "1.00000000",
            "commission": "4.00000000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3999.00000000",
            "qty": "5.00000000",
            "commission": "19.99500000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3998.00000000",
            "qty": "2.00000000",
            "commission": "7.99600000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3997.00000000",
            "qty": "1.00000000",
            "commission": "3.99700000",
            "commissionAsset": "USDT"
        },
        {
            "price": "3995.00000000",
            "qty": "1.00000000",
            "commission": "3.99500000",
            "commissionAsset": "USDT"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

create_sub_account_futures_transfer(**params)

Execute sub-account Futures transfer

https://github.com/binance-exchange/binance-official-api-docs/blob/9dbe0e961b80557bb19708a707c7fad08842b28e/wapi-api.md#sub-account-transferfor-master-account

Parameters
  • fromEmail (str) – required - Sender email

  • toEmail (str) – required - Recipient email

  • futuresType (int) – required

  • asset (str) – required

  • amount (decimal) – required

  • recvWindow (int) – optional

Returns

API response

{
     "success":true,
     "txnId":"2934662589"
 }
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.

https://binance-docs.github.io/apidocs/spot/en/#test-new-order-trade

Parameters
  • symbol (str) – required

  • side (str) – required

  • type (str) – required

  • timeInForce (str) – required if limit order

  • quantity (decimal) – required

  • price (str) – required

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

  • icebergQty (decimal) – Used with iceberg orders

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

  • recvWindow (int) – The number of milliseconds the request is valid for

Returns

API response

{}
Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

disable_fast_withdraw_switch(**params)

Disable Fast Withdraw Switch

https://binance-docs.github.io/apidocs/spot/en/#disable-fast-withdraw-switch-user_data

Parameters

recvWindow (int) – optional

Returns

API response

Raises

BinanceRequestException, BinanceAPIException

enable_fast_withdraw_switch(**params)

Enable Fast Withdraw Switch

https://binance-docs.github.io/apidocs/spot/en/#enable-fast-withdraw-switch-user_data

Parameters

recvWindow (int) – optional

Returns

API response

Raises

BinanceRequestException, BinanceAPIException

enable_subaccount_futures(**params)

Enable Futures for Sub-account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#enable-futures-for-sub-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • recvWindow (int) – optional

Returns

API response

{

    "email":"123@test.com",

    "isFuturesEnabled": true  // true or false

}
Raises

BinanceRequestException, BinanceAPIException

enable_subaccount_margin(**params)

Enable Margin for Sub-account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#enable-margin-for-sub-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • recvWindow (int) – optional

Returns

API response

{

     "email":"123@test.com",

     "isMarginEnabled": true

 }
Raises

BinanceRequestException, BinanceAPIException

futures_account(**params)

Get current account information.

https://binance-docs.github.io/apidocs/futures/en/#account-information-user_data

futures_account_balance(**params)

Get futures account balance

https://binance-docs.github.io/apidocs/futures/en/#future-account-balance-user_data

futures_account_trades(**params)

Get trades for the authenticated account and symbol.

https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data

futures_account_transfer(**params)

Execute transfer between spot account and futures account.

https://binance-docs.github.io/apidocs/futures/en/#new-future-account-transfer

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.

https://binance-docs.github.io/apidocs/futures/en/#compressed-aggregate-trades-list-market_data

futures_cancel_all_open_orders(**params)

Cancel all open futures orders

https://binance-docs.github.io/apidocs/futures/en/#cancel-all-open-orders-trade

futures_cancel_order(**params)

Cancel an active futures order.

https://binance-docs.github.io/apidocs/futures/en/#cancel-order-trade

futures_cancel_orders(**params)

Cancel multiple futures orders

https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade

futures_change_leverage(**params)

Change user’s initial leverage of specific symbol market

https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade

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_position_margin(**params)

Change the position margin for a symbol

https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade

futures_change_position_mode(**params)

Change position mode for authenticated account

https://binance-docs.github.io/apidocs/futures/en/#change-position-mode-trade

futures_coin_account(**params)

Get current account information.

https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data

futures_coin_account_balance(**params)

Get futures account balance

https://binance-docs.github.io/apidocs/delivery/en/#futures-account-balance-user_data

futures_coin_account_trades(**params)

Get trades for the authenticated account and symbol.

https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data

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.

https://binance-docs.github.io/apidocs/delivery/en/#compressed-aggregate-trades-list

futures_coin_cancel_all_open_orders(**params)

Cancel all open futures orders

https://binance-docs.github.io/apidocs/delivery/en/#cancel-all-open-orders-trade

futures_coin_cancel_order(**params)

Cancel an active futures order.

https://binance-docs.github.io/apidocs/delivery/en/#cancel-order-trade

futures_coin_cancel_orders(**params)

Cancel multiple futures orders

https://binance-docs.github.io/apidocs/delivery/en/#cancel-multiple-orders-trade

futures_coin_change_leverage(**params)

Change user’s initial leverage of specific symbol market

https://binance-docs.github.io/apidocs/delivery/en/#change-initial-leverage-trade

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

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 user’s position mode (Hedge Mode or One-way Mode ) on EVERY symbol

https://binance-docs.github.io/apidocs/delivery/en/#change-position-mode-trade

futures_coin_continous_klines(**params)

Kline/candlestick bars for a specific contract type. Klines are uniquely identified by their open time.

https://binance-docs.github.io/apidocs/delivery/en/#continuous-contract-kline-candlestick-data

futures_coin_create_order(**params)

Send in a new order.

https://binance-docs.github.io/apidocs/delivery/en/#new-order-trade

futures_coin_exchange_info()

Current exchange trading rules and symbol information

https://binance-docs.github.io/apidocs/delivery/en/#exchange-information

futures_coin_funding_rate(**params)

Get funding rate history

https://binance-docs.github.io/apidocs/delivery/en/#get-funding-rate-history-of-perpetual-futures

futures_coin_get_all_orders(**params)

Get all futures account orders; active, canceled, or filled.

https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data

futures_coin_get_open_orders(**params)

Get all open orders on a symbol.

https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data

futures_coin_get_order(**params)

Check an order’s status.

https://binance-docs.github.io/apidocs/delivery/en/#query-order-user_data

futures_coin_get_position_mode(**params)

Get user’s position mode (Hedge Mode or One-way Mode ) on EVERY symbol

https://binance-docs.github.io/apidocs/delivery/en/#get-current-position-mode-user_data

futures_coin_historical_trades(**params)

Get older market historical trades.

https://binance-docs.github.io/apidocs/delivery/en/#old-trades-lookup-market_data

futures_coin_income_history(**params)

Get income history for authenticated account

https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data

futures_coin_index_price_klines(**params)

Kline/candlestick bars for the index price of a pair..

https://binance-docs.github.io/apidocs/delivery/en/#index-price-kline-candlestick-data

futures_coin_klines(**params)

Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data

futures_coin_leverage_bracket(**params)

Notional and Leverage Brackets

https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-pair-user_data

futures_coin_liquidation_orders(**params)

Get all liquidation orders

https://binance-docs.github.io/apidocs/delivery/en/#get-all-liquidation-orders

futures_coin_mark_price(**params)

Get Mark Price and Funding Rate

https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price

futures_coin_mark_price_klines(**params)

Kline/candlestick bars for the index price of a pair..

https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-data

futures_coin_open_interest(**params)

Get present open interest of a specific symbol.

https://binance-docs.github.io/apidocs/delivery/en/#open-interest

futures_coin_open_interest_hist(**params)

Get open interest statistics of a specific symbol.

https://binance-docs.github.io/apidocs/delivery/en/#open-interest-statistics-market-data

futures_coin_order_book(**params)

Get the Order Book for the market

https://binance-docs.github.io/apidocs/delivery/en/#order-book

futures_coin_orderbook_ticker(**params)

Best price/qty on the order book for a symbol or symbols.

https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker

futures_coin_ping()

Test connectivity to the Rest API

https://binance-docs.github.io/apidocs/delivery/en/#test-connectivity

futures_coin_place_batch_order(**params)

Send in new orders. https://binance-docs.github.io/apidocs/delivery/en/#place-multiple-orders-trade 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

https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data

futures_coin_position_margin_history(**params)

Get position margin change history

https://binance-docs.github.io/apidocs/delivery/en/#get-position-margin-change-history-trade

futures_coin_recent_trades(**params)

Get recent trades (up to last 500).

https://binance-docs.github.io/apidocs/delivery/en/#recent-trades-list

futures_coin_symbol_ticker(**params)

Latest price for a symbol or symbols.

https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker

futures_coin_ticker(**params)

24 hour rolling window price change statistics.

https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics

futures_coin_time()

Test connectivity to the Rest API and get the current server time.

https://binance-docs.github.io/apidocs/delivery/en/#check-server-time

futures_create_order(**params)

Send in a new order.

https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

futures_exchange_info()

Current exchange trading rules and symbol information

https://binance-docs.github.io/apidocs/futures/en/#exchange-information-market_data

futures_funding_rate(**params)

Get funding rate history

https://binance-docs.github.io/apidocs/futures/en/#get-funding-rate-history-market_data

futures_get_all_orders(**params)

Get all futures account orders; active, canceled, or filled.

https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data

futures_get_open_orders(**params)

Get all open orders on a symbol.

https://binance-docs.github.io/apidocs/futures/en/#current-open-orders-user_data

futures_get_order(**params)

Check an order’s status.

https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data

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_historical_trades(**params)

Get older market historical trades.

https://binance-docs.github.io/apidocs/futures/en/#old-trades-lookup-market_data

futures_income_history(**params)

Get income history for authenticated account

https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data

futures_klines(**params)

Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data-market_data

futures_leverage_bracket(**params)

Notional and Leverage Brackets

https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-market_data

futures_liquidation_orders(**params)

Get all liquidation orders

https://binance-docs.github.io/apidocs/futures/en/#get-all-liquidation-orders-market_data

futures_mark_price(**params)

Get Mark Price and Funding Rate

https://binance-docs.github.io/apidocs/futures/en/#mark-price-market_data

futures_open_interest(**params)

Get present open interest of a specific symbol.

https://binance-docs.github.io/apidocs/futures/en/#open-interest-market_data

futures_open_interest_hist(**params)

Get open interest statistics of a specific symbol.

https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics

futures_order_book(**params)

Get the Order Book for the market

https://binance-docs.github.io/apidocs/futures/en/#order-book-market_data

futures_orderbook_ticker(**params)

Best price/qty on the order book for a symbol or symbols.

https://binance-docs.github.io/apidocs/futures/en/#symbol-order-book-ticker-market_data

futures_ping()

Test connectivity to the Rest API

https://binance-docs.github.io/apidocs/futures/en/#test-connectivity

futures_position_information(**params)

Get position information

https://binance-docs.github.io/apidocs/futures/en/#position-information-user_data

futures_position_margin_history(**params)

Get position margin change history

https://binance-docs.github.io/apidocs/futures/en/#get-postion-margin-change-history-trade

futures_recent_trades(**params)

Get recent trades (up to last 500).

https://binance-docs.github.io/apidocs/futures/en/#recent-trades-list-market_data

futures_symbol_ticker(**params)

Latest price for a symbol or symbols.

https://binance-docs.github.io/apidocs/futures/en/#symbol-price-ticker-market_data

futures_ticker(**params)

24 hour rolling window price change statistics.

https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics-market_data

futures_time()

Test connectivity to the Rest API and get the current server time.

https://binance-docs.github.io/apidocs/futures/en/#check-server-time

get_account(**params)

Get current account information.

https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data

Parameters

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

Returns

API response

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

BinanceRequestException, BinanceAPIException

get_account_api_trading_status(**params)

Fetch account api trading status detail.

https://binance-docs.github.io/apidocs/spot/en/#account-api-trading-status-sapi-user_data

Parameters

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

Returns

API response

{
    "data": {          // API trading status detail
        "isLocked": false,   // API trading function is locked or not
        "plannedRecoverTime": 0,  // If API trading function is locked, this is the planned recover time
        "triggerCondition": {
                "GCR": 150,  // Number of GTC orders
                "IFER": 150, // Number of FOK/IOC orders
                "UFR": 300   // Number of orders
        },
        "indicators": {  // The indicators updated every 30 seconds
             "BTCUSDT": [  // The symbol
                {
                    "i": "UFR",  // Unfilled Ratio (UFR)
                    "c": 20,     // Count of all orders
                    "v": 0.05,   // Current UFR value
                    "t": 0.995   // Trigger UFR value
                },
                {
                    "i": "IFER", // IOC/FOK Expiration Ratio (IFER)
                    "c": 20,     // Count of FOK/IOC orders
                    "v": 0.99,   // Current IFER value
                    "t": 0.99    // Trigger IFER value
                },
                {
                    "i": "GCR",  // GTC Cancellation Ratio (GCR)
                    "c": 20,     // Count of GTC orders
                    "v": 0.99,   // Current GCR value
                    "t": 0.99    // Trigger GCR value
                }
            ],
            "ETHUSDT": [
                {
                    "i": "UFR",
                    "c": 20,
                    "v": 0.05,
                    "t": 0.995
                },
                {
                    "i": "IFER",
                    "c": 20,
                    "v": 0.99,
                    "t": 0.99
                },
                {
                    "i": "GCR",
                    "c": 20,
                    "v": 0.99,
                    "t": 0.99
                }
            ]
        },
        "updateTime": 1547630471725
    }
}
Raises

BinanceWithdrawException

get_account_snapshot(**params)

Get daily account snapshot of specific type.

https://binance-docs.github.io/apidocs/spot/en/#daily-account-snapshot-user_data

Parameters
  • type (string) – required. Valid values are SPOT/MARGIN/FUTURES.

  • startTime (int) – optional

  • endTime (int) – optional

  • limit (int) – optional

  • recvWindow (int) – optional

Returns

API response

{
   "code":200, // 200 for success; others are error codes
   "msg":"", // error message
   "snapshotVos":[
      {
         "data":{
            "balances":[
               {
                  "asset":"BTC",
                  "free":"0.09905021",
                  "locked":"0.00000000"
               },
               {
                  "asset":"USDT",
                  "free":"1.89109409",
                  "locked":"0.00000000"
               }
            ],
            "totalAssetOfBtc":"0.09942700"
         },
         "type":"spot",
         "updateTime":1576281599000
      }
   ]
}

OR

{
   "code":200, // 200 for success; others are error codes
   "msg":"", // error message
   "snapshotVos":[
      {
         "data":{
            "marginLevel":"2748.02909813",
            "totalAssetOfBtc":"0.00274803",
            "totalLiabilityOfBtc":"0.00000100",
            "totalNetAssetOfBtc":"0.00274750",
            "userAssets":[
               {
                  "asset":"XRP",
                  "borrowed":"0.00000000",
                  "free":"1.00000000",
                  "interest":"0.00000000",
                  "locked":"0.00000000",
                  "netAsset":"1.00000000"
               }
            ]
         },
         "type":"margin",
         "updateTime":1576281599000
      }
   ]
}

OR

{
   "code":200, // 200 for success; others are error codes
   "msg":"", // error message
   "snapshotVos":[
      {
         "data":{
            "assets":[
               {
                  "asset":"USDT",
                  "marginBalance":"118.99782335",
                  "walletBalance":"120.23811389"
               }
            ],
            "position":[
               {
                  "entryPrice":"7130.41000000",
                  "markPrice":"7257.66239673",
                  "positionAmt":"0.01000000",
                  "symbol":"BTCUSDT",
                  "unRealizedProfit":"1.24029054"
               }
            ]
         },
         "type":"futures",
         "updateTime":1576281599000
      }
   ]
}
Raises

BinanceRequestException, BinanceAPIException

get_account_status(**params)

Get account status detail.

https://binance-docs.github.io/apidocs/spot/en/#account-status-sapi-user_data

Parameters

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

Returns

API response

{
    "data": "Normal"
}
Raises

BinanceWithdrawException

get_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.

https://binance-docs.github.io/apidocs/spot/en/#compressedaggregate-trades-list

Parameters
  • symbol (str) – required

  • fromId (str) – ID to get aggregate trades from INCLUSIVE.

  • startTime (int) – 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 500.

Returns

API response

[
    {
        "a": 26129,         # Aggregate tradeId
        "p": "0.01633102",  # Price
        "q": "4.70443515",  # Quantity
        "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?
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_all_coins_info(**params)

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

https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data

Parameters

recvWindow (int) – optional

Returns

API response

{
    "coin": "BTC",
    "depositAllEnable": true,
    "withdrawAllEnable": true,
    "name": "Bitcoin",
    "free": "0",
    "locked": "0",
    "freeze": "0",
    "withdrawing": "0",
    "ipoing": "0",
    "ipoable": "0",
    "storage": "0",
    "isLegalMoney": false,
    "trading": true,
    "networkList": [
        {
            "network": "BNB",
            "coin": "BTC",
            "withdrawIntegerMultiple": "0.00000001",
            "isDefault": false,
            "depositEnable": true,
            "withdrawEnable": true,
            "depositDesc": "",
            "withdrawDesc": "",
            "specialTips": "Both a MEMO and an Address are required to successfully deposit your BEP2-BTCB tokens to Binance.",
            "name": "BEP2",
            "resetAddressStatus": false,
            "addressRegex": "^(bnb1)[0-9a-z]{38}$",
            "memoRegex": "^[0-9A-Za-z-_]{1,120}$",
            "withdrawFee": "0.0000026",
            "withdrawMin": "0.0000052",
            "withdrawMax": "0",
            "minConfirm": 1,
            "unLockConfirm": 0
        },
        {
            "network": "BTC",
            "coin": "BTC",
            "withdrawIntegerMultiple": "0.00000001",
            "isDefault": true,
            "depositEnable": true,
            "withdrawEnable": true,
            "depositDesc": "",
            "withdrawDesc": "",
            "specialTips": "",
            "name": "BTC",
            "resetAddressStatus": false,
            "addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$",
            "memoRegex": "",
            "withdrawFee": "0.0005",
            "withdrawMin": "0.001",
            "withdrawMax": "0",
            "minConfirm": 1,
            "unLockConfirm": 2
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_all_isolated_margin_symbols(**params)

Query isolated margin symbol info for all pairs

https://binance-docs.github.io/apidocs/spot/en/#get-all-isolated-margin-symbol-user_data

pair_details = client.get_all_isolated_margin_symbols()
Returns

API response

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

BinanceRequestException, BinanceAPIException

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.

https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-order-user_data

Parameters
  • symbol (str) – required

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • orderId (str) – optional

  • startTime (str) – 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",
        "symbol": "BNBBTC",
        "time": 1556089977693
    },
    {
        "id": 43123877,
        "price": "0.00395740",
        "qty": "0.77000000",
        "quoteQty": "0.00304719",
        "symbol": "BNBBTC",
        "time": 1556089977693
    },
    {
        "id": 43253549,
        "price": "0.00428930",
        "qty": "23.30000000",
        "quoteQty": "0.09994069",
        "symbol": "BNBBTC",
        "time": 1556163963504
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_all_orders(**params)

Get all account orders; active, canceled, or filled.

https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data

Parameters
  • symbol (str) – required

  • orderId (int) – The unique order id

  • limit (int) – Default 500; max 500.

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

Returns

API response

[
    {
        "symbol": "LTCBTC",
        "orderId": 1,
        "clientOrderId": "myOrder1",
        "price": "0.1",
        "origQty": "1.0",
        "executedQty": "0.0",
        "status": "NEW",
        "timeInForce": "GTC",
        "type": "LIMIT",
        "side": "BUY",
        "stopPrice": "0.0",
        "icebergQty": "0.0",
        "time": 1499827319559
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_all_tickers()

Latest price for all symbols.

https://www.binance.com/restapipub.html#symbols-price-ticker

Returns

List of market tickers

[
    {
        "symbol": "LTCBTC",
        "price": "4.00000200"
    },
    {
        "symbol": "ETHBTC",
        "price": "0.07946600"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_asset_balance(asset, **params)

Get current asset balance.

https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data

Parameters
  • asset (str) – required

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

Returns

dictionary or None if not found

{
    "asset": "BTC",
    "free": "4723846.89208129",
    "locked": "0.00000000"
}
Raises

BinanceRequestException, BinanceAPIException

get_asset_details(**params)

Fetch details on assets.

https://binance-docs.github.io/apidocs/spot/en/#asset-detail-sapi-user_data

Parameters
  • asset (str) – optional

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

Returns

API response

{
    "CTR": {
        "minWithdrawAmount": "70.00000000", //min withdraw amount
        "depositStatus": false,//deposit status (false if ALL of networks' are false)
        "withdrawFee": 35, // withdraw fee
        "withdrawStatus": true, //withdraw status (false if ALL of networks' are false)
        "depositTip": "Delisted, Deposit Suspended" //reason
    },
    "SKY": {
        "minWithdrawAmount": "0.02000000",
        "depositStatus": true,
        "withdrawFee": 0.01,
        "withdrawStatus": true
    }
}
Raises

BinanceWithdrawException

get_asset_dividend_history(**params)

Query asset dividend record.

https://binance-docs.github.io/apidocs/spot/en/#asset-dividend-record-user_data

Parameters
  • asset (str) – optional

  • startTime (long) – optional

  • endTime (long) – optional

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

result = client.get_asset_dividend_history()
Returns

API response

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

BinanceRequestException, BinanceAPIException

get_avg_price(**params)

Current average price for a symbol.

https://binance-docs.github.io/apidocs/spot/en/#current-average-price

Parameters

symbol (str) –

Returns

API response

{
    "mins": 5,
    "price": "9.35751834"
}
get_bnb_burn_spot_margin(**params)

Get BNB Burn Status

https://binance-docs.github.io/apidocs/spot/en/#get-bnb-burn-status-user_data

status = client.get_bnb_burn_spot_margin()
Returns

API response

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

BinanceRequestException, BinanceAPIException

get_deposit_address(**params)

Fetch a deposit address for a symbol

https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data

Parameters
  • coin (str) – required

  • network (str) – optional

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

Returns

API response

{
    "address": "1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv",
    "coin": "BTC",
    "tag": "",
    "url": "https://btc.com/1HPn8Rx2y6nNSfagQBKy27GB99Vbzg89wv"
}
Raises

BinanceRequestException, BinanceAPIException

get_deposit_history(**params)

Fetch deposit history.

https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data

Parameters
  • coin (str) – optional

  • startTime (long) – optional

  • endTime (long) – optional

  • offset (long) – optional - default:0

  • limit (long) – optional

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

Returns

API response

[
    {
        "amount":"0.00999800",
        "coin":"PAXG",
        "network":"ETH",
        "status":1,
        "address":"0x788cabe9236ce061e5a892e1a59395a81fc8d62c",
        "addressTag":"",
        "txId":"0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3",
        "insertTime":1599621997000,
        "transferType":0,
        "confirmTimes":"12/12"
    },
    {
        "amount":"0.50000000",
        "coin":"IOTA",
        "network":"IOTA",
        "status":1,
        "address":"SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLNW",
        "addressTag":"",
        "txId":"ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999",
        "insertTime":1599620082000,
        "transferType":0,
        "confirmTimes":"1/1"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_dust_log(**params)

Get log of small amounts exchanged for BNB.

https://binance-docs.github.io/apidocs/spot/en/#dustlog-sapi-user_data

Parameters
  • startTime (int) – optional

  • endTime (int) – optional

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

Returns

API response

{
    "total": 8,   //Total counts of exchange
    "userAssetDribblets": [
        {
            "totalTransferedAmount": "0.00132256",   // Total transfered BNB amount for this exchange.
            "totalServiceChargeAmount": "0.00002699",    //Total service charge amount for this exchange.
            "transId": 45178372831,
            "userAssetDribbletDetails": [           //Details of  this exchange.
                {
                    "transId": 4359321,
                    "serviceChargeAmount": "0.000009",
                    "amount": "0.0009",
                    "operateTime": 1615985535000,
                    "transferedAmount": "0.000441",
                    "fromAsset": "USDT"
                },
                {
                    "transId": 4359321,
                    "serviceChargeAmount": "0.00001799",
                    "amount": "0.0009",
                    "operateTime": "2018-05-03 17:07:04",
                    "transferedAmount": "0.00088156",
                    "fromAsset": "ETH"
                }
            ]
        },
        {
            "operateTime":1616203180000,
            "totalTransferedAmount": "0.00058795",
            "totalServiceChargeAmount": "0.000012",
            "transId": 4357015,
            "userAssetDribbletDetails": [
                {
                    "transId": 4357015,
                    "serviceChargeAmount": "0.00001"
                    "amount": "0.001",
                    "operateTime": 1616203180000,
                    "transferedAmount": "0.00049",
                    "fromAsset": "USDT"
                },
                {
                    "transId": 4357015,
                    "serviceChargeAmount": "0.000002"
                    "amount": "0.0001",
                    "operateTime": 1616203180000,
                    "transferedAmount": "0.00009795",
                    "fromAsset": "ETH"
                }
            ]
        }
    ]
}
Raises

BinanceWithdrawException

get_exchange_info()

Return rate limits and list of symbols

Returns

list - List of product dictionaries

{
    "timezone": "UTC",
    "serverTime": 1508631584636,
    "rateLimits": [
        {
            "rateLimitType": "REQUESTS",
            "interval": "MINUTE",
            "limit": 1200
        },
        {
            "rateLimitType": "ORDERS",
            "interval": "SECOND",
            "limit": 10
        },
        {
            "rateLimitType": "ORDERS",
            "interval": "DAY",
            "limit": 100000
        }
    ],
    "exchangeFilters": [],
    "symbols": [
        {
            "symbol": "ETHBTC",
            "status": "TRADING",
            "baseAsset": "ETH",
            "baseAssetPrecision": 8,
            "quoteAsset": "BTC",
            "quotePrecision": 8,
            "orderTypes": ["LIMIT", "MARKET"],
            "icebergAllowed": false,
            "filters": [
                {
                    "filterType": "PRICE_FILTER",
                    "minPrice": "0.00000100",
                    "maxPrice": "100000.00000000",
                    "tickSize": "0.00000100"
                }, {
                    "filterType": "LOT_SIZE",
                    "minQty": "0.00100000",
                    "maxQty": "100000.00000000",
                    "stepSize": "0.00100000"
                }, {
                    "filterType": "MIN_NOTIONAL",
                    "minNotional": "0.00100000"
                }
            ]
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_fixed_activity_project_list(**params)

Get Fixed and Activity Project List

https://binance-docs.github.io/apidocs/spot/en/#get-fixed-and-activity-project-list-user_data

Parameters
  • asset (str) – optional

  • type (str) – required - “ACTIVITY”, “CUSTOMIZED_FIXED”

  • status (str) – optional - “ALL”, “SUBSCRIBABLE”, “UNSUBSCRIBABLE”; default “ALL”

  • sortBy (str) – optional - “START_TIME”, “LOT_SIZE”, “INTEREST_RATE”, “DURATION”; 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

Returns

API response

[
    {
        "asset": "USDT",
        "displayPriority": 1,
        "duration": 90,
        "interestPerLot": "1.35810000",
        "interestRate": "0.05510000",
        "lotSize": "100.00000000",
        "lotsLowLimit": 1,
        "lotsPurchased": 74155,
        "lotsUpLimit": 80000,
        "maxLotsPerUser": 2000,
        "needKyc": False,
        "projectId": "CUSDT90DAYSS001",
        "projectName": "USDT",
        "status": "PURCHASING",
        "type": "CUSTOMIZED_FIXED",
        "withAreaLimitation": False
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_historical_klines(symbol, interval, start_str, end_str=None, limit=500)

Get Historical Klines from Binance

See dateparser docs for valid start and end string formats http://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) – Name of symbol pair e.g BNBBTC

  • interval (str) – Binance Kline interval

  • start_str (str|int) – 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 500; max 1000.

Returns

list of OHLCV values

get_historical_klines_generator(symbol, interval, start_str, end_str=None)

Get Historical Klines from Binance

See dateparser docs for valid start and end string formats http://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) – Name of symbol pair e.g BNBBTC

  • interval (str) – Binance Kline interval

  • start_str (str|int) – 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)

Returns

generator of OHLCV values

get_historical_trades(**params)

Get older trades.

https://binance-docs.github.io/apidocs/spot/en/#recent-trades-list

Parameters
  • symbol (str) – required

  • limit (int) – Default 500; max 500.

  • fromId (str) – TradeId to fetch from. Default gets most recent trades.

Returns

API response

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

BinanceRequestException, BinanceAPIException

get_isolated_margin_account(**params)

Query isolated margin account details

https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-account-info-user_data

Parameters

symbols – optional up to 5 margin pairs as a comma separated string

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

API response

If "symbols" is not sent:

    {
    "assets":[
        {
            "baseAsset": 
            {
            "asset": "BTC",
            "borrowEnabled": true,
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000",
            "netAssetOfBtc": "0.00000000",
            "repayEnabled": true,
            "totalAsset": "0.00000000"
            },
            "quoteAsset": 
            {
            "asset": "USDT",
            "borrowEnabled": true,
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000",
            "netAssetOfBtc": "0.00000000",
            "repayEnabled": true,
            "totalAsset": "0.00000000"
            },
            "symbol": "BTCUSDT"
            "isolatedCreated": true, 
            "marginLevel": "0.00000000", 
            "marginLevelStatus": "EXCESSIVE", // "EXCESSIVE", "NORMAL", "MARGIN_CALL", "PRE_LIQUIDATION", "FORCE_LIQUIDATION"
            "marginRatio": "0.00000000",
            "indexPrice": "10000.00000000"
            "liquidatePrice": "1000.00000000",
            "liquidateRate": "1.00000000"
            "tradeEnabled": true
        }
        ],
        "totalAssetOfBtc": "0.00000000",
        "totalLiabilityOfBtc": "0.00000000",
        "totalNetAssetOfBtc": "0.00000000" 
    }

If "symbols" is sent:

    {
    "assets":[
        {
            "baseAsset": 
            {
            "asset": "BTC",
            "borrowEnabled": true,
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000",
            "netAssetOfBtc": "0.00000000",
            "repayEnabled": true,
            "totalAsset": "0.00000000"
            },
            "quoteAsset": 
            {
            "asset": "USDT",
            "borrowEnabled": true,
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000",
            "netAssetOfBtc": "0.00000000",
            "repayEnabled": true,
            "totalAsset": "0.00000000"
            },
            "symbol": "BTCUSDT"
            "isolatedCreated": true, 
            "marginLevel": "0.00000000", 
            "marginLevelStatus": "EXCESSIVE", // "EXCESSIVE", "NORMAL", "MARGIN_CALL", "PRE_LIQUIDATION", "FORCE_LIQUIDATION"
            "marginRatio": "0.00000000",
            "indexPrice": "10000.00000000"
            "liquidatePrice": "1000.00000000",
            "liquidateRate": "1.00000000"
            "tradeEnabled": true
        }
        ]
    }
get_isolated_margin_symbol(**params)

Query isolated margin symbol info

https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-symbol-user_data

Parameters

symbol (str) – name of the symbol pair

pair_details = client.get_isolated_margin_symbol(symbol='BTCUSDT')
Returns

API response

{
"symbol":"BTCUSDT",
"base":"BTC",
"quote":"USDT",
"isMarginTrade":true,
"isBuyAllowed":true,
"isSellAllowed":true      
}
Raises

BinanceRequestException, BinanceAPIException

get_klines(**params)

Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

https://binance-docs.github.io/apidocs/spot/en/#klinecandlestick-data

Parameters
  • symbol (str) – required

  • interval (str) –

  • limit (int) –

    • Default 500; max 500.

  • startTime (int) –

  • endTime (int) –

Returns

API response

[
    [
        1499040000000,      # Open time
        "0.01634790",       # Open
        "0.80000000",       # High
        "0.01575800",       # Low
        "0.01577100",       # Close
        "148976.11427815",  # Volume
        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.62484339" # Can be ignored
    ]
]
Raises

BinanceRequestException, BinanceAPIException

static get_latest_release_info()

Get infos about the latest available release :return: dict or False

get_latest_version()

Get the version of the latest available release (cache time 1 hour) :return: str or False

get_lending_account(**params)

Get Lending Account Details

https://binance-docs.github.io/apidocs/spot/en/#lending-account-user_data

get_lending_daily_quota_left(**params)

Get Left Daily Purchase Quota of Flexible Product.

https://binance-docs.github.io/apidocs/spot/en/#get-left-daily-purchase-quota-of-flexible-product-user_data

get_lending_daily_redemption_quota(**params)

Get Left Daily Redemption Quota of Flexible Product

https://binance-docs.github.io/apidocs/spot/en/#get-left-daily-redemption-quota-of-flexible-product-user_data

get_lending_interest_history(**params)

Get Lending Interest History

https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data-2

get_lending_position(**params)

Get Flexible Product Position

https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-position-user_data

get_lending_product_list(**params)

Get Lending Product List

https://binance-docs.github.io/apidocs/spot/en/#get-flexible-product-list-user_data

get_lending_purchase_history(**params)

Get Lending Purchase History

https://binance-docs.github.io/apidocs/spot/en/#get-purchase-record-user_data

get_lending_redemption_history(**params)

Get Lending Redemption History

https://binance-docs.github.io/apidocs/spot/en/#get-redemption-record-user_data

get_margin_account(**params)

Query cross-margin account details

https://binance-docs.github.io/apidocs/spot/en/#query-cross-margin-account-details-user_data

Returns

API response

{
    "borrowEnabled": true,
    "marginLevel": "11.64405625",
    "totalAssetOfBtc": "6.82728457",
    "totalLiabilityOfBtc": "0.58633215",
    "totalNetAssetOfBtc": "6.24095242",
    "tradeEnabled": true,
    "transferEnabled": true,
    "userAssets": [
        {
            "asset": "BTC",
            "borrowed": "0.00000000",
            "free": "0.00499500",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00499500"
        },
        {
            "asset": "BNB",
            "borrowed": "201.66666672",
            "free": "2346.50000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "2144.83333328"
        },
        {
            "asset": "ETH",
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000"
        },
        {
            "asset": "USDT",
            "borrowed": "0.00000000",
            "free": "0.00000000",
            "interest": "0.00000000",
            "locked": "0.00000000",
            "netAsset": "0.00000000"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_asset(**params)

Query cross-margin asset

https://binance-docs.github.io/apidocs/spot/en/#query-margin-asset-market_data

Parameters

asset (str) – name of the asset

asset_details = client.get_margin_asset(asset='BNB')
Returns

API response

{
    "assetFullName": "Binance Coin",
    "assetName": "BNB",
    "isBorrowable": false,
    "isMortgageable": true,
    "userMinBorrow": "0.00000000",
    "userMinRepay": "0.00000000"
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_loan_details(**params)

Query loan record

txId or startTime must be sent. txId takes precedence.

https://binance-docs.github.io/apidocs/spot/en/#query-loan-record-user_data

Parameters
  • asset (str) – required

  • isolatedSymbol (str) – isolated symbol (if querying isolated margin)

  • txId (str) – the tranId in of the created loan

  • startTime (str) – earliest timestamp to filter transactions

  • endTime (str) – Used to uniquely identify this cancel. Automatically generated by default.

  • current (str) – 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": [
        {
            "asset": "BNB",
            "principal": "0.84624403",
            "timestamp": 1555056425000,
            //one of PENDING (pending to execution), CONFIRMED (successfully loaned), FAILED (execution failed, nothing happened to your account);
            "status": "CONFIRMED"
        }
    ],
    "total": 1
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_order(**params)

Query margin accounts order

Either orderId or origClientOrderId must be sent.

For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.

https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-order-user_data

Parameters
  • symbol (str) – required

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • orderId (str) –

  • origClientOrderId (str) –

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

Returns

API response

{
    "clientOrderId": "ZwfQzuDIGpceVhKW5DvCmO",
    "cummulativeQuoteQty": "0.00000000",
    "executedQty": "0.00000000",
    "icebergQty": "0.00000000",
    "isWorking": true,
    "orderId": 213205622,
    "origQty": "0.30000000",
    "price": "0.00493630",
    "side": "SELL",
    "status": "NEW",
    "stopPrice": "0.00000000",
    "symbol": "BNBBTC",
    "time": 1562133008725,
    "timeInForce": "GTC",
    "type": "LIMIT",
    "updateTime": 1562133008725
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_price_index(**params)

Query margin priceIndex

https://binance-docs.github.io/apidocs/spot/en/#query-margin-priceindex-market_data

Parameters

symbol (str) – name of the symbol pair

price_index_details = client.get_margin_price_index(symbol='BTCUSDT')
Returns

API response

{
    "calcTime": 1562046418000,
    "price": "0.00333930",
    "symbol": "BNBBTC"
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_repay_details(**params)

Query repay record

txId or startTime must be sent. txId takes precedence.

https://binance-docs.github.io/apidocs/spot/en/#query-repay-record-user_data

Parameters
  • asset (str) – required

  • isolatedSymbol (str) – isolated symbol (if querying isolated margin)

  • txId (str) – the tranId in of the created loan

  • startTime (str) –

  • endTime (str) – Used to uniquely identify this cancel. Automatically generated by default.

  • current (str) – 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": [
        {
            //Total amount repaid
            "amount": "14.00000000",
            "asset": "BNB",
            //Interest repaid
            "interest": "0.01866667",
            //Principal repaid
            "principal": "13.98133333",
            //one of PENDING (pending to execution), CONFIRMED (successfully loaned), FAILED (execution failed, nothing happened to your account);
            "status": "CONFIRMED",
            "timestamp": 1563438204000,
            "txId": 2970933056
        }
    ],
    "total": 1
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_symbol(**params)

Query cross-margin symbol info

https://binance-docs.github.io/apidocs/spot/en/#query-cross-margin-pair-market_data

Parameters

symbol (str) – name of the symbol pair

pair_details = client.get_margin_symbol(symbol='BTCUSDT')
Returns

API response

{
    "id":323355778339572400,
    "symbol":"BTCUSDT",
    "base":"BTC",
    "quote":"USDT",
    "isMarginTrade":true,
    "isBuyAllowed":true,
    "isSellAllowed":true
}
Raises

BinanceRequestException, BinanceAPIException

get_margin_trades(**params)

Query margin accounts trades

If fromId is set, it will get orders >= that fromId. Otherwise most recent orders are returned.

https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data

Parameters
  • symbol (str) – required

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • fromId (str) – optional

  • startTime (str) – optional

  • endTime (str) – optional

  • limit (int) – Default 500; max 1000

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

Returns

API response

[
    {
        "commission": "0.00006000",
        "commissionAsset": "BTC",
        "id": 34,
        "isBestMatch": true,
        "isBuyer": false,
        "isMaker": false,
        "orderId": 39324,
        "price": "0.02000000",
        "qty": "3.00000000",
        "symbol": "BNBBTC",
        "time": 1561973357171
    }, {
        "commission": "0.00002950",
        "commissionAsset": "BTC",
        "id": 32,
        "isBestMatch": true,
        "isBuyer": false,
        "isMaker": true,
        "orderId": 39319,
        "price": "0.00590000",
        "qty": "5.00000000",
        "symbol": "BNBBTC",
        "time": 1561964645345
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_max_margin_loan(**params)

Query max borrow amount for an asset

https://binance-docs.github.io/apidocs/spot/en/#query-max-borrow-user_data

Parameters
  • asset (str) – required

  • isolatedSymbol (str) – isolated symbol (if querying isolated margin)

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

Returns

API response

{
    "amount": "1.69248805"
}
Raises

BinanceRequestException, BinanceAPIException

get_max_margin_transfer(**params)

Query max transfer-out amount

https://binance-docs.github.io/apidocs/spot/en/#query-max-transfer-out-amount-user_data

Parameters
  • asset (str) – required

  • isolatedSymbol (str) – isolated symbol (if querying isolated margin)

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

Returns

API response

{
    "amount": "3.59498107"
}
Raises

BinanceRequestException, BinanceAPIException

get_my_trades(**params)

Get trades for a specific symbol.

https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data

Parameters
  • symbol (str) – required

  • limit (int) – Default 500; max 500.

  • fromId (int) – TradeId to fetch from. Default gets most recent trades.

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

Returns

API response

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

BinanceRequestException, BinanceAPIException

get_open_isolated_margin_orders(**params)

Query isolated 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.

https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-open-order-user_data

Parameters
  • symbol (str) – optional

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

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

Returns

API response

[
    {
        "clientOrderId": "qhcZw71gAkCCTv0t0k8LUK",
        "cummulativeQuoteQty": "0.00000000",
        "executedQty": "0.00000000",
        "icebergQty": "0.00000000",
        "isWorking": true,
        "orderId": 211842552,
        "origQty": "0.30000000",
        "price": "0.00475010",
        "side": "SELL",
        "status": "NEW",
        "stopPrice": "0.00000000",
        "symbol": "BNBBTC",
        "time": 1562040170089,
        "timeInForce": "GTC",
        "type": "LIMIT",
        "updateTime": 1562040170089
    } ]
Raises

BinanceRequestException, BinanceAPIException

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.

https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-open-order-user_data

Parameters
  • symbol (str) – optional

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

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

Returns

API response

[
    {
        "clientOrderId": "qhcZw71gAkCCTv0t0k8LUK",
        "cummulativeQuoteQty": "0.00000000",
        "executedQty": "0.00000000",
        "icebergQty": "0.00000000",
        "isWorking": true,
        "orderId": 211842552,
        "origQty": "0.30000000",
        "price": "0.00475010",
        "side": "SELL",
        "status": "NEW",
        "stopPrice": "0.00000000",
        "symbol": "BNBBTC",
        "time": 1562040170089,
        "timeInForce": "GTC",
        "type": "LIMIT",
        "updateTime": 1562040170089
    } ]
Raises

BinanceRequestException, BinanceAPIException

get_open_orders(**params)

Get all open orders on a symbol.

https://binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data

Parameters
  • symbol (str) – optional

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

Returns

API response

[
    {
        "symbol": "LTCBTC",
        "orderId": 1,
        "clientOrderId": "myOrder1",
        "price": "0.1",
        "origQty": "1.0",
        "executedQty": "0.0",
        "status": "NEW",
        "timeInForce": "GTC",
        "type": "LIMIT",
        "side": "BUY",
        "stopPrice": "0.0",
        "icebergQty": "0.0",
        "time": 1499827319559
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_order(**params)

Check an order’s status. Either orderId or origClientOrderId must be sent.

https://binance-docs.github.io/apidocs/spot/en/#query-order-user_data

Parameters
  • symbol (str) – required

  • orderId (int) – The unique order id

  • origClientOrderId (str) – optional

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

Returns

API response

{
    "symbol": "LTCBTC",
    "orderId": 1,
    "clientOrderId": "myOrder1",
    "price": "0.1",
    "origQty": "1.0",
    "executedQty": "0.0",
    "status": "NEW",
    "timeInForce": "GTC",
    "type": "LIMIT",
    "side": "BUY",
    "stopPrice": "0.0",
    "icebergQty": "0.0",
    "time": 1499827319559
}
Raises

BinanceRequestException, BinanceAPIException

get_order_book(**params)

Get the Order Book for the market

https://binance-docs.github.io/apidocs/spot/en/#order-book

Parameters
  • symbol (str) – required

  • limit (int) – Default 100; max 1000

Returns

API response

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

BinanceRequestException, BinanceAPIException

get_orderbook_ticker(**params)

Latest price for a symbol or symbols.

https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker

Parameters

symbol (str) –

Returns

API response

{
    "symbol": "LTCBTC",
    "bidPrice": "4.00000000",
    "bidQty": "431.00000000",
    "askPrice": "4.00000200",
    "askQty": "9.00000000"
}

OR

[
    {
        "symbol": "LTCBTC",
        "bidPrice": "4.00000000",
        "bidQty": "431.00000000",
        "askPrice": "4.00000200",
        "askQty": "9.00000000"
    },
    {
        "symbol": "ETHBTC",
        "bidPrice": "0.07946700",
        "bidQty": "9.00000000",
        "askPrice": "100000.00000000",
        "askQty": "1000.00000000"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_orderbook_tickers()

Best price/qty on the order book for all symbols.

https://www.binance.com/restapipub.html#symbols-order-book-ticker

Returns

List of order book market entries

[
    {
        "symbol": "LTCBTC",
        "bidPrice": "4.00000000",
        "bidQty": "431.00000000",
        "askPrice": "4.00000200",
        "askQty": "9.00000000"
    },
    {
        "symbol": "ETHBTC",
        "bidPrice": "0.07946700",
        "bidQty": "9.00000000",
        "askPrice": "100000.00000000",
        "askQty": "1000.00000000"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_products()

Return list of products currently listed on Binance

Use get_exchange_info() call instead

Returns

list - List of product dictionaries

Raises

BinanceRequestException, BinanceAPIException

get_recent_trades(**params)

Get recent trades (up to last 500).

https://binance-docs.github.io/apidocs/spot/en/#recent-trades-list

Parameters
  • symbol (str) – required

  • limit (int) – Default 500; max 500.

Returns

API response

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

BinanceRequestException, BinanceAPIException

get_server_time()

Test connectivity to the Rest API and get the current server time.

https://binance-docs.github.io/apidocs/spot/en/#check-server-time

Returns

Current server time

{
    "serverTime": 1499827319559
}
Raises

BinanceRequestException, BinanceAPIException

get_sub_account_assets(**params)

Fetch sub-account assets

Parameters
  • email (str) – required

  • recvWindow (int) – optional

Returns

API response

{
    "balances":[
        {
            "asset":"ADA",
            "free":10000,
            "locked":0
        },
        {
            "asset":"BNB",
            "free":10003,
            "locked":0
        },
        {
            "asset":"BTC",
            "free":11467.6399,
            "locked":0
        },
        {
            "asset":"ETH",
            "free":10004.995,
            "locked":0
        },
        {
            "asset":"USDT",
            "free":11652.14213,
            "locked":0
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_sub_account_futures_transfer_history(**params)

Query Sub-account Futures Transfer History.

https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-futures-asset-transfer-history-for-master-account

Parameters
  • email (str) – required

  • futuresType (int) – required

  • startTime (int) – optional

  • endTime (int) – optional

  • page (int) – optional

  • limit (int) – optional

  • recvWindow (int) – optional

Returns

API response

{
    "success":true,
    "futuresType": 2,
    "transfers":[
        {
            "from":"aaa@test.com",
            "to":"bbb@test.com",
            "asset":"BTC",
            "qty":"1",
            "time":1544433328000
        },
        {
            "from":"bbb@test.com",
            "to":"ccc@test.com",
            "asset":"ETH",
            "qty":"2",
            "time":1544433328000
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_sub_account_list(**params)

Query Sub-account List.

https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-list-sapi-for-master-account

Parameters
  • email (str) – optional - Sub-account email

  • isFreeze (str) – optional

  • page – optional - Default value: 1

  • limit (int) – optional - Default value: 1, Max value: 200

  • recvWindow (int) – optional

Returns

API response

{
    "subAccounts":[
        {
            "email":"testsub@gmail.com",
            "isFreeze":false,
            "createTime":1544433328000
        },
        {
            "email":"virtual@oxebmvfonoemail.com",
            "isFreeze":false,
            "createTime":1544433328000
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_sub_account_transfer_history(**params)

Query Sub-account Transfer History.

https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-spot-asset-transfer-history-sapi-for-master-account

Parameters
  • fromEmail (str) – optional

  • toEmail (str) – optional

  • startTime (int) – optional

  • endTime (int) – optional

  • page (int) – optional - Default value: 1

  • limit (int) – optional - Default value: 500

  • recvWindow (int) – optional

Returns

API response

[
    {
        "from":"aaa@test.com",
        "to":"bbb@test.com",
        "asset":"BTC",
        "qty":"10",
        "status": "SUCCESS",
        "tranId": 6489943656,
        "time":1544433328000
    },
    {
        "from":"bbb@test.com",
        "to":"ccc@test.com",
        "asset":"ETH",
        "qty":"2",
        "status": "SUCCESS",
        "tranId": 6489938713,
        "time":1544433328000
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_deposit_address(**params)

Get Sub-account Deposit Address (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-deposit-address-for-master-account

Parameters
  • email (str) – required - Sub account email

  • coin (str) – required

  • network (str) – optional

  • recvWindow (int) – optional

Returns

API response

{
     "address":"TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV",
     "coin":"USDT",
     "tag":"",
     "url":"https://tronscan.org/#/address/TDunhSa7jkTNuKrusUTU1MUHtqXoBPKETV"
 }
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_deposit_history(**params)

Get Sub-account Deposit History (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-deposit-address-for-master-account

Parameters
  • email (str) – required - Sub account email

  • coin (str) – optional

  • status (int) – optional - (0:pending,6: credited but cannot withdraw, 1:success)

  • startTime (int) – optional

  • endTime (int) – optional

  • limit (int) – optional

  • offset (int) – optional - default:0

  • recvWindow (int) – optional

Returns

API response

[
     {
         "amount":"0.00999800",
         "coin":"PAXG",
         "network":"ETH",
         "status":1,
         "address":"0x788cabe9236ce061e5a892e1a59395a81fc8d62c",
         "addressTag":"",
         "txId":"0xaad4654a3234aa6118af9b4b335f5ae81c360b2394721c019b5d1e75328b09f3",
         "insertTime":1599621997000,
         "transferType":0,
         "confirmTimes":"12/12"
     },
     {
         "amount":"0.50000000",
         "coin":"IOTA",
         "network":"IOTA",
         "status":1,
         "address":"SIZ9VLMHWATXKV99LH99CIGFJFUMLEHGWVZVNNZXRJJVWBPHYWPPBOSDORZ9EQSHCZAMPVAPGFYQAUUV9DROOXJLNW",
         "addressTag":"",
         "txId":"ESBFVQUTPIWQNJSPXFNHNYHSQNTGKRVKPRABQWTAXCDWOAKDKYWPTVG9BGXNVNKTLEJGESAVXIKIZ9999",
         "insertTime":1599620082000,
         "transferType":0,
         "confirmTimes":"1/1"
     }
]
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_futures_details(**params)

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

https://binance-docs.github.io/apidocs/spot/en/#get-detail-on-sub-account-39-s-futures-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • recvWindow (int) – optional

Returns

API response

{
    "email": "abc@test.com",
    "asset": "USDT",
    "assets":[
        {
            "asset": "USDT",
            "initialMargin": "0.00000000",
            "maintenanceMargin": "0.00000000",
            "marginBalance": "0.88308000",
            "maxWithdrawAmount": "0.88308000",
            "openOrderInitialMargin": "0.00000000",
            "positionInitialMargin": "0.00000000",
            "unrealizedProfit": "0.00000000",
            "walletBalance": "0.88308000"
         }
    ],
    "canDeposit": true,
    "canTrade": true,
    "canWithdraw": true,
    "feeTier": 2,
    "maxWithdrawAmount": "0.88308000",
    "totalInitialMargin": "0.00000000",
    "totalMaintenanceMargin": "0.00000000",
    "totalMarginBalance": "0.88308000",
    "totalOpenOrderInitialMargin": "0.00000000",
    "totalPositionInitialMargin": "0.00000000",
    "totalUnrealizedProfit": "0.00000000",
    "totalWalletBalance": "0.88308000",
    "updateTime": 1576756674610
}
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_futures_margin_status(**params)

Get Sub-account’s Status on Margin/Futures (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-39-s-status-on-margin-futures-for-master-account

Parameters
  • email (str) – optional - Sub account email

  • recvWindow (int) – optional

Returns

API response

[
     {
         "email":"123@test.com",      // user email
         "isSubUserEnabled": true,    // true or false
         "isUserActive": true,        // true or false
         "insertTime": 1570791523523  // sub account create time
         "isMarginEnabled": true,     // true or false for margin
         "isFutureEnabled": true      // true or false for futures.
         "mobile": 1570791523523      // user mobile number
     }
 ]
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_futures_positionrisk(**params)

Get Futures Position-Risk of Sub-account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-futures-position-risk-of-sub-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • recvWindow (int) – optional

Returns

API response

[
    {
        "entryPrice": "9975.12000",
        "leverage": "50",              // current initial leverage
        "maxNotional": "1000000",      // notional value limit of current initial leverage
        "liquidationPrice": "7963.54",
        "markPrice": "9973.50770517",
        "positionAmount": "0.010",
        "symbol": "BTCUSDT",
        "unrealizedProfit": "-0.01612295"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_futures_summary(**params)

Get Summary of Sub-account’s Futures Account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-sub-account-39-s-futures-account-for-master-account

Parameters

recvWindow (int) – optional

Returns

API response

{
    "totalInitialMargin": "9.83137400",
    "totalMaintenanceMargin": "0.41568700",
    "totalMarginBalance": "23.03235621",
    "totalOpenOrderInitialMargin": "9.00000000",
    "totalPositionInitialMargin": "0.83137400",
    "totalUnrealizedProfit": "0.03219710",
    "totalWalletBalance": "22.15879444",
    "asset": "USDT",
    "subAccountList":[
        {
            "email": "123@test.com",
            "totalInitialMargin": "9.00000000",
            "totalMaintenanceMargin": "0.00000000",
            "totalMarginBalance": "22.12659734",
            "totalOpenOrderInitialMargin": "9.00000000",
            "totalPositionInitialMargin": "0.00000000",
            "totalUnrealizedProfit": "0.00000000",
            "totalWalletBalance": "22.12659734",
            "asset": "USDT"
        },
        {
            "email": "345@test.com",
            "totalInitialMargin": "0.83137400",
            "totalMaintenanceMargin": "0.41568700",
            "totalMarginBalance": "0.90575887",
            "totalOpenOrderInitialMargin": "0.00000000",
            "totalPositionInitialMargin": "0.83137400",
            "totalUnrealizedProfit": "0.03219710",
            "totalWalletBalance": "0.87356177",
            "asset": "USDT"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_margin_details(**params)

Get Detail on Sub-account’s Margin Account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-detail-on-sub-account-39-s-margin-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • recvWindow (int) – optional

Returns

API response

{
      "email":"123@test.com",
      "marginLevel": "11.64405625",
      "totalAssetOfBtc": "6.82728457",
      "totalLiabilityOfBtc": "0.58633215",
      "totalNetAssetOfBtc": "6.24095242",
      "marginTradeCoeffVo":
            {
                "forceLiquidationBar": "1.10000000",  // Liquidation margin ratio
                "marginCallBar": "1.50000000",        // Margin call margin ratio
                "normalBar": "2.00000000"             // Initial margin ratio
            },
      "marginUserAssetVoList": [
          {
              "asset": "BTC",
              "borrowed": "0.00000000",
              "free": "0.00499500",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00499500"
          },
          {
              "asset": "BNB",
              "borrowed": "201.66666672",
              "free": "2346.50000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "2144.83333328"
          },
          {
              "asset": "ETH",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          },
          {
              "asset": "USDT",
              "borrowed": "0.00000000",
              "free": "0.00000000",
              "interest": "0.00000000",
              "locked": "0.00000000",
              "netAsset": "0.00000000"
          }
      ]
}
Raises

BinanceRequestException, BinanceAPIException

get_subaccount_margin_summary(**params)

Get Summary of Sub-account’s Margin Account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-sub-account-39-s-margin-account-for-master-account

Parameters

recvWindow (int) – optional

Returns

API response

{
    "totalAssetOfBtc": "4.33333333",
    "totalLiabilityOfBtc": "2.11111112",
    "totalNetAssetOfBtc": "2.22222221",
    "subAccountList":[
        {
            "email":"123@test.com",
            "totalAssetOfBtc": "2.11111111",
            "totalLiabilityOfBtc": "1.11111111",
            "totalNetAssetOfBtc": "1.00000000"
        },
        {
            "email":"345@test.com",
            "totalAssetOfBtc": "2.22222222",
            "totalLiabilityOfBtc": "1.00000001",
            "totalNetAssetOfBtc": "1.22222221"
        }
    ]
}
Raises

BinanceRequestException, 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
  • asset (str) – required - The asset being transferred, e.g., USDT

  • type (int) – optional - 1: transfer in, 2: transfer out

  • startTime (int) – optional

  • endTime (int) – optional

  • limit (int) – optional - Default 500

  • recvWindow (int) – optional

Returns

API response

[
  {
    "counterParty":"master",
    "email":"master@test.com",
    "type":1,  // 1 for transfer in, 2 for transfer out
    "asset":"BTC",
    "qty":"1",
    "status":"SUCCESS",
    "tranId":11798835829,
    "time":1544433325000
  },
  {
    "counterParty":"subAccount",
    "email":"sub2@test.com",
    "type":2,
    "asset":"ETH",
    "qty":"2",
    "status":"SUCCESS",
    "tranId":11798829519,
    "time":1544433326000
  }
]
Raises

BinanceRequestException, BinanceAPIException

get_symbol_info(symbol)

Return information about a symbol

Parameters

symbol (str) – required e.g BNBBTC

Returns

Dict if found, None if not

{
    "symbol": "ETHBTC",
    "status": "TRADING",
    "baseAsset": "ETH",
    "baseAssetPrecision": 8,
    "quoteAsset": "BTC",
    "quotePrecision": 8,
    "orderTypes": ["LIMIT", "MARKET"],
    "icebergAllowed": false,
    "filters": [
        {
            "filterType": "PRICE_FILTER",
            "minPrice": "0.00000100",
            "maxPrice": "100000.00000000",
            "tickSize": "0.00000100"
        }, {
            "filterType": "LOT_SIZE",
            "minQty": "0.00100000",
            "maxQty": "100000.00000000",
            "stepSize": "0.00100000"
        }, {
            "filterType": "MIN_NOTIONAL",
            "minNotional": "0.00100000"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

get_symbol_ticker(**params)

Latest price for a symbol or symbols.

https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics

Parameters

symbol (str) –

Returns

API response

{
    "symbol": "LTCBTC",
    "price": "4.00000200"
}

OR

[
    {
        "symbol": "LTCBTC",
        "price": "4.00000200"
    },
    {
        "symbol": "ETHBTC",
        "price": "0.07946600"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_system_status()

Get system status detail.

https://binance-docs.github.io/apidocs/spot/en/#system-status-sapi-system

Returns

API response

{
    "status": 0,        # 0: normal,1:system maintenance
    "msg": "normal"     # normal or System maintenance.
}
Raises

BinanceAPIException

get_ticker(**params)

24 hour price change statistics.

https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics

Parameters

symbol (str) –

Returns

API response

{
    "priceChange": "-94.99999800",
    "priceChangePercent": "-95.960",
    "weightedAvgPrice": "0.29628482",
    "prevClosePrice": "0.10002000",
    "lastPrice": "4.00000200",
    "bidPrice": "4.00000000",
    "askPrice": "4.00000200",
    "openPrice": "99.00000000",
    "highPrice": "100.00000000",
    "lowPrice": "0.10000000",
    "volume": "8913.30000000",
    "openTime": 1499783499040,
    "closeTime": 1499869899040,
    "fristId": 28385,   # First tradeId
    "lastId": 28460,    # Last tradeId
    "count": 76         # Trade count
}

OR

[
    {
        "priceChange": "-94.99999800",
        "priceChangePercent": "-95.960",
        "weightedAvgPrice": "0.29628482",
        "prevClosePrice": "0.10002000",
        "lastPrice": "4.00000200",
        "bidPrice": "4.00000000",
        "askPrice": "4.00000200",
        "openPrice": "99.00000000",
        "highPrice": "100.00000000",
        "lowPrice": "0.10000000",
        "volume": "8913.30000000",
        "openTime": 1499783499040,
        "closeTime": 1499869899040,
        "fristId": 28385,   # First tradeId
        "lastId": 28460,    # Last tradeId
        "count": 76         # Trade count
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_trade_fee(**params)

Get trade fee.

https://binance-docs.github.io/apidocs/spot/en/#trade-fee-sapi-user_data

Parameters
  • symbol (str) – optional

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

Returns

API response

[
    {
        "symbol": "ADABNB",
        "makerCommission": "0.001",
        "takerCommission": "0.001"
    },
    {
        "symbol": "BNBBTC",
        "makerCommission": "0.001",
        "takerCommission": "0.001"
    }
]
Raises

BinanceWithdrawException

get_universal_transfer_history(**params)

Universal Transfer (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#query-universal-transfer-history

Parameters
  • fromEmail (str) – optional

  • toEmail (str) – optional

  • startTime (int) – optional

  • endTime (int) – optional

  • page (int) – optional

  • limit (int) – optional

  • recvWindow (int) – optional

Returns

API response

[
  {
    "tranId":11945860693,
    "fromEmail":"master@test.com",
    "toEmail":"subaccount1@test.com",
    "asset":"BTC",
    "amount":"0.1",
    "fromAccountType":"SPOT",
    "toAccountType":"COIN_FUTURE",
    "status":"SUCCESS",
    "createTimeStamp":1544433325000
  },
  {
    "tranId":11945857955,
    "fromEmail":"master@test.com",
    "toEmail":"subaccount2@test.com",
    "asset":"ETH",
    "amount":"0.2",
    "fromAccountType":"SPOT",
    "toAccountType":"USDT_FUTURE",
    "status":"SUCCESS",
    "createTimeStamp":1544433326000
  }
]
Raises

BinanceRequestException, BinanceAPIException

get_used_weight(make_new_request=False)

Get the used weight from Binance endpoints

https://binance-docs.github.io/apidocs/spot/en/

Parameters

make_new_request (int) – Set to True to make a new request before returning the used_weight.

Returns

int - used weight

{
 'weight': '5',
 'timestamp': 1626079769.0,
 'status_code': 200
}
get_user_agent()

Get the user_agent string “lib name + lib version + python version”

Returns

str - user agent

get_version()

Get the package/module version

Returns

str

get_withdraw_history(**params)

Fetch withdraw history.

https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data

Parameters
  • coin (str) – optional

  • status (int) – 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6Completed) optional

  • offset (int) – optional - default:0

  • limit (int) – 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

Returns

API response

[
    {
        "address": "0x94df8b352de7f46f64b01d3666bf6e936e44ce60",
        "amount": "8.91000000",
        "applyTime": "2019-10-12 11:12:02",
        "coin": "USDT",
        "id": "b6ae22b3aa844210a7041aee7589627c",
        "withdrawOrderId": "WITHDRAWtest123", // will not be returned if there's no withdrawOrderId for
                           this withdraw.
        "network": "ETH",
        "transferType": 0,   // 1 for internal transfer, 0 for external transfer
        "status": 6,
        "txId": "0xb5ef8c13b968a406cc62a93a8bd80f9e9a906ef1b3fcf20a2e48573c17659268"
    },
    {
        "address": "1FZdVHtiBqMrWdjPyRPULCUceZPJ2WLCsB",
        "amount": "0.00150000",
        "applyTime": "2019-09-24 12:43:45",
        "coin": "BTC",
        "id": "156ec387f49b41df8724fa744fa82719",
        "network": "BTC",
        "status": 6,
        "txId": "60fd9007ebfddc753455f95fafa808c4302c836e4d1eebc5a132c36c1d8ac354"
    }
]
Raises

BinanceRequestException, BinanceAPIException

get_withdraw_history_id(withdraw_id, **params)

Fetch withdraw history.

https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data

Parameters
  • withdraw_id (str) – required

  • asset (str) – optional

  • startTime (long) – optional

  • endTime (long) – optional

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

Returns

API response

{
    "id":"7213fea8e94b4a5593d507237e5a555b",
    "withdrawOrderId": None,
    "amount": 0.99,
    "transactionFee": 0.01,
    "address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
    "asset": "ETH",
    "txId": "0xdf33b22bdb2b28b1f75ccd201a4a4m6e7g83jy5fc5d5a9d1340961598cfcb0a1",
    "applyTime": 1508198532000,
    "status": 4
}
Raises

BinanceRequestException, BinanceAPIException

is_update_availabe()

Is a new release of this package available?

Returns

bool

isolated_margin_stream_close(symbol, listenKey)

Close out an isolated margin data stream.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-isolated-margin

Parameters
  • symbol (str) – required - symbol for the isolated margin account

  • listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, 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.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-isolated-margin

Parameters

symbol (str) – required - symbol for the isolated margin account

Returns

API response

{
    "listenKey":  "T3ee22BIYuWqmvne0HNq2A2WsFlEtLhvWCtItw6ffhhdmjifQ2tRbuKkTHhr"
}
Raises

BinanceRequestException, BinanceAPIException

isolated_margin_stream_keepalive(symbol, listenKey)

PING an isolated margin data stream to prevent a time out.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-isolated-margin

Parameters
  • symbol (str) – required - symbol for the isolated margin account

  • listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, BinanceAPIException

make_subaccount_futures_transfer(**params)

Futures Transfer for Sub-account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#futures-transfer-for-sub-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • asset (str) – required - The asset being transferred, e.g., USDT

  • amount (float) – 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 account to its spot account 3: 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

Returns

API response

{
    "txnId":"2966662589"
}
Raises

BinanceRequestException, BinanceAPIException

make_subaccount_margin_transfer(**params)

Margin Transfer for Sub-account (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#margin-transfer-for-sub-account-for-master-account

Parameters
  • email (str) – required - Sub account email

  • asset (str) – required - The asset being transferred, e.g., USDT

  • amount (float) – required - The amount to be transferred

  • type (int) – required - 1: transfer from subaccount’s spot account to margin account 2: transfer from subaccount’s margin account to its spot account

Returns

API response

{
    "txnId":"2966662589"
}
Raises

BinanceRequestException, BinanceAPIException

make_subaccount_to_master_transfer(**params)

Transfer to Master (For Sub-account)

https://binance-docs.github.io/apidocs/spot/en/#transfer-to-master-for-sub-account

Parameters
  • asset (str) – required - The asset being transferred, e.g., USDT

  • amount (float) – required - The amount to be transferred

  • recvWindow (int) – optional

Returns

API response

{
    "txnId":"2966662589"
}
Raises

BinanceRequestException, BinanceAPIException

make_subaccount_to_subaccount_transfer(**params)

Transfer to Sub-account of Same Master (For Sub-account)

https://binance-docs.github.io/apidocs/spot/en/#transfer-to-sub-account-of-same-master-for-sub-account

Parameters
  • toEmail (str) – required - Sub account email

  • asset (str) – required - The asset being transferred, e.g., USDT

  • amount (float) – required - The amount to be transferred

  • recvWindow (int) – optional

Returns

API response

{
    "txnId":"2966662589"
}
Raises

BinanceRequestException, BinanceAPIException

make_universal_transfer(**params)

Universal Transfer (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#universal-transfer-for-master-account

Parameters
  • fromEmail (str) – optional

  • toEmail (str) – optional

  • fromAccountType (str) – required - “SPOT”,”USDT_FUTURE”,”COIN_FUTURE”

  • toAccountType (str) – required - “SPOT”,”USDT_FUTURE”,”COIN_FUTURE”

  • asset (str) – required - The asset being transferred, e.g., USDT

  • amount (float) – required

  • recvWindow (int) – optional

Returns

API response

{
    "tranId":11945860693
}
Raises

BinanceRequestException, BinanceAPIException

margin_stream_close(listenKey)

Close out a cross-margin data stream.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-margin

Parameters

listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, 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.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-margin

Returns

API response

{
    "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
Raises

BinanceRequestException, BinanceAPIException

margin_stream_keepalive(listenKey)

PING a cross-margin data stream to prevent a time out.

https://binance-docs.github.io/apidocs/spot/en/#listen-key-margin

Parameters

listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, BinanceAPIException

new_transfer_history(**params)

Get future account transaction history list

https://binance-docs.github.io/apidocs/delivery/en/#new-future-account-transfer

order_limit(timeInForce='GTC', **params)

Send in a new limit order

Any order with an icebergQty MUST have timeInForce set to GTC.

Parameters
  • symbol (str) – required

  • side (str) – required

  • quantity (decimal) – required

  • price (str) – required

  • timeInForce (str) – default Good till cancelled

  • 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.

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, 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
  • symbol (str) – required

  • quantity (decimal) – required

  • price (str) – required

  • timeInForce (str) – default Good till cancelled

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

  • stopPrice (decimal) – Used with stop orders

  • icebergQty (decimal) – Used with iceberg orders

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_limit_sell(timeInForce='GTC', **params)

Send in a new limit sell order

Parameters
  • symbol (str) – required

  • quantity (decimal) – required

  • price (str) – required

  • timeInForce (str) – default Good till cancelled

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

  • stopPrice (decimal) – Used with stop orders

  • icebergQty (decimal) – Used with iceberg orders

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_market(**params)

Send in a new market order

Parameters
  • symbol (str) – required

  • side (str) – required

  • quantity (decimal) – required

  • quoteOrderQty (decimal) – 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 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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_market_buy(**params)

Send in a new market buy order

Parameters
  • symbol (str) – required

  • quantity (decimal) – 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.

  • newOrderRespType (str) – Set the response JSON. ACK, RESULT, or FULL; default: RESULT.

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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_market_sell(**params)

Send in a new market sell order

Parameters
  • symbol (str) – required

  • quantity (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 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

Returns

API response

See order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_oco_buy(**params)

Send in a new OCO buy order

Parameters
  • symbol (str) – 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.

  • price (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.

  • stopPrice (str) – required

  • stopLimitPrice (str) – If provided, stopLimitTimeInForce is required.

  • stopIcebergQty (decimal) – Used with STOP_LOSS_LIMIT leg to make an iceberg order.

  • stopLimitTimeInForce (str) – 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

Returns

API response

See OCO order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

order_oco_sell(**params)

Send in a new OCO sell order

Parameters
  • symbol (str) – 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.

  • price (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.

  • stopPrice (str) – required

  • stopLimitPrice (str) – If provided, stopLimitTimeInForce is required.

  • stopIcebergQty (decimal) – Used with STOP_LOSS_LIMIT leg to make an iceberg order.

  • stopLimitTimeInForce (str) – 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

Returns

API response

See OCO order endpoint for full response options

Raises

BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException

ping()

Test connectivity to the Rest API.

https://binance-docs.github.io/apidocs/spot/en/#test-connectivity

Returns

Empty array

{}
Raises

BinanceRequestException, BinanceAPIException

purchase_lending_product(**params)

Purchase Flexible Product

https://binance-docs.github.io/apidocs/spot/en/#purchase-flexible-product-user_data

query_subaccount_spot_summary(**params)

Query Sub-account Spot Assets Summary (For Master Account)

https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-spot-assets-summary-for-master-account

Parameters
  • email (str) – optional - Sub account email

  • page (int) – optional - default 1

  • size (int) – optional - default 10, max 20

  • recvWindow (int) – optional

Returns

API response

{
     "totalCount":2,
     "masterAccountTotalAsset": "0.23231201",
     "spotSubUserAssetBtcVoList":[
         {
             "email":"sub123@test.com",
             "totalAsset":"9999.00000000"
         },
         {
             "email":"test456@test.com",
             "totalAsset":"0.00000000"
         }
     ]
 }
Raises

BinanceRequestException, BinanceAPIException

query_universal_transfer_history(**params)

Query User Universal Transfer History

https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history

Parameters
  • type (str (ENUM)) – required

  • startTime (int) – optional

  • endTime (int) – optional

  • current (int) – optional - Default 1

  • size (int) – required - Default 10, Max 100

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

transfer_status = client.query_universal_transfer_history(params)
Returns

API response

{
    "total":2,
    "rows":[
        {
            "asset":"USDT",
            "amount":"1",
            "type":"MAIN_UMFUTURE"
            "status": "CONFIRMED",
            "tranId": 11415955596,
            "timestamp":1544433328000
        },
        {
            "asset":"USDT",
            "amount":"2",
            "type":"MAIN_UMFUTURE",
            "status": "CONFIRMED",
            "tranId": 11366865406,
            "timestamp":1544433328000
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

redeem_lending_product(**params)

Redeem Flexible Product

https://binance-docs.github.io/apidocs/spot/en/#redeem-flexible-product-user_data

repay_margin_loan(**params)

Repay loan in cross-margin or isolated-margin account.

If 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
  • asset (str) – name of the asset

  • amount (str) – amount to transfer

  • isIsolated (str) – set to ‘TRUE’ for isolated margin (default ‘FALSE’)

  • symbol (str) – Isolated margin symbol (default blank for cross-margin)

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

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

transaction = client.margin_repay_loan(asset='BTC', amount='1.1', 
                                        isIsolated='TRUE', symbol='ETHBTC')
Returns

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

stream_close(listenKey)

Close out a user data stream.

https://binance-docs.github.io/apidocs/spot/en/#close-user-data-stream-user_stream

Parameters

listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, 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.

https://binance-docs.github.io/apidocs/spot/en/#start-user-data-stream-user_stream

Returns

API response

{
    "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
Raises

BinanceRequestException, BinanceAPIException

stream_keepalive(listenKey)

PING a user data stream to prevent a time out.

https://binance-docs.github.io/apidocs/spot/en/#keepalive-user-data-stream-user_stream

Parameters

listenKey (str) – required

Returns

API response

{}
Raises

BinanceRequestException, BinanceAPIException

toggle_bnb_burn_spot_margin(**params)

Toggle BNB Burn On Spot Trade And Margin Interest

https://binance-docs.github.io/apidocs/spot/en/#toggle-bnb-burn-on-spot-trade-and-margin-interest-user_data

Parameters
  • spotBNBBurn (bool) – 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

response = client.toggle_bnb_burn_spot_margin()
Returns

API response

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

BinanceRequestException, BinanceAPIException

transfer_dust(**params)

Convert dust assets to BNB.

https://binance-docs.github.io/apidocs/spot/en/#dust-transfer-user_data

Parameters
  • asset (str) – The asset being converted. e.g: ‘ONE’

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

result = client.transfer_dust(asset='ONE')
Returns

API response

{
    "totalServiceCharge":"0.02102542",
    "totalTransfered":"1.05127099",
    "transferResult":[
        {
            "amount":"0.03000000",
            "fromAsset":"ETH",
            "operateTime":1563368549307,
            "serviceChargeAmount":"0.00500000",
            "tranId":2970932918,
            "transferedAmount":"0.25000000"
        }
    ]
}
Raises

BinanceRequestException, BinanceAPIException

transfer_history(**params)

Get future account transaction history list

https://binance-docs.github.io/apidocs/futures/en/#get-future-account-transaction-history-list-user_data

transfer_isolated_margin_to_spot(**params)

Execute transfer between isolated margin account and spot account.

https://binance-docs.github.io/apidocs/spot/en/#isolated-margin-account-transfer-margin

Parameters
  • asset (str) – name of the asset

  • symbol (str) – pair symbol

  • amount (str) – amount to transfer

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

transfer = client.transfer_isolated_margin_to_spot(asset='BTC', 
                                                    symbol='ETHBTC', amount='1.1')
Returns

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

transfer_margin_to_spot(**params)

Execute transfer between cross-margin account and spot account.

https://binance-docs.github.io/apidocs/spot/en/#cross-margin-account-transfer-margin

Parameters
  • asset (str) – name of the asset

  • amount (str) – amount to transfer

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

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

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

transfer_spot_to_isolated_margin(**params)

Execute transfer between spot account and isolated margin account.

https://binance-docs.github.io/apidocs/spot/en/#isolated-margin-account-transfer-margin

Parameters
  • asset (str) – name of the asset

  • symbol (str) – pair symbol

  • amount (str) – amount to transfer

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

transfer = client.transfer_spot_to_isolated_margin(asset='BTC', 
                                                    symbol='ETHBTC', amount='1.1')
Returns

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

transfer_spot_to_margin(**params)

Execute transfer between spot account and cross-margin account.

https://binance-docs.github.io/apidocs/spot/en/#cross-margin-account-transfer-margin

Parameters
  • asset (str) – name of the asset

  • amount (str) – amount to transfer

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

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

API response

{
    "tranId": 100000001
}
Raises

BinanceRequestException, BinanceAPIException

universal_transfer(**params)

Unviversal transfer api accross different unicorn_binance_rest_api account types

https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer

withdraw(**params)

Submit a withdraw request.

https://www.binance.com/restapipub.html

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
  • coin (str) – required

  • withdrawOrderId (str) – optional - client id for withdraw

  • network (str) – optional

  • address (str) – optional

  • amount (decimal) – required

  • transactionFeeFlag (bool) – 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.

  • name (str) – optional - Description of the address, default asset value passed will be used

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

Returns

API response

{
    "id":"7213fea8e94b4a5593d507237e5a555b"
}
Raises

BinanceRequestException, BinanceAPIException, BinanceWithdrawException

Module contents