bybit
This commit is contained in:
104
docs/exchanges/bybit/README.md
Normal file
104
docs/exchanges/bybit/README.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Bybit Exchange Integration Documentation
|
||||
|
||||
## Overview
|
||||
This documentation covers the integration of Bybit exchange using the official pybit Python library.
|
||||
|
||||
**Library:** [pybit](https://github.com/bybit-exchange/pybit)
|
||||
**Version:** 5.11.0 (Latest as of 2025-01-26)
|
||||
**Official Repository:** https://github.com/bybit-exchange/pybit
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
pip install pybit
|
||||
```
|
||||
|
||||
## Requirements
|
||||
- Python 3.9.1 or higher
|
||||
- API credentials (BYBIT_API_KEY and BYBIT_API_SECRET)
|
||||
|
||||
## Basic Usage
|
||||
|
||||
### HTTP Session Creation
|
||||
```python
|
||||
from pybit.unified_trading import HTTP
|
||||
|
||||
# Create HTTP session
|
||||
session = HTTP(
|
||||
testnet=False, # Set to True for testnet
|
||||
api_key="your_api_key",
|
||||
api_secret="your_api_secret",
|
||||
)
|
||||
```
|
||||
|
||||
### Common Operations
|
||||
|
||||
#### Get Orderbook
|
||||
```python
|
||||
# Get orderbook for BTCUSDT perpetual
|
||||
orderbook = session.get_orderbook(category="linear", symbol="BTCUSDT")
|
||||
```
|
||||
|
||||
#### Place Order
|
||||
```python
|
||||
# Place a single order
|
||||
order = session.place_order(
|
||||
category="linear",
|
||||
symbol="BTCUSDT",
|
||||
side="Buy",
|
||||
orderType="Limit",
|
||||
qty="0.001",
|
||||
price="50000"
|
||||
)
|
||||
```
|
||||
|
||||
#### Batch Orders (USDC Options only)
|
||||
```python
|
||||
# Create multiple orders (USDC Options support only)
|
||||
payload = {"category": "option"}
|
||||
orders = [{
|
||||
"symbol": "BTC-30JUN23-20000-C",
|
||||
"side": "Buy",
|
||||
"orderType": "Limit",
|
||||
"qty": "0.1",
|
||||
"price": str(15000 + i * 500),
|
||||
} for i in range(5)]
|
||||
|
||||
payload["request"] = orders
|
||||
session.place_batch_order(payload)
|
||||
```
|
||||
|
||||
## Categories
|
||||
- **linear**: USDT Perpetuals (BTCUSDT, ETHUSDT, etc.)
|
||||
- **inverse**: Inverse Perpetuals
|
||||
- **option**: USDC Options
|
||||
- **spot**: Spot trading
|
||||
|
||||
## Key Features
|
||||
- Official Bybit library maintained by Bybit employees
|
||||
- Lightweight with minimal external dependencies
|
||||
- Support for both HTTP and WebSocket APIs
|
||||
- Active development and quick API updates
|
||||
- Built-in testnet support
|
||||
|
||||
## Dependencies
|
||||
- `requests` - HTTP API calls
|
||||
- `websocket-client` - WebSocket connections
|
||||
- Built-in Python modules
|
||||
|
||||
## Trading Pairs
|
||||
- BTC/USDT perpetuals
|
||||
- ETH/USDT perpetuals
|
||||
- Various altcoin perpetuals
|
||||
- Options contracts
|
||||
- Spot markets
|
||||
|
||||
## Environment Variables
|
||||
- `BYBIT_API_KEY` - Your Bybit API key
|
||||
- `BYBIT_API_SECRET` - Your Bybit API secret
|
||||
|
||||
## Integration Notes
|
||||
- Unified trading interface for all Bybit products
|
||||
- Consistent API structure across different categories
|
||||
- Comprehensive error handling
|
||||
- Rate limiting compliance
|
||||
- Active community support via Telegram and Discord
|
||||
Reference in New Issue
Block a user