LogoLogo
  • HXRO NETWORK
    • Welcome to Hxro Network
    • Market Protocols
      • Derivatives Trading
      • Betting
        • SAMM Protocol Litepaper - v1.1
    • Network Fees
  • TOKENOMICS AND STAKING
    • HXRO Token
    • Network Staking
    • Liquidity Pools
    • How-To
      • Transfer HXRO from ERC20 to SPL via Wormhole
      • Claim an esHXRO Airdrop
      • How to Stake HXRO
      • How to Vest esHXRO
      • How to Initialize and Claim Rewards
  • NETWORK REWARDS AND INCENTIVES
    • Rewards
    • Volume Incentives
    • Staking Incentives
      • Stake Delegation
  • DEVELOPERS
    • Derivatives Tooling
      • Python & Typescript SDKs
      • Dexterity Typescript SDK QuickStart
      • Dexterity Typscript Scripts
      • DEX Reference Implementations
    • Parimutuel Tooling
      • Typescript SDK
      • Python SDK
      • Parimutuel Typescript SDK QuickStart
      • Parimutuel Typescript + React Project
        • Config.tsx
        • PariBox.tsx
        • PlacePositionBox.tsx
        • PlacePosition.tsx
    • Developer Grants
      • Developer Grant FAQs
    • Oracles
  • Traders
    • FAQs
  • MARKET MAKERS
    • Market Maker Reference Implementation
  • Security
    • Staking Contract Audit
  • External Links
    • Website
    • Governance, Staking, and Rewards Portal
    • Github
    • Forum
    • Twitter
    • Discord
    • Brand Kit
      • Brand and Press
Powered by GitBook
On this page
  • Introduction
  • How to get it
  • How to instantiate it
  • Example usage
  • Comments, Feedback, Suggestions
  1. DEVELOPERS
  2. Parimutuel Tooling

Python SDK

Last updated 1 year ago

Introduction

Hxro provides a Python SDK that closely resembles the REST API for traders & developers who wish to write trading bots or build on top of the protocol directly from their Python applications.

How to get it

The SDK is currently available on Pypi for Linux only at . A MacOS version will follow soon, if you have an immediate use for it please reach us on Discord.

How to instantiate it

Start by creating a virtualenv and installing the SDK

pip install partimutuelsdk

Then instantiate the SDK, passing in a validator URL (public or private), the parimutuel program id (the program id on devnet is 3kjK4HA6A4K86NgNB93gGhSt257wtN4QAqXMNPQ4fVTm and on mainnet is GUhB2ohrfqWspztgCrQpAmeVFBWmnWYhPcZuwY52WWRe) and the private key for the owner of the system account that will be used to pay for transactions and which owns the ATAs holding the settlement token (USDC) and any HXRO tokens. Note you can get an airdrop for both using our devnet UI, see for more information.

Optionally, pass in a network key to filter to a particular market denomination. Currently there are only USDC denominated markets (the network key on devnet is 2xJcpMZvegKZ6GCYzUp74DfEFtPss66XNzV932xgSgNW and mainnet is FoCmS48FRyJrx6bozDijaARYAThdUeUGu4rbGKqBegcH).

import parimutuelsdk as psdk

url = "https://api.devnet.solana.com"

private_key_bytes = bytes(json.load(open(in_file, 'rb')))
private_key = base58.b58encode(private_key_bytes).decode("ascii")

program_id = "3kjK4HA6A4K86NgNB93gGhSt257wtN4QAqXMNPQ4fVTm"

sdk = psdk.SDKClientImpl(url, private_key, program_id)

Example usage

class ParimutuelSDK(ParimutuelClient):
    def __init__(
        self, url: str, private_key: str, program_id: str, network_key: str = None,
    ):
        self._sdk = psdk.SDKClientImpl(
            url, private_key, program_id, network_key=network_key)

    def get_series_ids(self) -> List[psdk.Series]:
        series = self._sdk.get_series_ids_py()
        return series

    def get_contest_ids(self, series_id: str) -> List[psdk.Contest]:
        contests = self._sdk.get_contest_ids_py(series_id)
        return contests

    def enter_contest(
            self,
            user_id: str,
            contest_id: str,
            contest_type: str,
            direction: str,
            wager: float,
    ) -> psdk.ContestEntry:
        contest_entry = self._sdk.enter_contest_py(
            user_id,
            contest_id,
            contest_type,
            direction,
            wager
        )
        return contest_entry

    def get_contest_entry(
            self,
            user_id,
            contest_entry_id,
    ) -> psdk.ContestEntry:
        contest_entry = self._sdk.get_contest_entry_py(user_id, contest_entry_id)
        return contest_entry

    def get_contest_history(
            self,
            user_id,
    ) -> List[psdk.ContestEntry]:
        contest_entries = self._sdk.get_contest_history_py(user_id)
        return contest_entries

    def get_account_info(
            self,
            user_id: str,
    ) -> List[psdk.AccountBalance]:
        account_balances = self._sdk.get_account_info_py(user_id)
        return account_balances

Comments, Feedback, Suggestions

The SDK attempts to replicate the existing hxro.trade API described here at . We recommend wrapping the SDK in a user defined class that allows adding type hints, for example:

Please find us on the #builder-chat channel on Discord at

https://pypi.org/project/parimutuelsdk
https://hxroapi.readme.io/docs/getting-started
https://discord.com/channels/740983228134981793/980287738819538974