Metadata-Version: 2.1
Name: bsx-sdk-py
Version: 0.0.1b19
Summary: 
Author: bsx-engineering
Author-email: dev@bsx.exchange
Requires-Python: >=3.9,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: aiodns (>=3.2.0,<4.0.0)
Requires-Dist: aiohttp (>=3.9.5,<4.0.0)
Requires-Dist: eip712-structs-ng (>=2.0.1,<3.0.0)
Requires-Dist: eth-account (>=0.11.0,<0.12.0)
Requires-Dist: pandas (>=2.2.2,<3.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: typing_extensions (>=4.9.0,<5.0.0)
Requires-Dist: web3 (>=6.15.1,<7.0.0)
Description-Content-Type: text/markdown

# BSX Exchange Python SDK

This is the Python SDK for the [BSX Exchange API](https://api-docs.bsx.exchange/reference/general-information).

See [SDK docs](https://bsx-engineering.github.io) to get started.

## Requirements

- Python 3.10 or above

## Installation

You can install the SDK via pip:

```bash
pip install bsx-sdk-py
```

## Basic usage

### Create a wallet and a signer from private keys

```python
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:

```python
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:

```python
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:

```python
# 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](https://bsx-engineering.github.io/getting-started.html) for more.

## Running locally

1. Clone [github repo](https://github.com/bsx-engineering/bsx-python-sdk)

2. Install poetry

```

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

```

3. Setup a virtual environment and activate it

```

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

```

4. Install dependencies via `poetry install`

