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.5.tar.gz (143.4 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.5-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ritbit_v4_client-0.0.5.tar.gz
  • Upload date:
  • Size: 143.4 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.5.tar.gz
Algorithm Hash digest
SHA256 e533f2633ac48befb644a9970688734dd91e7f45382674f1ae754bbffae21595
MD5 7823a5c2e3768e9b527fb76d72368bcb
BLAKE2b-256 5d8e1a124a5c4890f70c4be616cf245882308aca084ffd95365f88c76890b75d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ritbit_v4_client-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 df8cb7ef879fff5cb3f5e73cc519e515c65d4c403ccfc6a06c734844532c5880
MD5 53e5c5cd6fe8018a7b6bc3aeddc0f736
BLAKE2b-256 5a711aa30856e2cdbaab82e170cd6c698b99e0073d16be1827af9d1958d05c15

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