Binance

Binance-only functions

Binance Spot

The names of the functions related to the Binance spot start with privateAPI.binance_.


1. Get Account Information

privateAPI.binance_account_info() -> dict

Get an account information, including the balance, fee rate, and etc.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


2. Get Asset Balance

privateAPI.binance_asset_balance(asset: str) -> dict

Get the tradable amount(free) and locked amount(locked) of the asset in the Binance spot account.

This function filters the elements of the balance value in the response of the binance_account_info().

Arguments

  • asset : (string) The name of the asset to get the balance.

Response

  • asset : (string) The name of the asset.

  • free : (string) The tradable amount of the asset.

  • locked : (string) The amount of locked asset.

# response example
{ 
    "asset": "BTC",
    "free": "4723846.89208129",
    "locked": "0.00000000"
}

3. Market Order by Amount

privateAPI.binance_market_order_by_amount(amount: float, symbol: str, orderside: str) -> dict

Create a new market order. In this function, the currency of the amount is a base asset. For example, If the symbol = 'BTCUSDT'(base asset = BTC, quote asset = USDT) and amount=0.15, then it creates an order of size 0.15 BTC.

API Documentation

Arguments

  • amount : (float) The amount of the order.

  • symbol : (string) The name of the symbol to trade.

  • orderside : (string) To buy, set it as 'buy', or 'sell' to sell.

Response

Same as the response in the API documentation.


4. Market Order by Quote Asset Quantity

privateAPI.binance_market_order_by_quote_qty(quoteqty: float, symbol: str, orderside: str) -> dict

Create a new market order by the amount of the order in the quote asset. In this function, the currency of the amount is a quote asset. For example, If the symbol = 'BTCUSDT'(base asset = BTC, quote asset = USDT) and quoteqty=120, then it creates an order of size 120 USDT.

API Documentation

Arguments

  • quoteqty : (float) The amount of the order in quote asset.

  • symbol : (string) The name of the symbol to trade.

  • orderside : (string) To buy, set it as 'buy', or 'sell' to sell.

Response

Same as the response in the API documentation.


5. Limit Order by Amount

privateAPI.binance_limit_order_by_amount(amount: float, price: float, symbol: str, orderside: str) -> dict

Create a new limit order. In this function, the currency of the amount is a base asset.

API Documentation

Arguments

  • amount : (float) The amount of the order.

  • price : (float) The price for the order to be filled.

  • symbol : (string) The name of the symbol to trade.

  • orderside : (string) To buy, set it as 'buy', or 'sell' to sell.

Response

Same as the response in the API documentation.


6. Cancel Orders on Symbol

privateAPI.binance_cancel_orders_on_symbol(symbol: str) -> any

Cancel all open orders of the symbol.

API Documentation

Arguments

  • symbol : (string) The name of the symbol to cancel.

Response

Same as the response in the API documentation.


Binance USDⓈ-M Futures

The names of the functions related to the Binance USDⓈ-M futures start with privateAPI.binance_futures_.

1. Get Account Balance

privateAPI.binance_futures_account_balance() -> list

Get the balance of the assets in the Binance USD-M futures account.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


2. Get Account Information

privateAPI.binance_futures_account_info() -> dict

Get the account information of the Binance USDⓈ-M futures account.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


3. Get Position Information

privateAPI.binance_futures_position_info() -> list

Get the open position information of the Binance USDⓈ-M futures account.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


4. Market Order

privateAPI.binance_futures_market_order(leverage: int, symbol: str, side: str, qty: float) -> dict

Set the leverage of the symbol and create a market order.

API Documentation

Arguments

  • leverage : (int) The leverage value to set.

  • symbol : (string) The name of the symbol.

  • side : (string) 'BUY' to open long & close short position, or 'SELL' to open short & close long position.

  • qty : (float) The contract size to set order. In most case, it is the amount in base asset. For instance, symbol=ETHUSDT, and qty=0.12 will create an order of contract size 0.12 ETH.

Response

Same as the response in the API documentation.


5. Limit Order

privateAPI.binance_futures_limit_order(leverage: int, symbol: str, side: str, qty: float, price: float) -> dict

Set the leverage of the symbol and create a limit order.

API Documentation

Arguments

  • leverage : (int) The leverage value to set.

  • symbol : (string) The name of the symbol.

  • side : (string) 'BUY' to open long & close short position, or 'SELL' to open short & close long position.

  • qty : (float) The contract size to set order. In most case, it is the amount in base asset. For instance, symbol=ETHUSDT and qty=0.12 will create an order of contract size 0.12 ETH.

  • price : (float) The price for the order to be filled.

Response

Same as the response in the API documentation.


6. Cancel Orders on Symbol

privateAPI.binance_futures_cancel_orders_on_symbol(symbol: str) -> any

Cancel all open orders of the symbol.

API Documentation

Arguments

  • symbol : (string) The name of the symbol to cancel.

Response

Same as the response in the API documentation.


Binance COIN-M Futures

The names of the functions related to the Binance COIN-M futures start with privateAPI.binance_cm_futures_.

1. Get Account Information

privateAPI.binance_cm_futures_account_info() -> dict

Get the account information in the Binance COIN-M Futures account.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


2. Get Position Information

privateAPI.binance_cm_futures_position_info() -> list

Get the open position information in the Binance COIN-M Futures account.

API Documentation

Arguments

None

Response

Same as the response in the API documentation.


3. Market Order

privateAPI.binance_cm_futures_market_order(leverage: int, symbol: str, side: str, qty: float) -> dict

Set the leverage of the symbol and create a market order.

API Documentation

Arguments

  • leverage : (int) The leverage value to set.

  • symbol : (string) The name of the symbol.

  • side : (string) 'BUY' to open long & close short position, or 'SELL' to open short & close long position.

  • qty : (float) The size of the contract(=CONT) to set order. In most case, 1 CONT is a size of 10 USD, while some symbols such as BTCUSD have 1 CONT as 100 USD. For instance, symbol=ETHUSD and qty=20 will create an order of ETHUSD with the contract size 200 USD, but symbol=BTCUSD and qty=20 will create an order of BTCUSD with the contract size 2000 USD.

Response

Same as the response in the API documentation.


4. Limit Order

privateAPI.binance_cm_futures_limit_order(leverage: int, symbol: str, side: str, qty: float, price: float) -> dict

Set the leverage of the symbol and create a limit order.

API Documentation

Arguments

  • leverage : (int) The leverage value to set.

  • symbol : (string) The name of the symbol.

  • side : (string) 'BUY' to open long & close short position, or 'SELL' to open short & close long position.

  • qty : (float) The size of the contract(=CONT) to set order. In most case, 1 CONT is a size of 10 USD, while some symbols such as BTCUSD have 1 CONT as 100 USD. For instance, symbol=ETHUSD and qty=20 will create an order of ETHUSD with the contract size 200 USD, but symbol=BTCUSD and qty=20 will create an order of BTCUSD with the contract size 2000 USD.

  • price : (float) The price for the order to be filled.

Response

Same as the response in the API documentation.


5. Cancel Orders on Symbol

privateAPI.binance_cm_futures_cancel_orders_on_symbol(symbol: str) -> any

Cancel all open orders of the symbol.

API Documentation

Arguments

  • symbol : (string) The name of the symbol to cancel.

Response

Same as the response in the API documentation.

Last updated

Copyright © 2023, UnBlinked Co., Ltd. | All rights reserved.