Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a84a2ae
add timeout to jobs (#1556)
pcriadoperez Feb 19, 2025
1d3bbff
feat: add uiKlines support (#1555)
pcriadoperez Feb 22, 2025
be87758
fix: json_dumps when using orjson (#1553)
pcriadoperez Feb 22, 2025
1716ceb
fix: ws api not allowing to send over 100 requests (#1560)
pcriadoperez Feb 22, 2025
b02989d
feat: auto generate missing endpoints (#1529)
pcriadoperez Feb 24, 2025
d12d6a9
fix: return empty json instead of throwing error on empty response (#…
pcriadoperez Feb 26, 2025
028d6aa
feat: add options websocket market streams (#1563)
pcriadoperez Feb 26, 2025
ea4006f
Bump 0.28 (#1565)
carlosmiei Feb 27, 2025
80e1ff5
update gitignore (#1566)
carlosmiei Feb 27, 2025
06c721e
fix: async client receive empty text (#1569)
pcriadoperez Apr 3, 2025
9dac1d4
feat: Expose option for user to edit max_queue_size in websockets, ha…
pcriadoperez Apr 7, 2025
287f95d
fixed a deprecation warning in helpers.py (#1572)
ChuckTG Apr 7, 2025
94f28c9
Improve error handling for depth manager (#1579)
pcriadoperez Apr 21, 2025
dccb3d9
chore: update testnet urls (#1583)
pcriadoperez May 19, 2025
52877c0
chore: Bump 29 (#1585)
carlosmiei May 19, 2025
5ee540e
Ensure spot v3 version (#1587)
pcriadoperez Jun 4, 2025
5735603
docs: update websocket error docs (#1591)
pcriadoperez Jul 12, 2025
d18981e
feat: throw readloopclosed error if trying to connect once read loop …
pcriadoperez Jul 12, 2025
4b27d8c
Update of links in the docstrings (#1590)
yzh-pelle Jul 29, 2025
20ac112
all links updated (#1600)
yzh-pelle Aug 6, 2025
1d67cc4
fixed a typo in a method name (#1605)
luk0y Aug 25, 2025
efc2f5c
Set default `limit=None` for futures_historical_klines* (fetch full r…
meet-vasita Sep 15, 2025
3ce7b9c
feat: add demo trading support (#1610)
carlosmiei Sep 30, 2025
4257586
feat: websocket userdatastream.singature support, deprecate listenkey…
pcriadoperez Oct 10, 2025
e692c12
chore: bump to 1.0.30 (#1615)
carlosmiei Oct 14, 2025
ec3164e
fix(signature): encode non-ascii symbol (#1618)
carlosmiei Oct 29, 2025
d88c065
fix(client): handle non ascii symbols in public and private methods (…
carlosmiei Nov 3, 2025
d549914
chore: bump to 32 (#1621)
carlosmiei Nov 3, 2025
a76774b
fix conditional swap order (#1639)
pcriadoperez Dec 5, 2025
f16d34c
fix: reconnect keep alive (#1637)
pcriadoperez Dec 5, 2025
f82d5fb
chore: Bump to 1.0.33 (#1640)
carlosmiei Dec 6, 2025
a5617be
feat: add support for rpi orders (#1644)
pcriadoperez Dec 10, 2025
642eeab
fix: remove duplicate import and replace type() with isinstance() (#1…
xingarr Dec 10, 2025
ebfbd4e
docs: add missing doc references from async client (#1651)
pcriadoperez Dec 15, 2025
e04e2c7
feat: add support for websocket algo orders (#1646)
pcriadoperez Dec 15, 2025
8e536e6
fix(client): use proper exception instead of assert for US endpoints …
lorenjphillips Dec 15, 2025
0ac6d89
fix: fix #1647 support max_queue_size for futures_user_socket (#1649)
pcriadoperez Dec 15, 2025
18d88b8
feat: add verbose mode (#1638)
pcriadoperez Dec 15, 2025
8d9334a
feat: update futures ticker endpoint to v2 (#1650)
pcriadoperez Dec 15, 2025
ca52743
chore: bump to 1.0.34 (#1652)
carlosmiei Dec 16, 2025
9b9c9e9
chore: normalize package name (#1653)
carlosmiei Dec 16, 2025
6e4364d
fix: reconnects for websocket connection closed ok and ws-api (#1655)
pcriadoperez Jan 2, 2026
bbf04cd
feat: upgrade margin socket to use websocket api (#1670)
pcriadoperez Feb 13, 2026
8b92419
feat: Update futures algo order API with new TP/SL parameters (#1672)
paul-lestyo Feb 15, 2026
02ce388
Change delist schedule API request to unsigned (#1659)
m-HD Feb 17, 2026
8215039
chore: bump to 35 (#1673)
carlosmiei Feb 17, 2026
d8009cc
docs: add missing doc references from async client (#1665)
pcriadoperez Feb 17, 2026
6dd5d72
chore: fix changelog format (#1675)
carlosmiei Feb 17, 2026
5f1312a
chore: missing version formatting (#1676)
carlosmiei Mar 16, 2026
dc8d7b7
fix(client): sync get_spot_delist_schedule shouldn't be signed (#1674)
carlosmiei Mar 16, 2026
997d499
feat: update options streams to new api changes and fix CI (#1657)
pcriadoperez Mar 22, 2026
9ce7e68
feat: USD-M futures WebSocket URL category support (#1684)
pcriadoperez Mar 22, 2026
0b63172
fix: propagate connection errors to subscription queues (#1681)
pcriadoperez Mar 23, 2026
70a7a2a
chore: bump to 1.0.36 (#1686)
carlosmiei Mar 24, 2026
b697c97
feat: add LLM-friendly docs and agent skill (#1679)
pcriadoperez Mar 31, 2026
812f652
chore: update ids (#1692)
carlosmiei Jun 8, 2026
7d7b7fb
chore: bump to v1.0.37 (#1693)
carlosmiei Jun 8, 2026
04e51f6
feat: add support for Python 3.13 and 3.14
claude Aug 24, 2026
f881b9d
ci: don't fail-fast the test matrix
claude Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions .agents/skills/python-binance/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
name: python-binance
description: >
Help developers use the python-binance library for trading on Binance.
Use when code imports binance, references Client/AsyncClient, or asks
about Binance API trading, market data, websockets, or account management.
---

# python-binance SDK

Unofficial Python SDK for the Binance cryptocurrency exchange. 797+ methods covering Spot, Margin, Futures, Options, Portfolio Margin, and WebSocket APIs.

## Setup

```python
from binance import Client, AsyncClient

# Sync client
client = Client(api_key, api_secret)

# Async client
client = await AsyncClient.create(api_key, api_secret)

# Testnet
client = Client(api_key, api_secret, testnet=True)

# Demo/paper trading
client = Client(api_key, api_secret, demo=True)

# RSA key auth
client = Client(api_key, private_key=open("key.pem").read())

# Other TLD (Binance US, Japan, etc.)
client = Client(api_key, api_secret, tld="us")
```

## Critical Patterns

1. **All methods return plain Python dicts** — not custom objects. Access fields with `response["key"]`.
2. **`**params` kwargs** — most methods accept extra Binance API parameters as keyword arguments.
3. **Sync/async parity** — `Client` and `AsyncClient` have identical method names. Use `await` for async.
4. **Enums** — import from `binance.enums` or use string values directly (`"BUY"`, `"LIMIT"`, etc.).

## Method Naming Convention

This is the most important pattern — it lets you infer method names:

| Prefix | Domain | Example |
|--------|--------|---------|
| `get_*` / `create_*` / `cancel_*` | Spot | `get_order_book()`, `create_order()` |
| `futures_*` | USD-M Futures | `futures_create_order()` |
| `futures_coin_*` | Coin-M Futures | `futures_coin_create_order()` |
| `margin_*` | Margin | `margin_borrow_repay()` |
| `options_*` | Vanilla Options | `options_place_order()` |
| `papi_*` | Portfolio Margin | `papi_create_um_order()` |
| `ws_*` | WebSocket CRUD | `ws_create_order()` |
| `order_*` | Order helpers | `order_limit_buy()` |
| `stream_*` | User data stream | `stream_get_listen_key()` |

## Key Enums

```python
from binance.enums import *

SIDE_BUY, SIDE_SELL = "BUY", "SELL"
ORDER_TYPE_LIMIT, ORDER_TYPE_MARKET = "LIMIT", "MARKET"
ORDER_TYPE_STOP_LOSS_LIMIT = "STOP_LOSS_LIMIT"
TIME_IN_FORCE_GTC = "GTC" # Good till cancelled
TIME_IN_FORCE_IOC = "IOC" # Immediate or cancel
KLINE_INTERVAL_1MINUTE = "1m"
KLINE_INTERVAL_1HOUR = "1h"
KLINE_INTERVAL_1DAY = "1d"
FUTURE_ORDER_TYPE_MARKET = "MARKET"
FUTURE_ORDER_TYPE_LIMIT = "LIMIT"
```

## Common Tasks

### Get current price
```python
ticker = client.get_symbol_ticker(symbol="BTCUSDT")
print(ticker["price"]) # "50000.00000000"
```

### Get account balances
```python
account = client.get_account()
balances = [b for b in account["balances"] if float(b["free"]) > 0]
```

### Place a market buy order
```python
from binance.enums import *
order = client.create_order(
symbol="BTCUSDT",
side=SIDE_BUY,
type=ORDER_TYPE_MARKET,
quoteOrderQty=100 # spend 100 USDT
)
```

### Place a limit sell order
```python
order = client.create_order(
symbol="BTCUSDT",
side=SIDE_SELL,
type=ORDER_TYPE_LIMIT,
timeInForce=TIME_IN_FORCE_GTC,
quantity=0.001,
price="60000"
)
```

### Get order status
```python
order = client.get_order(symbol="BTCUSDT", orderId=12345)
print(order["status"]) # "FILLED", "NEW", "CANCELED"
```

### Cancel an order
```python
result = client.cancel_order(symbol="BTCUSDT", orderId=12345)
```

### Get historical klines (candlesticks)
```python
klines = client.get_historical_klines("BTCUSDT", Client.KLINE_INTERVAL_1HOUR, "1 day ago UTC")
# Each kline: [open_time, open, high, low, close, volume, close_time, ...]
```

### Get order book depth
```python
depth = client.get_order_book(symbol="BTCUSDT")
print(depth["bids"][:5]) # [[price, qty], ...]
```

### Futures: place an order
```python
order = client.futures_create_order(
symbol="BTCUSDT", side="BUY", type="MARKET", quantity=0.001
)
```

### Futures: get position info
```python
positions = client.futures_position_information(symbol="BTCUSDT")
```

## WebSocket Streaming

```python
from binance import ThreadedWebsocketManager

twm = ThreadedWebsocketManager(api_key=api_key, api_secret=api_secret)
twm.start()

def handle_message(msg):
print(msg)

twm.start_kline_socket(callback=handle_message, symbol="BTCUSDT")
twm.join()
```

### Async WebSocket
```python
from binance import AsyncClient, BinanceSocketManager

async def main():
client = await AsyncClient.create()
bsm = BinanceSocketManager(client)
async with bsm.trade_socket("BTCUSDT") as ts:
for _ in range(10):
msg = await ts.recv()
print(msg)
await client.close_connection()
```

## Error Handling

```python
from binance.exceptions import BinanceAPIException

try:
order = client.create_order(...)
except BinanceAPIException as e:
print(e.code) # e.g., -1013
print(e.message) # e.g., "Filter failure: LOT_SIZE"
print(e.status_code)
```

## Full Reference

For the complete method reference with all 797+ methods, signatures, and parameters, see:
- `llms-full.txt` in the repository root
- `Endpoints.md` for endpoint-to-method mapping
36 changes: 36 additions & 0 deletions .agents/skills/python-binance/references/REFERENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# python-binance Full Method Reference

This reference points to the comprehensive auto-generated method documentation.

## Primary Reference

The full method reference with all 797+ methods, their signatures and parameters is available at:

**[llms-full.txt](../../../../llms-full.txt)**

This file is auto-generated by `generate_llms_txt.py` and contains every public method in the `Client` class, organized by category:

- **Spot / General** — Market data, trading, account management, wallet operations
- **Futures USD-M** — USD-margined futures trading
- **Futures Coin-M** — Coin-margined futures trading
- **Margin** — Cross and isolated margin trading
- **Options** — Vanilla options trading
- **Portfolio Margin** — Portfolio margin (unified account) operations
- **WebSocket API** — Order management over WebSocket for low latency
- **WebSocket Futures** — Futures operations over WebSocket
- **Gift Card** — Binance gift card operations
- **Convert** — Crypto conversion operations

## Other References

- **[Endpoints.md](../../../../Endpoints.md)** — Maps every Binance API endpoint to its python-binance method
- **[Binance API Docs](https://developers.binance.com/docs/)** — Official Binance API documentation
- **[python-binance ReadTheDocs](https://python-binance.readthedocs.io/en/latest/)** — Official library documentation

## Regenerating

To regenerate the full reference after library updates:

```bash
python generate_llms_txt.py
```
38 changes: 22 additions & 16 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ permissions:
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Install Ruff
Expand All @@ -30,50 +31,55 @@ jobs:
run: ruff format --check .
continue-on-error: true

build:
test:
needs: lint
runs-on: ubuntu-22.04
timeout-minutes: 40
strategy:
fail-fast: false
max-parallel: 2
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
env:
PROXY: "http://51.83.140.52:16301"
PROXY: "http://188.245.226.105:8911"
TEST_TESTNET: "true"
TEST_API_KEY: "u4L8MG2DbshTfTzkx2Xm7NfsHHigvafxeC29HrExEmah1P8JhxXkoOu6KntLICUc"
TEST_API_SECRET: "hBZEqhZUUS6YZkk7AIckjJ3iLjrgEFr5CRtFPp5gjzkrHKKC9DAv4OH25PlT6yq5"
TEST_FUTURES_API_KEY: "227719da8d8499e8d3461587d19f259c0b39c2b462a77c9b748a6119abd74401"
TEST_FUTURES_API_SECRET: "b14b935f9cfacc5dec829008733c40da0588051f29a44625c34967b45c11d73c"
strategy:
max-parallel: 1
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Checking env
run: |
echo "PROXY: $PROXY"
env
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
echo "Python version: ${{ matrix.python-version }}"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pyright tox
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Type check with pyright
- name: Id Tests
run: pytest tests/test_ids.py
- name: Type check with pyright (Python 3.12 only)
if: matrix.python-version == '3.12'
run: pyright
- name: Test with tox
run: tox -e py
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true
finish:
needs: build
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ python_binance.egg-info/
.idea/
venv*/
.vscode
.binance/
Loading