Skip to main content

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_time parameter
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

nextpoly_data_provider-0.10.1-cp311-abi3-macosx_11_0_arm64.whl (10.9 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6166dec4e77eea76fe7b4c20432f8e1d1dc3f9a1e135782a6360c8a9bb9a66eb
MD5 a900c9535c8150107e426daf680f47a8
BLAKE2b-256 c6a884a9661bad81cc2e770c473cfa4bc8e6dc416147951ad8c000c6c11dc5a9

See more details on using hashes here.

File details

Details for the file nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nextpoly_data_provider-0.10.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1fd2648ccb4d1d3941f5258b97fded0750ff83a985ff2867231f908f90c1d6fd
MD5 7edad9c569151bb27e380d88d932f346
BLAKE2b-256 1b5d50c4f6fc659b52d91e602477515f842c050bdace2b350e72e55a0131d0e4

See more details on using hashes here.

File details

Details for the file nextpoly_data_provider-0.10.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nextpoly_data_provider-0.10.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 068357061f156acb8d1dd997d4f1a9e0d5ead8db325938fd5655d37e1f398476
MD5 5104a981a8c0af33406a367ccb70dcba
BLAKE2b-256 6c6736a58ccbba0b64f2e24322757544eac42c52aa4a93dc2cac0994e74964c9

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