Skip to main content

Python client library for interacting with Mango Markets v4.

Project description

mango-explorer-v4

Python client library for interacting with Mango Markets v4.

📦 Installation

PyPI

mango-explorer-v4 is available as a Python package on PyPI and can be installed as:

pip install mango-explorer-v4

Example usage

This example assumes that you have a wallet already set up: visit https://v4alpha.mango.markets to create a Mango account and fund it so that you can place orders. You can find the full sources here.

import asyncio
from mango_explorer_v4 import MangoClient

async def main():
    mango_client = await MangoClient.connect(
        secret_key='YOUR_SECRET_KEY', # Output from Phantom's "Export Private Key"
        mango_account_pk='YOUR_MANGO_ACCOUNT_PK'
    )

    print(await mango_client.symbols())
    # [
    #   {
    #       'name': 'SOL/USDC',
    #       'baseCurrency': 'SOL',
    #       'quoteCurrency': 'USDC',
    #       'makerFees': -5e-05,
    #       'takerFees': 0.0001
    #   }
    #   ...
    # ]

    print(await mango_client.place_order('SOL/USDC', 'bid', 10, 0.1, 'limit'))
    # (Refresh the UI to see the newly opened order)

    print(await mango_client.orderbook_l2('SOL/USDC', 3))
    # {
    #   'symbol': 'SOL/USDC',
    #   'bids': [
    #       [11.826, 0.899],
    #       [11.824, 39.436],
    #       [11.82, 316.421],
    #    ],
    #  'asks': [
    #       [11.839, 0.78],
    #       [11.84, 44.392],
    #       [11.841, 1.1],
    #   ]}

    print(await mango_client.balances())
    # [
    #   {'symbol': 'USDC', 'balance': 2.7435726906761744},
    #   {'symbol': 'SOL', 'balance': 0.1690007074236178},
    #   ...
    # ]

asyncio.run(main())

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

mango-explorer-v4-0.1.1.tar.gz (44.9 kB view hashes)

Uploaded Source

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