Skip to main content

A production-ready Python client for the OneBullEx Exchange API

Project description

OneBullEx Python Client

A production-ready, typed, and robust Python client for the OneBullEx Exchange API.

Designed for trading systems and quantitative infrastructure, offering:

  • Clean Architecture: Strict separation of transport, authentication, and business logic.
  • Robustness: Connection pooling, exponential backoff retries, and strict timeouts.
  • Type Safety: Pydantic models for all major interactions.
  • Safety: Proactive rate limiting and idempotent-aware retry logic.

Installation

pip install requests pydantic
pip install -e .

Quick Start

Public Data

from onebullex import OneBullExClient

# Initialize (defaults to PROD environment)
client = OneBullExClient()

# Get Market Summary
summary = client.market.summary()
print(summary)

# Get Orderbook
depth = client.market.orderbook("BTCUSDT")
print(f"Best Bid: {depth['bids'][0]}")

Authenticated Trading

from onebullex import OneBullExClient
from onebullex.models.orders import PlaceSpotOrder, OrderSide, OrderType

client = OneBullExClient(
    api_key="YOUR_API_KEY",
    secret="YOUR_SECRET",
    identify="YOUR_IDENTIFY_CODE"
)

# Place a Limit Order
order = PlaceSpotOrder(
    symbol="BTCUSDT",
    side=OrderSide.BUY,
    orderType=OrderType.LIMIT,
    price="45000.0",
    quantity="0.001"
)

try:
    response = client.orders.place(order)
    print(f"Order Placed: {response}")
except Exception as e:
    print(f"Trading Error: {e}")

Architecture

This client treats infrastructure as code:

  • onebullex.transport: Low-level HTTP/WebSocket handling with requests.Session.
  • onebullex.auth: Signer class for HMAC-SHA256 signatures with automatic server-time drift correction.
  • onebullex.models: Pydantic models for request validation.
  • onebullex.errors: Hierarchical exception mapping (e.g., specific InsufficientBalanceError vs generic ClientError).

Development

Run tests:

python -m unittest discover tests

Run verification script (Public API):

python examples/verify_rest_v2.py

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onebullex-0.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onebullex-0.0.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file onebullex-0.0.0.tar.gz.

File metadata

  • Download URL: onebullex-0.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for onebullex-0.0.0.tar.gz
Algorithm Hash digest
SHA256 8e2a6c52a670eaa35a3573d028e6fdf03f9899bfd84b826dfc018453b89b05ad
MD5 9eb88f11e05961d01610b688d66c2de7
BLAKE2b-256 f31a1b4a2ef9751b1918baacc59bbd1cfd3bc7399eb5d30fade4fcbc1cd63796

See more details on using hashes here.

File details

Details for the file onebullex-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: onebullex-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for onebullex-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc7e388adcbfd2b15b4caa5cb5a0fa8f56892fb0b178062912b7b94169b685b
MD5 ac534d22074be3acdbc97a68233d0096
BLAKE2b-256 2013d126b12adb4c2d46d439f130bfaa4df151bfc8217cb5d82317094e7e128e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page