nibiru


Namenibiru JSON
Version 0.21.12 PyPI version JSON
download
home_pagehttps://github.com/NibiruChain/py-sdk
SummaryPython SDK for interacting with Nibiru.
upload_time2023-09-27 17:11:22
maintainerNibiruHeisenberg
docs_urlNone
authorNibiru Chain
requires_python>=3.8.16,<4.0.0
licenseMIT
keywords nibiru blockchain sdk python cosmos
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python SDK - Nibiru Chain    <!-- omit in toc -->

> Python-based client for interacting with the Nibiru blockchain.

<!-- Badges -->

[![Nibiru Test workflow][tests-badge]][tests-workflow]
[![Examples tests][examples-badge]][tests-example]
[![PyPI Version][pypi-image]][pypi-url]
[![][documentation-image]][documentation-url]
[![][discord-badge]][discord-url]
[![][stars-image]][stars-url]
[![MIT license][license-badge]][license-link]

<!-- Badges links -->

<!-- pypi -->
[pypi-image]: https://img.shields.io/pypi/v/nibiru
[pypi-url]: https://pypi.org/project/nibiru/
[stars-image]: https://img.shields.io/github/stars/NibiruChain?style=social
[stars-url]: https://github.com/NibiruChain
[documentation-image]: https://readthedocs.org/projects/nibiru-py/badge/?version=latest
[documentation-url]: https://nibiru-py.readthedocs.io/en/latest/?badge=latest
[discord-badge]: https://dcbadge.vercel.app/api/server/nibirufi?style=flat
[discord-url]: https://discord.gg/nibirufi
[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg
[license-link]: https://github.com/NibiruChain/py-sdk/blob/master/LICENSE
[tests-badge]: https://github.com/NibiruChain/py-sdk/actions/workflows/pytests.yml/badge.svg
[examples-badge]: https://github.com/NibiruChain/py-sdk/actions/workflows/notebooks.yml/badge.svg
[tests-workflow]: https://github.com/NibiruChain/py-sdk/actions/workflows/pytests.yml
[tests-example]: https://github.com/NibiruChain/py-sdk/actions/workflows/notebooks.yml

The `nibiru` package allows you to index, query, and send transactions on Nibiru Chain using Python. It provides access to market data for analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering.

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

## Try running nibiru sdk online

Open the google collab link below to try running Niburu code online: 

<a href="https://colab.research.google.com/github/NibiruChain/py-sdk/blob/main/examples/colab_notebook.ipynb" target="_blank">
<p align="center">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" style="width: 300px;">
</p>
</a>

Or go to the [examples folder](examples) to see the codes and run Jupyter notebooks locally.

## Installation
```bash
pip install nibiru  # requires Python 3.8+
```

## Usage

### Querying the chain

```python
import json
from nibiru import Network, ChainClient

client = ChainClient(Network.testnet(2))

# Query perp markets
print(json.dumps(client.query.perp.markets(), indent=4))

# Query trader's positions
print(
  json.dumps(
    client.query.perp.all_positions(
      trader="nibi1jle8khj3aennq24zx6g93aam9rt0fqhgyp4h52"
    ),
    indent=4)
)
```

### Submitting transactions to the chain

To send a tx you need to authenticate using your wallet mnemonic or private key.

To create a new wallet, generate a mnemonic key using any service or using SDK call.

```python
import json
import nibiru
from nibiru import Network, ChainClient, Msg, PrivateKey

mnemonic, private_key = PrivateKey.generate()
print(mnemonic)
# Example OUTPUT:
# enlist satisfy inspire hobby romance caught great neither kitchen unfair cage awesome update fade object eagle sun ordinary again journey spell gown tiger spin

# Your wallet address
print(private_key.to_public_key().to_address().to_acc_bech32())
# Example OUTPUT:
# nibi1efsh4dq3ve58dgu68rxp8cfe4mgf89el0qfucm
```

Store your mnemonic key in a safe place and use it going forward. 

Use faucet to get some test tokens into your wallet: https://app.nibiru.fi/faucet

Сreate your chain client and authenticate with the mnemoniс generated

```python
mnemonic = "put your mnemonic here..."
client = ChainClient(network=Network.testnet(2))
client.authenticate(mnemonic=mnemonic)
print(client.address)
```

Check your bank balances. If the faucet succeded - your wallet should not be empty.

```python
print(client.query.get_bank_balances(client.address))
```

### Send tx

```python
output = client.tx.execute_msgs(
  Msg.perp.open_position(
    pair=pair,
    is_long=True,
    margin=10,
    leverage=2,
  )
)
print(output)
```

You can broadcast any available transaction by passing its corresponding `Msg` to the `client.tx.execute_msgs` function.

## Documentation Website

Documentation can be found here: [Nibiru-py documentation](https://nibiru-py.readthedocs.io/en/latest/index.html)

- Learn more about opening and managing your spot and perp positions [here](https://nibiru-py.readthedocs.io/en/latest/nibiru.sdks.tx.html#nibiru-sdks-tx-package)
- Learn about querying the chain using the Sdk [here](https://nibiru-py.readthedocs.io/en/latest/nibiru.clients.html#nibiru-clients-package)

## Contributing

Please read [HACKING.MD](HACKING.md) for developer environment setup.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NibiruChain/py-sdk",
    "name": "nibiru",
    "maintainer": "NibiruHeisenberg",
    "docs_url": null,
    "requires_python": ">=3.8.16,<4.0.0",
    "maintainer_email": "dev@nibiru.fi",
    "keywords": "nibiru,blockchain,sdk,python,cosmos",
    "author": "Nibiru Chain",
    "author_email": "dev@nibiru.fi",
    "download_url": "https://files.pythonhosted.org/packages/76/c5/d9cc38986965fecd142a815d200ee86e72ebaa83e8a42d1dba7beda977f8/nibiru-0.21.12.tar.gz",
    "platform": null,
    "description": "# Python SDK - Nibiru Chain    <!-- omit in toc -->\n\n> Python-based client for interacting with the Nibiru blockchain.\n\n<!-- Badges -->\n\n[![Nibiru Test workflow][tests-badge]][tests-workflow]\n[![Examples tests][examples-badge]][tests-example]\n[![PyPI Version][pypi-image]][pypi-url]\n[![][documentation-image]][documentation-url]\n[![][discord-badge]][discord-url]\n[![][stars-image]][stars-url]\n[![MIT license][license-badge]][license-link]\n\n<!-- Badges links -->\n\n<!-- pypi -->\n[pypi-image]: https://img.shields.io/pypi/v/nibiru\n[pypi-url]: https://pypi.org/project/nibiru/\n[stars-image]: https://img.shields.io/github/stars/NibiruChain?style=social\n[stars-url]: https://github.com/NibiruChain\n[documentation-image]: https://readthedocs.org/projects/nibiru-py/badge/?version=latest\n[documentation-url]: https://nibiru-py.readthedocs.io/en/latest/?badge=latest\n[discord-badge]: https://dcbadge.vercel.app/api/server/nibirufi?style=flat\n[discord-url]: https://discord.gg/nibirufi\n[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg\n[license-link]: https://github.com/NibiruChain/py-sdk/blob/master/LICENSE\n[tests-badge]: https://github.com/NibiruChain/py-sdk/actions/workflows/pytests.yml/badge.svg\n[examples-badge]: https://github.com/NibiruChain/py-sdk/actions/workflows/notebooks.yml/badge.svg\n[tests-workflow]: https://github.com/NibiruChain/py-sdk/actions/workflows/pytests.yml\n[tests-example]: https://github.com/NibiruChain/py-sdk/actions/workflows/notebooks.yml\n\nThe `nibiru` package allows you to index, query, and send transactions on Nibiru Chain using Python. It provides access to market data for analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, and related software engineering.\n\nThe package is intended to be used by coders, developers, technically-skilled traders and  data-scientists for building trading algorithms.\n\n## Try running nibiru sdk online\n\nOpen the google collab link below to try running Niburu code online: \n\n<a href=\"https://colab.research.google.com/github/NibiruChain/py-sdk/blob/main/examples/colab_notebook.ipynb\" target=\"_blank\">\n<p align=\"center\">\n  <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" style=\"width: 300px;\">\n</p>\n</a>\n\nOr go to the [examples folder](examples) to see the codes and run Jupyter notebooks locally.\n\n## Installation\n```bash\npip install nibiru  # requires Python 3.8+\n```\n\n## Usage\n\n### Querying the chain\n\n```python\nimport json\nfrom nibiru import Network, ChainClient\n\nclient = ChainClient(Network.testnet(2))\n\n# Query perp markets\nprint(json.dumps(client.query.perp.markets(), indent=4))\n\n# Query trader's positions\nprint(\n  json.dumps(\n    client.query.perp.all_positions(\n      trader=\"nibi1jle8khj3aennq24zx6g93aam9rt0fqhgyp4h52\"\n    ),\n    indent=4)\n)\n```\n\n### Submitting transactions to the chain\n\nTo send a tx you need to authenticate using your wallet mnemonic or private key.\n\nTo create a new wallet, generate a mnemonic key using any service or using SDK call.\n\n```python\nimport json\nimport nibiru\nfrom nibiru import Network, ChainClient, Msg, PrivateKey\n\nmnemonic, private_key = PrivateKey.generate()\nprint(mnemonic)\n# Example OUTPUT:\n# enlist satisfy inspire hobby romance caught great neither kitchen unfair cage awesome update fade object eagle sun ordinary again journey spell gown tiger spin\n\n# Your wallet address\nprint(private_key.to_public_key().to_address().to_acc_bech32())\n# Example OUTPUT:\n# nibi1efsh4dq3ve58dgu68rxp8cfe4mgf89el0qfucm\n```\n\nStore your mnemonic key in a safe place and use it going forward. \n\nUse faucet to get some test tokens into your wallet: https://app.nibiru.fi/faucet\n\n\u0421reate your chain client and authenticate with the mnemoni\u0441 generated\n\n```python\nmnemonic = \"put your mnemonic here...\"\nclient = ChainClient(network=Network.testnet(2))\nclient.authenticate(mnemonic=mnemonic)\nprint(client.address)\n```\n\nCheck your bank balances. If the faucet succeded - your wallet should not be empty.\n\n```python\nprint(client.query.get_bank_balances(client.address))\n```\n\n### Send tx\n\n```python\noutput = client.tx.execute_msgs(\n  Msg.perp.open_position(\n    pair=pair,\n    is_long=True,\n    margin=10,\n    leverage=2,\n  )\n)\nprint(output)\n```\n\nYou can broadcast any available transaction by passing its corresponding `Msg` to the `client.tx.execute_msgs` function.\n\n## Documentation Website\n\nDocumentation can be found here: [Nibiru-py documentation](https://nibiru-py.readthedocs.io/en/latest/index.html)\n\n- Learn more about opening and managing your spot and perp positions [here](https://nibiru-py.readthedocs.io/en/latest/nibiru.sdks.tx.html#nibiru-sdks-tx-package)\n- Learn about querying the chain using the Sdk [here](https://nibiru-py.readthedocs.io/en/latest/nibiru.clients.html#nibiru-clients-package)\n\n## Contributing\n\nPlease read [HACKING.MD](HACKING.md) for developer environment setup.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python SDK for interacting with Nibiru.",
    "version": "0.21.12",
    "project_urls": {
        "Homepage": "https://github.com/NibiruChain/py-sdk",
        "Repository": "https://github.com/NibiruChain/py-sdk"
    },
    "split_keywords": [
        "nibiru",
        "blockchain",
        "sdk",
        "python",
        "cosmos"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f99e32757cb6d9e3d120c28ee5b4f5b25aa9d01eda4e2944c4b80c11ae836cf",
                "md5": "f450fb489286cd2dbc41bd1f9bfd111c",
                "sha256": "23876691b80bdd6463a0abd709dc1a7eb054b7028cbc1ba12a657194ab630ef6"
            },
            "downloads": -1,
            "filename": "nibiru-0.21.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f450fb489286cd2dbc41bd1f9bfd111c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.16,<4.0.0",
            "size": 683752,
            "upload_time": "2023-09-27T17:11:20",
            "upload_time_iso_8601": "2023-09-27T17:11:20.033998Z",
            "url": "https://files.pythonhosted.org/packages/2f/99/e32757cb6d9e3d120c28ee5b4f5b25aa9d01eda4e2944c4b80c11ae836cf/nibiru-0.21.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76c5d9cc38986965fecd142a815d200ee86e72ebaa83e8a42d1dba7beda977f8",
                "md5": "3e0e0040e271a4d6f9efccf6007ef236",
                "sha256": "6e221e1c2f4e793f8c80320a8817e44519855a5f26e2efe13f19ea667ee45fa2"
            },
            "downloads": -1,
            "filename": "nibiru-0.21.12.tar.gz",
            "has_sig": false,
            "md5_digest": "3e0e0040e271a4d6f9efccf6007ef236",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.16,<4.0.0",
            "size": 394653,
            "upload_time": "2023-09-27T17:11:22",
            "upload_time_iso_8601": "2023-09-27T17:11:22.290799Z",
            "url": "https://files.pythonhosted.org/packages/76/c5/d9cc38986965fecd142a815d200ee86e72ebaa83e8a42d1dba7beda977f8/nibiru-0.21.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-27 17:11:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NibiruChain",
    "github_project": "py-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "nibiru"
}
        
Elapsed time: 0.12624s