Skip to main content

No project description provided

Project description

BSX Exchange Python SDK

This is the Python SDK for the BSX Exchange API.

See SDK docs to get started.

Requirements

  • Python 3.10 or above

Installation

You can install the SDK via pip:

pip install bsx-sdk-py

Basic usage

Create a wallet and a signer from private keys

from eth_account import Account

wallet_private_key = "0x0000000000000000000000000000000000000000000000000000000000000000"
signer_private_key = "0x1111111111111111111111111111111111111111111111111111111111111111"
wallet = Account.from_key(wallet_private_key)
signer = Account.from_key(signer_private_key)

Create the BSXInstance using the main wallet's private key:

from eth_account import Account
from bsx_py import BSXInstance, Environment

wallet_private_key = "0x0000000000000000000000000000000000000000000000000000000000000000"
signer_private_key = "0x1111111111111111111111111111111111111111111111111111111111111111"
wallet = Account.from_key(wallet_private_key)
signer = Account.from_key(signer_private_key)
bsx_instance = BSXInstance(env=Environment.TESTNET, wallet=wallet, signer=signer)

Create the BSXInstance using an active API key:

from eth_account import Account
from bsx_py import BSXInstance, Environment

signer_private_key = "0x1111111111111111111111111111111111111111111111111111111111111111"
signer = Account.from_key(signer_private_key)
bsx_instance = BSXInstance.from_api_key(api_key="xxx", api_secret="zzz", signer=signer, env=Environment.TESTNET)

Perform basic operations:

# Placing orders
import time
from decimal import Decimal
from bsx_py.common.types.market import CreateOrderParams, Side, OrderType

params = CreateOrderParams(
    type=OrderType.LIMIT,
    side=Side.BUY,
    product_index=3,
    price=Decimal("100"),
    size=Decimal("1"),
    time_in_force="GTC",
    nonce=int(time.time_ns()),
)
order = bsx_instance.create_order(params)
print(order)

See Getting Started for more.

Running locally

  1. Clone github repo

  2. Install poetry


$ curl -sSL https://install.python-poetry.org | python3 -

  1. Setup a virtual environment and activate it

$ python3 -m venv venv
$ source ./venv/bin/activate

  1. Install dependencies via poetry install

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

bsx_sdk_py-0.0.1b18.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

bsx_sdk_py-0.0.1b18-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file bsx_sdk_py-0.0.1b18.tar.gz.

File metadata

  • Download URL: bsx_sdk_py-0.0.1b18.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for bsx_sdk_py-0.0.1b18.tar.gz
Algorithm Hash digest
SHA256 f16ca0fd493e01b0d1b3822042efbc45e189b78037a52bdbd4dc0e87e00f364f
MD5 58c6bb48f1c66f8a04e5f85ada631546
BLAKE2b-256 2c3b357d34008460b04b144b3c14a80105cd3e9b332b96928bcac9b81ee4ee0d

See more details on using hashes here.

File details

Details for the file bsx_sdk_py-0.0.1b18-py3-none-any.whl.

File metadata

  • Download URL: bsx_sdk_py-0.0.1b18-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for bsx_sdk_py-0.0.1b18-py3-none-any.whl
Algorithm Hash digest
SHA256 49d973113f4a435e0980bc92ac63e81f6d586d62284b7e1521778bcd7c3e24be
MD5 b0b1bb330988323f3b5e92c10640433c
BLAKE2b-256 d84ba0cc228db03fd235475ff5869797c0fb68a6c9ba848106cb0e06d98e3dcd

See more details on using hashes here.

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