Skip to main content

marginfi Python SDK

Project description

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.

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

marginpy-0.1.0a2.tar.gz (13.4 kB view hashes)

Uploaded Source

Built Distributions

marginpy-0.1.0a2-cp39-abi3-win_amd64.whl (271.0 kB view hashes)

Uploaded CPython 3.9+ Windows x86-64

marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9+ manylinux: glibc 2.5+ x86-64

marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl (384.4 kB view hashes)

Uploaded CPython 3.9+ macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page