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
-
Clone github repo
-
Install poetry
$ curl -sSL https://install.python-poetry.org | python3 -
- Setup a virtual environment and activate it
$ python3 -m venv venv
$ source ./venv/bin/activate
- Install dependencies via
poetry install
Project details
Release history Release notifications | RSS feed
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.1b19.tar.gz
(19.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bsx_sdk_py-0.0.1b19.tar.gz.
File metadata
- Download URL: bsx_sdk_py-0.0.1b19.tar.gz
- Upload date:
- Size: 19.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c60dccd56cedafeceb1a51426f85b3ffac86ba8585c7bb0483bc7138d16f01c1
|
|
| MD5 |
484177bfb00f6b6f4f8b1f8e8f03d978
|
|
| BLAKE2b-256 |
594dd85e9e3c75b4c8e52001cc3a4dd7a14725b5f4faa4ee0091aee5681a7ea6
|
File details
Details for the file bsx_sdk_py-0.0.1b19-py3-none-any.whl.
File metadata
- Download URL: bsx_sdk_py-0.0.1b19-py3-none-any.whl
- Upload date:
- Size: 27.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a6fa1d11be72d5360352343f8ec15c767e9192a33c975843f0b6fe40b5776da
|
|
| MD5 |
b69ab1c169bcd4fb02db6b8437aecb76
|
|
| BLAKE2b-256 |
65387ff4db6c8241ab49406d4e404f68519c07502ff4cf1cd7ef9b81cabdb889
|