Skip to main content

Python SDK for the PolyNode real-time prediction market data platform

Project description

polynode

Python SDK for the PolyNode real-time prediction market data platform.

Install

pip install polynode

For trading support:

pip install polynode[trading]

Quick Start

REST API

from polynode import PolyNode

with PolyNode(api_key="pn_live_...") as pn:
    status = pn.status()
    markets = pn.markets(count=10)
    settlements = pn.recent_settlements(count=5)

Async REST

import asyncio
from polynode import AsyncPolyNode

async def main():
    async with AsyncPolyNode(api_key="pn_live_...") as pn:
        status = await pn.status()
        markets = await pn.markets(count=10)

asyncio.run(main())

WebSocket Streaming

import asyncio
from polynode import AsyncPolyNode

async def main():
    async with AsyncPolyNode(api_key="pn_live_...") as pn:
        sub = await pn.ws.subscribe("settlements").min_size(1000).send()

        async for event in sub:
            print(event.event_type, event.market_title, event.taker_price)

asyncio.run(main())

Orderbook

import asyncio
from polynode import OrderbookEngine

async def main():
    engine = OrderbookEngine(api_key="pn_live_...")
    await engine.subscribe(["token_id_1", "token_id_2"])

    engine.on("ready", lambda: print(f"Tracking {engine.size} books"))
    engine.on("update", lambda u: print(f"{u.asset_id}: {engine.midpoint(u.asset_id)}"))

asyncio.run(main())

Trading

import asyncio
from polynode.trading import PolyNodeTrader, TraderConfig, OrderParams

async def main():
    trader = PolyNodeTrader(TraderConfig(polynode_key="pn_live_..."))
    status = await trader.ensure_ready("0xYourPrivateKey...")

    result = await trader.order(OrderParams(
        token_id="...",
        side="BUY",
        price=0.55,
        size=100,
    ))
    print(result)

    trader.close()

asyncio.run(main())

Documentation

Full docs at docs.polynode.dev

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

polynode-0.6.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

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

polynode-0.6.0-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file polynode-0.6.0.tar.gz.

File metadata

  • Download URL: polynode-0.6.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for polynode-0.6.0.tar.gz
Algorithm Hash digest
SHA256 8eb0d984c76f4cc568b58aef9a9357cd4d5f2a5c0f8a5e41e6bfe8ff9f0b95bc
MD5 31df22433e940c04e583e8e4f8b22dc4
BLAKE2b-256 8a6e23dda908b363d6ae7df91193fbe18f05fac2c912e2d6647c3c9f8541b08a

See more details on using hashes here.

File details

Details for the file polynode-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: polynode-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 47.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for polynode-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21b5904fd29eaaf1362cd618aec24cc431c4c1102b419d58627ba2e64df789c5
MD5 8e0994b452e37239c70757e0f76179ac
BLAKE2b-256 a7b8db2c5dca3b520f7cf7e539c3b583f0d215fe9474a1c0b4de39ef5624c24f

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