Skip to main content

Python Client (async) for Ritbit (v4 API)

Quick links

Install

Using uv (recommended)

uv init my-trading-bot
cd my-trading-bot
uv add ritbit-v4-client

Using pip

pip install ritbit-v4-client

Install from GitHub

uv add git+https://github.com/ritbit/v4-clients#subdirectory=v4-client-py-v2

or with pip:

pip install "ritbit-v4-client @ git+https://github.com/ritbit/v4-clients#subdirectory=v4-client-py-v2"

Common Installation Issue on Ubuntu

If you encounter the following error:

Failed building wheel for ed25519-blake2b

Install the required build tools and Rust toolchain:

sudo apt-get update
sudo apt-get install build-essential python3-dev libssl-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

Then retry the installation.

Getting Started Guide

Ritbit Python SDK Trading Documentation: go-to resource for starting trades on Ritbit using the Python SDK. Follow this guide to learn the basics and begin trading.

Table of Contents

  1. Introduction
  2. Network Setup
  3. Using the Testnet Faucet
  4. Account Details
  5. Getting Price Quotes
  6. Placing Orders
  7. Placing Native Orders
  8. Using WebSockets

Quick Start

  1. Set up your network connection (see Network Setup)
  2. If using testnet, obtain funds from the faucet (see Using the Testnet Faucet)
  3. Check your account details (see Account Details)
  4. Get current market prices (see Getting Price Quotes)
  5. Build and place your order (see Placing Orders or Placing Native Orders)
  6. Optionally, set up WebSocket connections for real-time updates (see Using WebSockets)

For more detailed examples, see the examples directory. Note that some examples may require installation of additional packages to work.

Changes

Migration

If you are transitioning from a previous version of the Python client, please note the following differences:

NodeClient

ValidatorClient is renamed to NodeClient.

All provided methods are asynchronous.

Methods are available directly, no methods get or post needed, since the client uses inheritance, and consists of three layers:

  • QueryNodeClient, the basic layer that send queries to a node
  • MutatingNodeClient - the extension on top of the query client, that support transation simulation and sending
  • NodeClient the toppest layer that provides methods to control orders

For parameters raw types used.

For construcint order the Market builder is provided, that helps to calculate quantums and subticks values.

IndexerClient

The IndexerClient has the similar structure, but provides asynchronous methods as well.

IndexerSocket

The SocketClient is replaced with the IndexerSocket that provides separate channels concept and allow to add per-channel processing.

Key Improvements

The latest version of the Python async client for Ritbit offers notable enhancements over previous iterations. These improvements make it a more efficient tool for trading and integration.

Asynchronous Execution

The methods leverage Python's async features, allowing you to fully harness concurrency benefits. This approach optimizes resource usage, minimizes unnecessary threads, and reduces latency.

Enhanced Type Hints

Expanded type hint coverage enhances code readability and provides better tooling support. Additionally, it helps detect errors early during development.

API Reflection

The client closely mirrors the Ritbit API, enabling seamless access to the exchange's features and parameters. This makes integrating the client with your applications intuitive and straightforward.

Lightweight Implementation

The client is built using pure Python libraries and maintains a thin, transparent layer that follows the Principle of Least Astonishment (POLA). This ensures explicit behavior and gives you greater control.

MIT License

Licensed under the permissive MIT license, the client can be easily integrated into your software projects without restrictive legal hurdles.

Development

The project is divided into three main parts:

  • node - contains the NodeClient, transaction builder and other utilities
  • indexer - contains rest api indexer client and websocket indexer client
  • faucet - contains faucet client

Installing from source

The project uses uv. To install dependencies, run:

uv sync

To include dev and example dependencies:

uv sync --group dev --group examples

Preparing development environment

Install git hooks:

uv run pre-commit install

Testing

To run tests use:

uv run pytest

Linting

uv run black --check ./ritbit_v4_client ./tests ./examples

For more details about the grant see link.

Metadata

Release files for ritbit-v4-client 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ritbit-v4-client 0.0.6
File Size Uploaded
ritbit_v4_client-0.0.6.tar.gz 146.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ritbit-v4-client 0.0.6
File Interpreter ABI Platform
ritbit_v4_client-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 192.5 kB

Release files / ritbit_v4_client-0.0.6.tar.gz

Download URL ritbit_v4_client-0.0.6.tar.gz
Size 146.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f4886b11f0565f922d1a5be91a4c6cb65092c088f31b5d080e73ff67d077b79d
BLAKE2b-256 checksum
How to use checksums
a5d56bf6c5a627b98a6890abd487bf60841d59f361511cb657b2dc959232bfe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ritbit_v4_client-0.0.6-py3-none-any.whl

Download URL ritbit_v4_client-0.0.6-py3-none-any.whl
Size 45.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2395c2c4c06b58d244a0b87cff6d52186638a3fab7a41f8a33ea53be2eeed197
BLAKE2b-256 checksum
How to use checksums
5a508f15f9098dccab467f0e9201f0bb504c9abc1c275d2b5c27e86fa10088ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page