Data provider for Python - Query data from local DuckDB
Project description
nextpoly-data-provider
NextPoly data provider for Python, built with Rust and PyO3.
Features
- Query Polymarket on-chain data (order filled events, FPMM transactions)
- Query Polymarket off-chain data (markets, market tokens)
- Query timeseries data for trading analysis
- Time-travel queries with
simulation_timeparameter - Built on DuckDB for fast local queries
- Python 3.11+ support with abi3 compatibility
Installation
pip install nextpoly-data-provider
uv
uv add nextpoly-data-provider
# or
uv pip install nextpoly-data-provider
Quick Start
from data_provider import DataProvider
# Create provider with default data directory
provider = DataProvider()
# Or specify a custom data directory
# provider = DataProvider(data_dir="path/to/data")
# Optional: limit DuckDB memory per connection
# provider = DataProvider(memory_limit="4GB")
# Optional: set spill directory + threads per connection
# provider = DataProvider(temp_directory="/tmp/duckdb", threads=4)
# Query markets
markets = provider.off_chain.list_markets(limit=10)
for market in markets:
print(f"{market.raw_data.get('question')}")
# Query on-chain events
orders = provider.on_chain.list_orders(limit=10)
# Query time series data
ts = provider.trading.get_timeseries(token_id="...")
Time Travel Queries
from datetime import datetime, timezone
# Query data as of a specific time
ts = int(datetime(2024, 1, 1, tzinfo=timezone.utc).timestamp())
provider = DataProvider(simulation_time=ts)
# Or set it later
provider.set_simulation_time(ts)
Development
Building from source
cd crates/data-provider
uv sync
uv run maturin develop
Running tests
# Install test dependencies
uv pip install pytest duckdb --python .venv/bin/python
# Run all tests
.venv/bin/python -m pytest tests/ -v
# Run specific test file
.venv/bin/python -m pytest tests/test_queries.py -v
Code quality
# Lint with ruff
ruff check tests/
# Type check with ty
uv tool run ty check tests/
Requirements
- Python 3.11+
- Local DuckDB database files
Type stubs
Type stubs live next to the package in crates/data-provider/data_provider/*.pyi.
To build the extension with maturin and verify stubs against runtime objects:
uv --version
cargo run -p xtask -- stub-check
stub-check uses uv run in crates/provider, creating .venv if needed and installing
maturin, mypy, ruff, and ty automatically.
Pass --debug to skip --release.
Publishing
maturin publish --release
License
MIT
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 Distributions
Built Distributions
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
File details
Details for the file nextpoly_data_provider-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: nextpoly_data_provider-0.10.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.2 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a01bfe03c3f992d894ba3bd0e304f4f595aa261468ffdd012a54b1fad1c91de
|
|
| MD5 |
a51b2a466631558d1130a0c0ee3def1e
|
|
| BLAKE2b-256 |
2f6783d78f3686ee7e45f96c8de59e7a25b37539973afba229ae89080058693e
|
File details
Details for the file nextpoly_data_provider-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: nextpoly_data_provider-0.10.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 10.2 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60963e092641be8a77030b31e70ad53ec11daffdf1e20b4dfc23b312042282cf
|
|
| MD5 |
eb6031d90f2be79953737fffcb1b2ecc
|
|
| BLAKE2b-256 |
cd37c363544402f4373cf4277fc385ce1f4342a4071d18dab3e342e8a3952b56
|
File details
Details for the file nextpoly_data_provider-0.10.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: nextpoly_data_provider-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 10.9 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abb7d834540e8142bf89a744315d3ac68b5a5c38ddc13b4d49999a4ffbc9cc3a
|
|
| MD5 |
27311f931e405b5bad7b7fe03d06beb5
|
|
| BLAKE2b-256 |
28eafae6143602f208dadf1de8bf52e2249641a16161204505ae82346df13269
|