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.5.tar.gz (11.5 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.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pokpok_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 11.5 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.5.tar.gz
Algorithm Hash digest
SHA256 2192f8dd0120c699f67c6d7627f3f9c0f5b00d7ba8c7a805336548fce6040494
MD5 d84ef449cd14151b9bdd36a32485fa2b
BLAKE2b-256 dc30894ad240865a89f3c0c77930b0900d29e3da76ce25fcf31eb0b789f643ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pokpok_sdk-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 952012d63c30ac86c83eb0236d7f21c5087557d1ae66708467018f1ccf61fc8a
MD5 c6e3a07faa02416f89e3724a95a3fb8e
BLAKE2b-256 79ce6a424e6db02e06c5d4868782e93b40784274893af4c47b33a5122c3b3e47

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