Skip to main content

No project description provided

Project description

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.

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

ritbit_v4_client-0.0.4.tar.gz (143.3 kB view details)

Uploaded Source

Built Distribution

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

ritbit_v4_client-0.0.4-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file ritbit_v4_client-0.0.4.tar.gz.

File metadata

  • Download URL: ritbit_v4_client-0.0.4.tar.gz
  • Upload date:
  • Size: 143.3 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for ritbit_v4_client-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fbf24b7cd75eeee7c2459c9cef96acd51969d7b27b263af3dc82d02d6a342e85
MD5 ec8acb1580535e42ca7f15839ef059b2
BLAKE2b-256 3fc52f15bfe98456b73cab9313e18735ba5637ca589afbfc068ae02dc810e037

See more details on using hashes here.

File details

Details for the file ritbit_v4_client-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ritbit_v4_client-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for ritbit_v4_client-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 71f0cc6a94b571b9540aae9e968972533640cd4c1c35615dbf2750c1557ca25d
MD5 5fa6ec00847b38692fc6178a481e1612
BLAKE2b-256 0087180a1982623bf71d64fc8543feac3e5662c4de9541fef615e717eb4b1707

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