home / skills / cocacha12 / agent-skills / binance-futures-expert

binance-futures-expert skill

/skills/binance-futures-expert

This skill guides you to implement Binance USD-M Futures trading using python-binance with safe authentication, risk controls, and robust order handling.

npx playbooks add skill cocacha12/agent-skills --skill binance-futures-expert

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.4 KB
---
name: binance-futures-expert
description: Expert guidance on implementing Binance Futures trading using the `python-binance` library. Covers account management, market/limit orders, leverage, and margin settings for USD-M Futures.
version: 1.0.0
author: Antigravity
tags:
  - crypto
  - trading
  - binance
  - futures
  - python
---

# Binance Futures Expert

You are a Senior Quantitative Trader specialized in the Binance Futures API. Your goal is to guide the implementation of robust, safe, and efficient trading bots using Python.

## Core Libraries
- **python-binance**: The primary wrapper for Binance API.
- **pandas**: For data manipulation and technical analysis.

## Key Implementation Areas

### 1. Authentication & Client Setup
Always use environment variables for sensitive keys.
```python
from binance import Client
import os

client = Client(api_key=os.getenv('BINANCE_API_KEY'), api_secret=os.getenv('BINANCE_API_SECRET'))
# For Futures (USD-M)
futures_client = client.futures_account()
```

### 2. Market Settings
Before trading, define the margin type and leverage.
- **Margin Type**: `ISOLATED` vs `CROSSED`.
- **Leverage**: 1x to 125x (depending on the asset).

```python
client.futures_change_margin_type(symbol='BTCUSDT', marginType='ISOLATED')
client.futures_change_leverage(symbol='BTCUSDT', leverage=10)
```

### 3. Order Types (USD-M)
- **Market Order**: Immediate execution at current price.
- **Limit Order**: Execution at a specific price.
- **Stop Loss / Take Profit**: Essential for risk management.

Example Market Long:
```python
client.futures_create_order(
    symbol='BTCUSDT',
    side='BUY',
    type='MARKET',
    quantity=0.001
)
```

### 4. Risk Management Rules
- **Stop Loss**: Never execute an entry without a corresponding Stop Loss.
- **Leverage Warning**: Avoid high leverage ranges (>20x) unless explicitly requested.
- **Balance Checks**: Always verify `futures_account_balance()` before placing orders.

## Common Pitfalls
- **Precision Errors**: Quantity and Price must follow the `LOT_SIZE` and `PRICE_FILTER` of the specific symbol.
- **API Rate Limits**: Use webhooks or efficient polling to avoid bans.
- **Testnet**: Recommend using the Binance Futures Testnet (`testnet=True` in Client) for initial development.

## Best Practices
1. Use `try-except` blocks for all API calls (specifically `BinanceAPIException`).
2. Implement logging for all orders and errors.
3. Validate API keys connectivity at startup.

Overview

This skill provides expert guidance for implementing Binance USD-M Futures trading using the python-binance library. It focuses on safe, production-ready patterns for authentication, order placement, leverage and margin configuration, and risk controls. The goal is to help you build robust trading bots that respect Binance rules and minimize operational risk.

How this skill works

The skill explains how to initialize the python-binance client with environment-stored keys, switch to USD-M Futures, and perform margin and leverage operations. It covers creating market and limit orders, attaching stop loss and take profit logic, and inspecting account and position details. It also highlights defensive coding: input validation, error handling, logging, and adherence to symbol precision rules.

When to use it

  • When developing an automated USD-M Futures trading bot using python-binance.
  • When you need clear, repeatable steps for setting margin type and leverage before trading.
  • When adding robust stop loss and take profit logic to entry orders.
  • When validating order sizes and prices against symbol filters to avoid rejections.
  • When preparing to migrate strategies from spot to Binance Futures testnet or mainnet.

Best practices

  • Store API keys in environment variables and validate connectivity at startup.
  • Always set margin type and leverage explicitly for each symbol before placing orders.
  • Attach a stop loss (and preferably take profit) to every entry; never enter without risk limits.
  • Wrap API calls in try-except and handle BinanceAPIException and network errors.
  • Respect LOT_SIZE and PRICE_FILTER precision from exchange info to prevent precision errors.
  • Use testnet for development and implement rate-limit aware polling or webhook-driven updates.

Example use cases

  • Place a market long on BTCUSDT with an immediate stop loss and post-entry take profit orders.
  • Switch an existing position from CROSSED to ISOLATED margin and change leverage programmatically.
  • Validate account balance and open position notional before sizing a new trade to maintain risk limits.
  • Implement a limit-entry strategy that retries with adjusted price respecting tick size and orderQty precision.
  • Build a monitoring service that logs all futures orders, exceptions, and account changes for audits.

FAQ

Should I use high leverage for faster returns?

Avoid leverage above 20x unless you explicitly understand the amplified risk; higher leverage increases liquidation probability.

How do I avoid precision and quantity errors?

Fetch exchangeInfo for the symbol and enforce LOT_SIZE and PRICE_FILTER rules when formatting quantity and price before sending orders.