Skip to main content

Nibiru Python SDK

Project description

Nibiru Python SDK

Interact with the Nibiru protocol using Python.

PyPI Version

The nibiru-py allows you to connect and trade with the Nibiru Protocol. It provides quick access to market data for storage, analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering.

It is intended to be used by coders, developers, technically-skilled traders, data-scientists and financial analysts for building trading algorithms.

README Contents

Documentation Website

Documentation can be found here: Nibiru-py documentation

  • Learn more about opening and managing your spot and perp positions here
  • Learn about querying the chain using the Sdk here

Quick Start

Installation

pip install nibiru-py

Usage Instructions

The examples directory contains runnable examples that showcase how to use the package.

  • Requires Python 3.9+
  • Requires a running instance of the Nibiru blockchain
$ pipenv shell
$ pipenv install

# connecting to Nibiru Exchange API and create a new pool
$ python examples/chain_client/dex/create_pool.py

# sending a msg with bank transfer signs and posts a transaction to the Nibiru Chain
$ python examples/chain_client/msg_send.py

Upgrade pip to the latest version, if you see these warnings:

WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
WARNING: Additional context:   user = True   home = None   root = None   prefix = None

Development Guidelines

Python dependencies

1 (option A). Install the nibiru-py package from source

pipenv shell
pipenv install --dev

Set up a .env file to set environment variables for the tests.

# Example configuration for the Nibiry Python SDK
HOST="..."
VALIDATOR_MNEMONIC="..."
CHAIN_ID="..."

There's currently a "devnet" running in GCP that the CI workflows use. You can find these secrets at this notion page if you have access to it or contact @Unique-Divine or @matthiasmatt. This is useful so that you can run every part of the package code without needing to visit other repositories.

1 (option B). Install the nibiru-py package with pip

# from local
# build and install
pip install .

# from local build
pip uninstall nibiru-py
pip install nibiru-py --no-index --find-links /path/to/nibiru/nibiru-py/dist

# from pypi
pip uninstall nibiru-py
pip install nibiru-py

Running the tests

Package tests are written pytest. To run and edit them, follow the instructions for installation from source and use pipenv run pytest.

Other dependencies

To run shell scripts and commands in the Makefile, you'll need to install the following tools depending on your operating system.

  • Ubuntu
    sudo apt install python3.X-dev autoconf automake build-essential libffi-dev libtool pkg-config
    
  • macOS
    brew install autoconf automake libtool
    
  • Fedora
    sudo dnf install python3-devel autoconf automake gcc gcc-c++ libffi-devel libtool make pkgconfig
    

Generate proto binding & build

make proto-gen
python -m build     # Run `pip install build` in case this fails

Linting

Enable git hook which will perform linting before each commit:

pre-commit install

This will keep your code clean.

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

nibiru-py-0.0.12.tar.gz (179.3 kB view hashes)

Uploaded Source

Built Distribution

nibiru_py-0.0.12-py3-none-any.whl (309.5 kB view hashes)

Uploaded Python 3

Supported by

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