polynode 0.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- polynode-0.5.5/.gitignore +38 -0
- polynode-0.5.5/PKG-INFO +133 -0
- polynode-0.5.5/README.md +100 -0
- polynode-0.5.5/polynode/__init__.py +41 -0
- polynode-0.5.5/polynode/_version.py +1 -0
- polynode-0.5.5/polynode/cache/__init__.py +11 -0
- polynode-0.5.5/polynode/client.py +635 -0
- polynode-0.5.5/polynode/engine.py +201 -0
- polynode-0.5.5/polynode/errors.py +35 -0
- polynode-0.5.5/polynode/orderbook.py +243 -0
- polynode-0.5.5/polynode/orderbook_state.py +77 -0
- polynode-0.5.5/polynode/redemption_watcher.py +339 -0
- polynode-0.5.5/polynode/short_form.py +321 -0
- polynode-0.5.5/polynode/subscription.py +137 -0
- polynode-0.5.5/polynode/testing.py +83 -0
- polynode-0.5.5/polynode/trading/__init__.py +19 -0
- polynode-0.5.5/polynode/trading/clob_api.py +158 -0
- polynode-0.5.5/polynode/trading/constants.py +31 -0
- polynode-0.5.5/polynode/trading/cosigner.py +86 -0
- polynode-0.5.5/polynode/trading/eip712.py +163 -0
- polynode-0.5.5/polynode/trading/onboarding.py +242 -0
- polynode-0.5.5/polynode/trading/signer.py +91 -0
- polynode-0.5.5/polynode/trading/sqlite_backend.py +208 -0
- polynode-0.5.5/polynode/trading/trader.py +506 -0
- polynode-0.5.5/polynode/trading/types.py +191 -0
- polynode-0.5.5/polynode/types/__init__.py +8 -0
- polynode-0.5.5/polynode/types/enums.py +51 -0
- polynode-0.5.5/polynode/types/events.py +270 -0
- polynode-0.5.5/polynode/types/orderbook.py +66 -0
- polynode-0.5.5/polynode/types/rest.py +376 -0
- polynode-0.5.5/polynode/types/short_form.py +35 -0
- polynode-0.5.5/polynode/types/ws.py +38 -0
- polynode-0.5.5/polynode/ws.py +278 -0
- polynode-0.5.5/pyproject.toml +46 -0
- polynode-0.5.5/tests/__init__.py +0 -0
- polynode-0.5.5/tests/conftest.py +29 -0
- polynode-0.5.5/tests/test_client.py +45 -0
- polynode-0.5.5/tests/test_orderbook.py +59 -0
- polynode-0.5.5/tests/test_trading.py +50 -0
- polynode-0.5.5/tests/test_types.py +80 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
target/
|
|
3
|
+
dist/
|
|
4
|
+
node_modules/
|
|
5
|
+
|
|
6
|
+
# Environment files
|
|
7
|
+
.env
|
|
8
|
+
.env.local
|
|
9
|
+
.env.production
|
|
10
|
+
|
|
11
|
+
# IDE
|
|
12
|
+
.idea/
|
|
13
|
+
.vscode/
|
|
14
|
+
*.swp
|
|
15
|
+
*.swo
|
|
16
|
+
|
|
17
|
+
# OS
|
|
18
|
+
.DS_Store
|
|
19
|
+
Thumbs.db
|
|
20
|
+
|
|
21
|
+
# Redis
|
|
22
|
+
*.rdb
|
|
23
|
+
*.aof
|
|
24
|
+
|
|
25
|
+
# Archives
|
|
26
|
+
*.jsonl
|
|
27
|
+
*.jsonl.zst
|
|
28
|
+
|
|
29
|
+
# Secrets
|
|
30
|
+
*.pem
|
|
31
|
+
*.key
|
|
32
|
+
|
|
33
|
+
# Embedded repos (tracked separately)
|
|
34
|
+
docs/
|
|
35
|
+
|
|
36
|
+
# Compiled binaries
|
|
37
|
+
ob/ob
|
|
38
|
+
ob/ob.bak
|
polynode-0.5.5/PKG-INFO
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polynode
|
|
3
|
+
Version: 0.5.5
|
|
4
|
+
Summary: Python SDK for the PolyNode real-time prediction market data platform
|
|
5
|
+
Project-URL: Homepage, https://polynode.dev
|
|
6
|
+
Project-URL: Documentation, https://docs.polynode.dev
|
|
7
|
+
Author-email: PolyNode <josh@quantish.live>
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: polymarket,polynode,prediction-markets,trading,websocket
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: pydantic>=2.0
|
|
22
|
+
Requires-Dist: websockets>=12.0
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: aiosqlite>=0.20; extra == 'all'
|
|
25
|
+
Requires-Dist: eth-account>=0.13; extra == 'all'
|
|
26
|
+
Requires-Dist: web3>=7.0; extra == 'all'
|
|
27
|
+
Provides-Extra: cache
|
|
28
|
+
Requires-Dist: aiosqlite>=0.20; extra == 'cache'
|
|
29
|
+
Provides-Extra: trading
|
|
30
|
+
Requires-Dist: eth-account>=0.13; extra == 'trading'
|
|
31
|
+
Requires-Dist: web3>=7.0; extra == 'trading'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# polynode
|
|
35
|
+
|
|
36
|
+
Python SDK for the [PolyNode](https://polynode.dev) real-time prediction market data platform.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install polynode
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For trading support:
|
|
45
|
+
```bash
|
|
46
|
+
pip install polynode[trading]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### REST API
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from polynode import PolyNode
|
|
55
|
+
|
|
56
|
+
with PolyNode(api_key="pn_live_...") as pn:
|
|
57
|
+
status = pn.status()
|
|
58
|
+
markets = pn.markets(count=10)
|
|
59
|
+
settlements = pn.recent_settlements(count=5)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Async REST
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import asyncio
|
|
66
|
+
from polynode import AsyncPolyNode
|
|
67
|
+
|
|
68
|
+
async def main():
|
|
69
|
+
async with AsyncPolyNode(api_key="pn_live_...") as pn:
|
|
70
|
+
status = await pn.status()
|
|
71
|
+
markets = await pn.markets(count=10)
|
|
72
|
+
|
|
73
|
+
asyncio.run(main())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### WebSocket Streaming
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import asyncio
|
|
80
|
+
from polynode import AsyncPolyNode
|
|
81
|
+
|
|
82
|
+
async def main():
|
|
83
|
+
async with AsyncPolyNode(api_key="pn_live_...") as pn:
|
|
84
|
+
sub = await pn.ws.subscribe("settlements").min_size(1000).send()
|
|
85
|
+
|
|
86
|
+
async for event in sub:
|
|
87
|
+
print(event.event_type, event.market_title, event.taker_price)
|
|
88
|
+
|
|
89
|
+
asyncio.run(main())
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Orderbook
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import asyncio
|
|
96
|
+
from polynode import OrderbookEngine
|
|
97
|
+
|
|
98
|
+
async def main():
|
|
99
|
+
engine = OrderbookEngine(api_key="pn_live_...")
|
|
100
|
+
await engine.subscribe(["token_id_1", "token_id_2"])
|
|
101
|
+
|
|
102
|
+
engine.on("ready", lambda: print(f"Tracking {engine.size} books"))
|
|
103
|
+
engine.on("update", lambda u: print(f"{u.asset_id}: {engine.midpoint(u.asset_id)}"))
|
|
104
|
+
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Trading
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import asyncio
|
|
112
|
+
from polynode.trading import PolyNodeTrader, TraderConfig, OrderParams
|
|
113
|
+
|
|
114
|
+
async def main():
|
|
115
|
+
trader = PolyNodeTrader(TraderConfig(polynode_key="pn_live_..."))
|
|
116
|
+
status = await trader.ensure_ready("0xYourPrivateKey...")
|
|
117
|
+
|
|
118
|
+
result = await trader.order(OrderParams(
|
|
119
|
+
token_id="...",
|
|
120
|
+
side="BUY",
|
|
121
|
+
price=0.55,
|
|
122
|
+
size=100,
|
|
123
|
+
))
|
|
124
|
+
print(result)
|
|
125
|
+
|
|
126
|
+
trader.close()
|
|
127
|
+
|
|
128
|
+
asyncio.run(main())
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
Full docs at [docs.polynode.dev](https://docs.polynode.dev)
|
polynode-0.5.5/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# polynode
|
|
2
|
+
|
|
3
|
+
Python SDK for the [PolyNode](https://polynode.dev) real-time prediction market data platform.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install polynode
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For trading support:
|
|
12
|
+
```bash
|
|
13
|
+
pip install polynode[trading]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### REST API
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from polynode import PolyNode
|
|
22
|
+
|
|
23
|
+
with PolyNode(api_key="pn_live_...") as pn:
|
|
24
|
+
status = pn.status()
|
|
25
|
+
markets = pn.markets(count=10)
|
|
26
|
+
settlements = pn.recent_settlements(count=5)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Async REST
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import asyncio
|
|
33
|
+
from polynode import AsyncPolyNode
|
|
34
|
+
|
|
35
|
+
async def main():
|
|
36
|
+
async with AsyncPolyNode(api_key="pn_live_...") as pn:
|
|
37
|
+
status = await pn.status()
|
|
38
|
+
markets = await pn.markets(count=10)
|
|
39
|
+
|
|
40
|
+
asyncio.run(main())
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### WebSocket Streaming
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import asyncio
|
|
47
|
+
from polynode import AsyncPolyNode
|
|
48
|
+
|
|
49
|
+
async def main():
|
|
50
|
+
async with AsyncPolyNode(api_key="pn_live_...") as pn:
|
|
51
|
+
sub = await pn.ws.subscribe("settlements").min_size(1000).send()
|
|
52
|
+
|
|
53
|
+
async for event in sub:
|
|
54
|
+
print(event.event_type, event.market_title, event.taker_price)
|
|
55
|
+
|
|
56
|
+
asyncio.run(main())
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Orderbook
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import asyncio
|
|
63
|
+
from polynode import OrderbookEngine
|
|
64
|
+
|
|
65
|
+
async def main():
|
|
66
|
+
engine = OrderbookEngine(api_key="pn_live_...")
|
|
67
|
+
await engine.subscribe(["token_id_1", "token_id_2"])
|
|
68
|
+
|
|
69
|
+
engine.on("ready", lambda: print(f"Tracking {engine.size} books"))
|
|
70
|
+
engine.on("update", lambda u: print(f"{u.asset_id}: {engine.midpoint(u.asset_id)}"))
|
|
71
|
+
|
|
72
|
+
asyncio.run(main())
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Trading
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import asyncio
|
|
79
|
+
from polynode.trading import PolyNodeTrader, TraderConfig, OrderParams
|
|
80
|
+
|
|
81
|
+
async def main():
|
|
82
|
+
trader = PolyNodeTrader(TraderConfig(polynode_key="pn_live_..."))
|
|
83
|
+
status = await trader.ensure_ready("0xYourPrivateKey...")
|
|
84
|
+
|
|
85
|
+
result = await trader.order(OrderParams(
|
|
86
|
+
token_id="...",
|
|
87
|
+
side="BUY",
|
|
88
|
+
price=0.55,
|
|
89
|
+
size=100,
|
|
90
|
+
))
|
|
91
|
+
print(result)
|
|
92
|
+
|
|
93
|
+
trader.close()
|
|
94
|
+
|
|
95
|
+
asyncio.run(main())
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Documentation
|
|
99
|
+
|
|
100
|
+
Full docs at [docs.polynode.dev](https://docs.polynode.dev)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""PolyNode Python SDK — real-time prediction market data and trading."""
|
|
2
|
+
|
|
3
|
+
from ._version import __version__
|
|
4
|
+
from .client import AsyncPolyNode, PolyNode
|
|
5
|
+
from .engine import EngineView, OrderbookEngine
|
|
6
|
+
from .errors import ApiError, PolyNodeError, WsError
|
|
7
|
+
from .orderbook import OrderbookWS
|
|
8
|
+
from .orderbook_state import LocalOrderbook
|
|
9
|
+
from .redemption_watcher import RedeemableAlert, RedemptionWatcher, TrackedPosition
|
|
10
|
+
from .short_form import ShortFormStream
|
|
11
|
+
from .subscription import Subscription, SubscriptionBuilder
|
|
12
|
+
from .testing import get_active_test_wallet, get_active_test_wallets
|
|
13
|
+
from .ws import PolyNodeWS
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"__version__",
|
|
17
|
+
# Clients
|
|
18
|
+
"PolyNode",
|
|
19
|
+
"AsyncPolyNode",
|
|
20
|
+
# WebSocket
|
|
21
|
+
"PolyNodeWS",
|
|
22
|
+
"SubscriptionBuilder",
|
|
23
|
+
"Subscription",
|
|
24
|
+
# Orderbook
|
|
25
|
+
"OrderbookWS",
|
|
26
|
+
"LocalOrderbook",
|
|
27
|
+
"OrderbookEngine",
|
|
28
|
+
"EngineView",
|
|
29
|
+
# Streams
|
|
30
|
+
"ShortFormStream",
|
|
31
|
+
"RedemptionWatcher",
|
|
32
|
+
"RedeemableAlert",
|
|
33
|
+
"TrackedPosition",
|
|
34
|
+
# Testing
|
|
35
|
+
"get_active_test_wallet",
|
|
36
|
+
"get_active_test_wallets",
|
|
37
|
+
# Errors
|
|
38
|
+
"PolyNodeError",
|
|
39
|
+
"ApiError",
|
|
40
|
+
"WsError",
|
|
41
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.5"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Cache module placeholder — local SQLite-backed trade/position history.
|
|
2
|
+
|
|
3
|
+
This module will be implemented in a future release.
|
|
4
|
+
The cache/ directory structure matches the TypeScript SDK:
|
|
5
|
+
- sqlite_backend.py — SQLite storage (settlements, trades, positions)
|
|
6
|
+
- watchlist.py — JSON watchlist file management
|
|
7
|
+
- backfill.py — Rate-limited REST backfill orchestrator
|
|
8
|
+
- query_builder.py — Fluent query builder
|
|
9
|
+
- views.py — Analytical views (wallet_dashboard, leaderboard, etc.)
|
|
10
|
+
- export.py — CSV/JSON export
|
|
11
|
+
"""
|