marginfi Python SDK
Project description
◼️ The marginfi Python SDK ◼️
marginpy is the python library for interacting with marginfi, the decentralized portfolio margin protocol on Solana.
🏎 Quickstart
Installation
pip install marginpy
Running marginpy
in a Github Codespace
marginpy
is installed out-of-the-box in the [.devcontainer/Dockerfile](Python SDK Codespace).
Enable Github Codespaces for your Github user or organization account and spin up a machine for a no-hassle way to get started!
Installing on an M1
If you are using an M1, you need to install marginpy
through a Rosetta-enabled x86_64 version of python. If starting from scratch:
- Install brew into
/usr/local/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Open a terminal instance with Rosetta enabled
-
Install a supported version of python with brew from
/usr/local/
:
$ /usr/local/bin/brew install python@[PYTHON_VERSION]
- Create a new virtualenv using newly installed python:
/usr/local/opt/python@[PYTHON_VERSION]/bin/python3 -m venv .env
- Activate new env
source .env/bin/activate
- Install
marginpy
with pip from env:
pip install marginpy
General Usage
import marginpy
Check out the examples for more details.
👷♀️ Development
Setup local development environment
- Ensure you have python installed.
- Install poetry:
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
- Install nox-poetry:
$ pip install nox-poetry
- Initialize Python virtual environment:
$ poetry env use [PYTHON_VERSION]
- Install project dependencies:
$ poetry install
- Activate virtual environment:
$ poetry shell
- Build the rust crate and install it locally:
$ maturin develop
Running tests
As of writing, only a small subset of tests can be run by the user, due to initially private dependencies. They can be run like so:
- Activate virtual environment:
$ poetry shell
- Run desired task:
- unit tests only:
$ make test-unit
- type check + lint:
$ make lint
- unit tests only:
Feel free to check the Makefile for other available actions.
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
Built Distributions
Hashes for marginpy-0.1.0a2-cp39-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d6cad5ccc5f609434678821a3755c89b3edd345fd5aa4a300cd719ed27bbd80 |
|
MD5 | 149a35cc4f65dd5e19da5fea7e211f66 |
|
BLAKE2b-256 | 627687a59ef3eaa1e68fefe02861109180b98092b6a37a99de186edc43203e09 |
Hashes for marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e2e22e20029512acec2515dadf51a8463009e03eb49e4c520d53865e61e977b |
|
MD5 | 3f5ebf1d2069cd2b224957fce3ed0bb3 |
|
BLAKE2b-256 | 20918ec249f0a08174da0a4ed122ca165573c0d356a7640b5f9a901610e12fba |
Hashes for marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f995e6a86c8dfdbf7053a9259a84f165e03be90554913af021414d07746cb46 |
|
MD5 | d5f19733e5289e13522546deacbc3b83 |
|
BLAKE2b-256 | 67e3b92c94e8d8166505c533e523d2317b4f7dee0ef4162819de2ac3884fc786 |