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-1.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-1.0.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: onebullex-1.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7c58560fb223e494ff0d74c04c1a21b45c1eb9640a08275e65578bba740a763c
MD5 1a0e77fc70052a923bbb2a71f8a17601
BLAKE2b-256 98c570ab8c58d3d6f601218d23dd3e04e407a851620ac2c4e3318388d4ed5f4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: onebullex-1.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 417af5d1e3053c3bc2e1cba91a8c9ca109678e5ea539ec1d97283500f3af7861
MD5 b7dd75a1dac81ae8571690261588f07a
BLAKE2b-256 a418b576a6aea735001b1228187cbdaa9841e8d72f326173723efd13538a4411

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