Skip to main content

Python SDK for PokPok API

Project description

PokPok SDK

A Python SDK for interacting with PokPok's options trading platform. This SDK provides easy access to both Pay-as-you-go (PAYG) and Spread trading functionalities.

Installation

Install the package using pip:

pip install pokpok-sdk

Configuration

The SDK requires some environment variables to be set up. Create a .env file in your project root:

MERCHANT_PKEY=your_private_key_here

Usage

Initialize Clients

You can initialize both PAYG and Spread clients with your API key. Optionally, you can provide a custom RPC URL:

from pokpok_sdk import Payg, Spread

# Basic initialization
payg = Payg(api_key='your_api_key')
spread = Spread(api_key='your_api_key')

# With custom RPC URL
payg = Payg(api_key='your_api_key', rpc_url='your_custom_rpc_url')
spread = Spread(api_key='your_api_key', rpc_url='your_custom_rpc_url')

PAYG Trading Example

from pokpok_sdk import Payg, QuoteFetchInput
from pokpok_sdk.exceptions import PokPokError

# Create input for quote fetching
payg_input = QuoteFetchInput(
    duration=3,
    meal="economical",
    coin="eth",
    option="up",
    size=0.5,
    amount=1
)

# Execute PAYG trade
try:
    payg = Payg(api_key='your_api_key')

    # Fetch quote
    fetched_quote = payg.fetch_quote(input=payg_input)

    # Place order
    tx_receipt = payg.place_order(
        fetch_quote_input=payg_input,
        fetched_quote=fetched_quote
    )
    print(f"Transaction Receipt: {tx_receipt}")
except PokPokError as e:
    print(f"Error: {e}")

Spread Trading Example

from pokpok_sdk import Spread, SpreadQuoteFetchInput
from pokpok_sdk.exceptions import PokPokError

# Create input for spread quote fetching
spread_input = SpreadQuoteFetchInput(
    duration=3,
    meal="economical",
    coin="eth",
    option="up",
    size=0.5,
    spreadPercent=5,
    amount=1
)

# Execute Spread trade
try:
    spread = Spread(api_key='your_api_key')

    # Fetch quote
    fetched_quote = spread.fetch_quote(input=spread_input)

    # Place order
    tx_receipt = spread.place_order(
        fetch_quote_input=spread_input,
        fetched_quote=fetched_quote
    )
    print(f"Transaction Receipt: {tx_receipt}")
except PokPokError as e:
    print(f"Error: {e}")

Input Parameters

QuoteFetchInput

  • duration: Trading duration 3 or 7 days
  • meal: Trading strategy type (e.g., "economical")
  • coin: Trading pair (e.g., "eth")
  • option: Option type ("up" or "down")
  • size: Position size
  • amount: Trading amount

SpreadQuoteFetchInput

Includes all parameters from QuoteFetchInput plus:

  • spreadPercent: Spread percentage for the trade

Error Handling

The SDK uses custom PokPokError for error handling. Always wrap your API calls in try-except blocks:

from pokpok_sdk.exceptions import PokPokError

try:
    # Your SDK calls here
except PokPokError as e:
    print(f"Error: {e}")

License

MIT

Support

For support, please contact support@pokpok.io

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

pokpok_sdk-0.1.6.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pokpok_sdk-0.1.6-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file pokpok_sdk-0.1.6.tar.gz.

File metadata

  • Download URL: pokpok_sdk-0.1.6.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for pokpok_sdk-0.1.6.tar.gz
Algorithm Hash digest
SHA256 03d36b602dfa2cbaa81ce632376a7bcc8adb948a3bfb8afb6601b80aaa171a1a
MD5 79fd88ba76646d869fa5989e8677ecf1
BLAKE2b-256 cfc0eab5dfa6682219a13a88d7eb847d50e690899fea79b8eeda1dc9765eac25

See more details on using hashes here.

File details

Details for the file pokpok_sdk-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: pokpok_sdk-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for pokpok_sdk-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5b53d4aee70f0baf63672f9ca2eab2d30d94602c18cf7e732adec216778db3a3
MD5 7a83f0a0ba97740d57b8477d64260a51
BLAKE2b-256 0dd17a1c44fb70682018ef26da3e109825da6d70af74c0fb4d2bc6171046c2c3

See more details on using hashes here.

Supported by

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