Binance

from binance import Client
from binance.helpers import round_step_size

API_KEY = None
API_SECRET = None
client = Client(api_key=API_KEY, api_secret=API_SECRET)
data = client.get_exchange_info()
df = pd.DataFrame(data['symbols'])
df
```python
trades = client.get_my_trades(symbol=symbol)
```
```python
prices = client.get_all_tickers()
price_dict = {p['symbol']:float(p['price']) for p in prices}
price_dict
```
```python
import pandas as pd
balances = client.get_account()['balances']
df = pd.DataFrame(balances)
df['free'] = df['free'].astype(float)
df = df[df['free'] > 0.000001]
df
```
```python
order = client.create_order(
    symbol='BNBBTC',
    side=Client.SIDE_BUY,
    type=Client.ORDER_TYPE_MARKET,
    quantity=0.127
    )
```
symbol = "ETHBTC"

round_quote_amt = round_step_size(float(related_amt), asset_mapping["tick_size"])
market_result = client.order_market_buy(
                symbol=symbol, 
                quoteOrderQty=round_quote_amt, 
                newOrderRespType="FULL"
                )
symbol = "ETHBTC"

round_asset_qty = round_step_size(float(related_amt), asset_mapping["step_size"])
market_result = client.order_market_sell(
                symbol=symbol, 
                quantity=round_asset_qty, 
                newOrderRespType="FULL"
                )

Last updated