bytx

mcp
Security Audit
Pass
Health Pass
  • License — License: NOASSERTION
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Community trust — 206 GitHub stars
Code Pass
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

bytx — typed async Python SDK for crypto exchanges by BYTtrade

README.md

bytx — by BYTtrade

English | Русский | 中文 | Español | Português | 日本語 | 한국어 | Türkçe

PyPI
Python
License

A typed async Python SDK for crypto exchanges. One interface for spot and perpetual futures on
Binance, Bybit, OKX, BingX, Hyperliquid, KuCoin, Bitget; in beta: Gate, MEXC, HTX, BloFin (spot and USDT-M futures).

One API for every exchange

pip install bytx            # + extras: [ws] [fast]

Quick start

import asyncio
from bytx import create_exchange

async def main():
    async with create_exchange('bybit', api_key='…', secret='…', demo=True) as ex:
        print(await ex.ticker('BTC/USDT'))                      # BTC/USDT:USDT, swap by default
        order = await ex.buy('BTC/USDT', notional=100, price=60_000, post_only=True)
        print(order.status, order.size)                         # size in BTC, not in contracts
        await ex.cancel_order('BTC/USDT', order.id)

asyncio.run(main())

OKX and Bitget perpetuals: pass the margin mode — create_exchange('okx', …, margin_mode='cross').
Without it the first order raises ConfigError: bytx never guesses the margin mode for you.

demo=True uses the exchange's demo/testnet; no real money involved. Market data needs no keys at all:
create_exchange('okx').

Take-profit and stop-loss — one call on every exchange:

await ex.set_tp_sl('BTC/USDT', take_profit=72_000, stop_loss=58_000)

A live order book that survives disconnects:

async for book in ex.stream.order_book('BTC/USDT', depth=20):
    print(book.best_bid, book.best_ask, book.spread_bps, book.imbalance(5))

Live order book

Paper trading on the live order book — no keys, no real money:

from bytx.paper import PaperConfig

ex = create_exchange('binance', paper=True, paper_config=PaperConfig(balance={'USDT': 1000}))
order = await ex.buy('BTC/USDT', notional=100)     # walks the book, real taker fee

Paper trading

Spot, execution algorithms, risk-based sizing:

spot = create_exchange('okx', market='spot', api_key=…, secret=…, password=…, demo=True)
await spot.buy('DOGE/USDT', notional=10)                              # market buy for 10 USDT, one request
await ex.algos.twap('BTC/USDT', 'buy', size=0.5, duration=600)       # also chase, iceberg, bracket, trailing_stop
await ex.open_position('BTC/USDT', 'long', risk_usdt=50, stop=58_000) # size from the stop distance

More in examples/: market data, backtest, arbitrage
scanner, grid, DCA, Telegram alerts, scalper, multi-account, strategy with restart recovery.

Why bytx

bytx is built on ccxt and turns it into a trading SDK you don't have to fight.

  • One line instead of a page. buy('BTC/USDT', notional=100) — no contract sizes, precision or
    minimums to compute by hand; size in the base coin on every exchange.
  • No double entries. On a timeout bytx finds the order by client_id and tells you exactly what
    happened (OrderStatusUnknown only when the exchange really can't say).
  • Same call everywhere. TP/SL, leverage, margin and position mode, dead-man switch, transfers — one
    method instead of each exchange's private endpoints.
  • WebSocket that stays up. Reconnect with backoff, silence watchdog, resubscribe, order book gap
    checks and resync from a snapshot.
  • Checked against the exchange docs. Every exchange rule is tested against response examples from the
    official documentation; ccxt bugs found this way are fixed in the SDK.
  • Typed models and clear errors. Order, Position, OrderBook dataclasses; one BytxError
    hierarchy with a .retryable flag; keys never appear in error text or logs.
  • Ready for production. A proxy per account, one market cache per process, paper trading and replay,
    a position journal, API-key permission checks and exchange health.
Raw ccxt vs bytx: buy BTC for 100 USDT on OKX perpetuals
# raw ccxt
ex = ccxt.okx({'apiKey': key, 'secret': secret, 'password': passphrase})
await ex.load_markets()
m = ex.market('BTC/USDT:USDT')
price = (await ex.fetch_ticker(m['symbol']))['last']
contracts = 100 / price / m['contractSize']               # OKX: 1 contract = 0.01 BTC
amount = float(ex.amount_to_precision(m['symbol'], contracts))
if amount < m['limits']['amount']['min']:
    raise ValueError('order too small')
order = await ex.create_order(m['symbol'], 'market', 'buy', amount)   # dict, amount in contracts
# bytx
async with bytx.create_exchange('okx', api_key=key, secret=secret, password=passphrase,
                                margin_mode='cross') as ex:
    order = await ex.buy('BTC/USDT', notional=100)        # Order model, size in BTC

No-code bots, backtests and trade confirmations in Telegram — at byttrade.com.

Documentation

The full guide — every method, exchange specifics, errors, recovery after a restart:
docs/GUIDE.md
(на русском).

Features ·
Spot ·
WebSocket ·
Scalping ·
Paper trading ·
Algorithms ·
Risk sizing ·
Restart recovery ·
Proxies ·
Integrations ·
Errors

License

Free to use under the BYTtrade Source-Available License,
including commercially; copying the code into other libraries, modified versions and hosted services are not
permitted. Uses ccxt (MIT), see NOTICE.
Not financial advice; trading cryptocurrency carries a risk of loss.

Reviews (0)

No results found