Skip to content

Latest commit

 

History

History
161 lines (101 loc) · 4.05 KB

File metadata and controls

161 lines (101 loc) · 4.05 KB

Account Endpoints

Orders

Order Validation

Binance has a number of rules around symbol pair orders with validation on minimum price, quantity and total order value.

Read more about their specifics in the Filters section of the official API.

It can be helpful to format the output using the following snippet

amount = 0.000234234
precision = 5
amt_str = "{:0.0{}f}".format(amount, precision)
orders = client.get_all_orders(symbol='BNBBTC', limit=10)

Place an order

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

from binance.enums import *
order = client.create_order(
    symbol='BNBBTC',
    side=SIDE_BUY,
    type=ORDER_TYPE_LIMIT,
    timeInForce=TIME_IN_FORCE_GTC,
    quantity=100,
    price='0.00001')

Place a limit order

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

order = client.order_limit_buy(
    symbol='BNBBTC',
    quantity=100,
    price='0.00001')

order = client.order_limit_sell(
    symbol='BNBBTC',
    quantity=100,
    price='0.00001')

Place a market order

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

order = client.order_market_buy(
    symbol='BNBBTC',
    quantity=100)

order = client.order_market_sell(
    symbol='BNBBTC',
    quantity=100)

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

from binance.enums import *
order = client.create_test_order(
    symbol='BNBBTC',
    side=SIDE_BUY,
    type=ORDER_TYPE_LIMIT,
    timeInForce=TIME_IN_FORCE_GTC,
    quantity=100,
    price='0.00001')
order = client.get_order(
    symbol='BNBBTC',
    orderId='orderId')
result = client.cancel_order(
    symbol='BNBBTC',
    orderId='orderId')
orders = client.get_open_orders(symbol='BNBBTC')
orders = client.get_all_orders(symbol='BNBBTC')

Account

info = client.get_account()
balance = client.get_asset_balance(asset='BTC')
status = client.get_account_status()
trades = client.get_my_trades(symbol='BNBBTC')