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
Release history Release notifications | RSS feed
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.7.3.tar.gz
(45.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
polynode-0.7.3-py3-none-any.whl
(55.7 kB
view details)
File details
Details for the file polynode-0.7.3.tar.gz.
File metadata
- Download URL: polynode-0.7.3.tar.gz
- Upload date:
- Size: 45.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
022f7e2392e6d0a3e2c7bf2f1d55af6a6c7fed4d09a0686b8b88e8c23ec3d36f
|
|
| MD5 |
879bbb6bf27d4a3ec41f19562ce8ce7c
|
|
| BLAKE2b-256 |
87ca0bf0f8761285005ae16bf2186a8f6b96b177047fe37e5090c6848eb2faf3
|
File details
Details for the file polynode-0.7.3-py3-none-any.whl.
File metadata
- Download URL: polynode-0.7.3-py3-none-any.whl
- Upload date:
- Size: 55.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a1a14c05e4968a24f2b1e0ff44a3603051d8005cdbaa936b32abef29177209
|
|
| MD5 |
82b3b054dc3522691ca77c83fc075d88
|
|
| BLAKE2b-256 |
a576e29de9242c74c283c934eff1ab506e3034ee0c6fb09d26be983ce1310f40
|