A complete async Python client for Deribit Options Market (REST & WebSocket)
Project description
Deribit Options Client
A complete, async Python client for the Deribit Options Market, supporting both REST and WebSocket protocols.
Features
- Asyncio-native: Built on
aiohttpandwebsockets. - Dual Protocol: Seamlessly use REST for one-off requests and WebSockets for streaming.
- Unified Client: Access both
restandwsinterfaces through a singleDeribitClient. - Authentication: Supports Client Credentials flow for private endpoints.
- Generic Support: Helper methods for common actions (Buy, Sell, Get Instruments), plus generic
public_request,private_request, andsend_requestmethods to access any Deribit endpoint.
Installation
pip install .
(Or install dependencies manually: pip install aiohttp websockets)
Usage
Initialization
from deribit import DeribitClient
# For Testnet, set testnet=True
client = DeribitClient(client_id="YOUR_ID", client_secret="YOUR_SECRET", testnet=False)
REST API
# Public
instruments = await client.rest.get_instruments("BTC")
# Private (auto-authenticates)
positions = await client.rest.get_positions("BTC")
buy_order = await client.rest.buy("BTC-29MAR24-50000-C", 1.0, price=0.05)
WebSocket API
await client.ws.connect()
def on_message(data):
print(data)
# Subscribe with callback
await client.ws.subscribe(["trades.BTC-PERPETUAL.100ms"], on_message)
# Send request via WS
instruments = await client.ws.get_instruments("BTC")
Generic Requests
If a specific method wrapper is missing, you can call any endpoint directly:
# REST
res = await client.rest.private_request("private/get_user_trades_by_currency", {"currency": "BTC"})
# WebSocket
res = await client.ws.send_request("private/get_user_trades_by_currency", {"currency": "BTC"})
Structure
deribit.rest: Handles HTTP requests, session management, and token refresh.deribit.ws: Handles persistent WebSocket connection, subscription management, and request/response correlation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deribit_py-0.1.0.tar.gz.
File metadata
- Download URL: deribit_py-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9bee0a178aef5fe4c46b6ad3cff59c7b8aa29a1469f4775580189a09de1792d
|
|
| MD5 |
186fa8df3d3a89b895a9dc4c94c2c7c9
|
|
| BLAKE2b-256 |
21e6e9cb0f54eda5ff18cb62eea04e2389d94e72898d0eb8477799c8ff8b9e4c
|
File details
Details for the file deribit_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: deribit_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c99082076a765b0e1d31f3f9b489425f5b6d1b0f1a40ae8bd3c3ec08b45ba45
|
|
| MD5 |
aaf6b3bc0814a4c3d12ecc42d7d39ac2
|
|
| BLAKE2b-256 |
f0b8c569ed1439530c6def9110fdfc0c2f94694eb81080136af73fcaa8d322de
|