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 details)

Uploaded Source

Built Distributions

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

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 details)

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 details)

Uploaded CPython 3.9+ macOS 10.7+ x86-64

File details

Details for the file marginpy-0.1.0a2.tar.gz.

File metadata

  • Download URL: marginpy-0.1.0a2.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.13.2

File hashes

Hashes for marginpy-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 7f12eab6ad04d126b0c6259641736800adef29139d0b51ab8d1ab26e8d88c9c6
MD5 305909757740c8b5521490e040120ed4
BLAKE2b-256 38623a7d47b133b3d13abae9b912d762fdd9083338de66f6485fb18d453b72d7

See more details on using hashes here.

File details

Details for the file marginpy-0.1.0a2-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for marginpy-0.1.0a2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8d6cad5ccc5f609434678821a3755c89b3edd345fd5aa4a300cd719ed27bbd80
MD5 149a35cc4f65dd5e19da5fea7e211f66
BLAKE2b-256 627687a59ef3eaa1e68fefe02861109180b98092b6a37a99de186edc43203e09

See more details on using hashes here.

File details

Details for the file marginpy-0.1.0a2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

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

See more details on using hashes here.

File details

Details for the file marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for marginpy-0.1.0a2-cp39-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0f995e6a86c8dfdbf7053a9259a84f165e03be90554913af021414d07746cb46
MD5 d5f19733e5289e13522546deacbc3b83
BLAKE2b-256 67e3b92c94e8d8166505c533e523d2317b4f7dee0ef4162819de2ac3884fc786

See more details on using hashes here.

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