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 python3.10 or greater with brew from
/usr/local/
:
$ /usr/local/bin/brew install python@3.10
- Create a new virtualenv using newly installed python:
/usr/local/opt/python@3.10/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
-
Spare yourself some pain and setup your default
python
command to point to 3.10+ -
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 3.10 virtual environment:
$ poetry env use 3.10
-
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.0a1-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d11c005fae3669fafb7519027ed6577b99729b8fb94bdd5fc65d34fa7c1e4634 |
|
MD5 | 4835b94ac8788851e9e0b3f618c9daae |
|
BLAKE2b-256 | 662a07a1915442a88523479656995c28097c61246a2d5759cfd761a379c8d8c4 |
Hashes for marginpy-0.1.0a1-cp39-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64047613ff30a440509004585dd0e7eafbb678d57bdf9fa6508184acf0352af |
|
MD5 | 7d17bc3db3435905fd7cfa0737101f94 |
|
BLAKE2b-256 | 50e7fbc01d83ac70664de0b9e06029e5e52fec2e95d1c08c9f106be585a9bf9b |