An SDK to interact with the Perennial derivatives protocol.
Project description
Perennial Python SDK
Overview
This tool is designed to communicate with the Perennial exchange from Python and read/write the following data:
Read account and market information:
- Open positions (Iterates through available markets -> checks for open positions -> prints them in the end)
- Open orders (Prints a list of open orders and their details, incl. nonces)
- Collaterals
- Maintenance margin requirements
- Pair prices
- Funding rate
Execute market orders:
- Closing positions
- Placing market orders
- Placing limit orders
- Placing trigger orders
- Canceling orders
- When closing positions - Doesnt automatically withdraw the collateral, you should use the last step in the example to do so.
- When placing market/limit order - Approves collateral (62.5$ min), commits price to MultiInvoker, places order.
- When placing trigger orders -
- Placing collateral is optional,
- Commits price and places order.
- If you are holding a Long position you should choose side 1 - Buy; Even though you need it to short. Same for short position.
- The delta is with how much you want to reduce the position size , so it should be negative.
- For full close delta = 0.
- To cancel orders, you will need the nonce fo the order (from MultiInvoker side). You can get this by using fetch_open_orders.py.
Features
- Connects to an Arbitrum node using a provided RPC URL
- Retrieves oracle information for specified markets
- Fetches VAAs from the Pyth Network
- Creates market snapshots using a Lens contract
- Supports multiple markets and optional account specification
- Reads all needed information from the snapshot
Prerequisites
- RPC URL (in .env)
- Wallet private key (in .env)
- Python 3.7+
- Required Libraries:
web3librarypython-dotenvlibraryrequestslibraryeth-accountlibraryeht_abilibrary
Installation
Using pip
You can install the SDK using pip:
pip install perennial_sdk==0.1.0
Using Poetry
If you prefer using Poetry for dependency management, you can add the SDK to your project with:
poetry add perennial_sdk@0.1.0
Development
If you are using Poetry, you can set up your environment with:
-
Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
-
Install dependencies:
poetry install -
Activate the virtual environment:
poetry run python <command here>
Example usage can be found in the examples directory:
Private key and RPC url will need to be added first to .env.
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
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 perennial_sdk-0.1.3.tar.gz.
File metadata
- Download URL: perennial_sdk-0.1.3.tar.gz
- Upload date:
- Size: 51.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b7cc52c3e7641a343c0402471b29d95d238d2dd4aa0da8096d6d432e8a83956
|
|
| MD5 |
9b280ab9535931c36fb4a22449b6faff
|
|
| BLAKE2b-256 |
908af883117ac6e790ea1da7713653388c34a54faa43d68d6a9efc0e251f50fd
|
File details
Details for the file perennial_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: perennial_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 63.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
328e2cf92c85ea50a46b14fc90be19a4de7df09456c6aac908f05ac4d1126861
|
|
| MD5 |
0b15e4ea4533b9e8afac04d4cb07041f
|
|
| BLAKE2b-256 |
a7e4573251b29d3fcc353a63fca6f9887f88555ccbf75a689a932318af9cc25a
|