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.9 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 = "xxx"
signer_private_key = "yyy"
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 = "xxx"
signer_private_key = "yyy"
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 = "yyy"
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())
)
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.1b5.tar.gz
(12.7 kB
view hashes)
Built Distribution
Close
Hashes for bsx_sdk_py-0.0.1b5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 539ccfd6bee46c457e6457dbbd690074569e28dc5a011cc68f6f13471ede4d73 |
|
MD5 | 79e512df1f0e59f77aa498b48fe48fdd |
|
BLAKE2b-256 | c83066d8596c47e2406c13f68e76bf07564626ef23006d46b0940bf5fe735f81 |