Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

marginpy

Python 3.9+ PyPI version Codecov License Code style: black

◼️ 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:

  1. Install brew into /usr/local/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Open a terminal instance with Rosetta enabled

  2. Install a supported version of python with brew from /usr/local/:

$ /usr/local/bin/brew install python@[PYTHON_VERSION]
  1. Create a new virtualenv using newly installed python:
/usr/local/opt/python@[PYTHON_VERSION]/bin/python3 -m venv .env
  1. Activate new env
source .env/bin/activate
  1. 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

  1. Ensure you have python installed.
  2. Install poetry: $ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
  3. Install nox-poetry: $ pip install nox-poetry
  4. Initialize Python virtual environment: $ poetry env use [PYTHON_VERSION]
  5. Install project dependencies: $ poetry install
  6. Activate virtual environment: $ poetry shell
  7. 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:

  1. Activate virtual environment:
$ poetry shell
  1. Run desired task:
    • unit tests only: $ make test-unit
    • type check + lint: $ make lint

Feel free to check the Makefile for other available actions.

Metadata

Release files for marginpy 0.1.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marginpy 0.1.0a2
File Size Uploaded
marginpy-0.1.0a2.tar.gz 13.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for marginpy 0.1.0a2
File Interpreter ABI Platform
marginpy-0.1.0a2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.9 abi3 Linux glibc 2.5+ x86-64 Details
marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl CPython 3.9 abi3 macOS 10.7+ x86-64 Details

Total release size: 1.8 MB

Release files / marginpy-0.1.0a2.tar.gz

Download URL marginpy-0.1.0a2.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7f12eab6ad04d126b0c6259641736800adef29139d0b51ab8d1ab26e8d88c9c6
BLAKE2b-256 checksum
How to use checksums
38623a7d47b133b3d13abae9b912d762fdd9083338de66f6485fb18d453b72d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.2

Release files / marginpy-0.1.0a2-cp39-abi3-win_amd64.whl

Download URL marginpy-0.1.0a2-cp39-abi3-win_amd64.whl
Size 271.0 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8d6cad5ccc5f609434678821a3755c89b3edd345fd5aa4a300cd719ed27bbd80
BLAKE2b-256 checksum
How to use checksums
627687a59ef3eaa1e68fefe02861109180b98092b6a37a99de186edc43203e09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.2

Release files / marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
3e2e22e20029512acec2515dadf51a8463009e03eb49e4c520d53865e61e977b
BLAKE2b-256 checksum
How to use checksums
20918ec249f0a08174da0a4ed122ca165573c0d356a7640b5f9a901610e12fba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.2

Release files / marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl

Download URL marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl
Size 384.4 kB
Tags CPython 3.9 abi3 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
0f995e6a86c8dfdbf7053a9259a84f165e03be90554913af021414d07746cb46
BLAKE2b-256 checksum
How to use checksums
67e3b92c94e8d8166505c533e523d2317b4f7dee0ef4162819de2ac3884fc786
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page