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 = "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_beta 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_beta 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_beta.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_beta-0.0.1b11.tar.gz
(13.6 kB
view details)
Built Distribution
File details
Details for the file bsx_sdk_beta-0.0.1b11.tar.gz
.
File metadata
- Download URL: bsx_sdk_beta-0.0.1b11.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b9f54d8d753c9fbebb3b624d534e03b57a92fc928eb8891b4d676ccd7c10589 |
|
MD5 | 7bc268f98db19450414c72bc10e512c0 |
|
BLAKE2b-256 | 2ecc487a7582fdad4d78cde770ee02faec60dc15344d4a0d0ea1286b06507f8a |
File details
Details for the file bsx_sdk_beta-0.0.1b11-py3-none-any.whl
.
File metadata
- Download URL: bsx_sdk_beta-0.0.1b11-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d725585b216a67e548b7c9913f03c788d8b6ea55bec3b38c5a7638a8ce5430ef |
|
MD5 | 8e8c49583a3febb12b2cca47bce0e6d5 |
|
BLAKE2b-256 | dd9ab68839dfde5250dc568a512dce5aa7605acdf57c992b0036c6bef4b1776d |