Skip to main content

PineForge Data

PyPI Python CI Documentation

Fetch normalized market data and run raw PineScript strategies through PineForge.

PineForge Data provides Python adapters for exchanges, CSV files, SQLite, and SQLAlchemy-compatible databases. Its backtest harness sends normalized OHLCV to the pineforge-release container, which transpiles the PineScript, compiles it, and runs pineforge-engine.

exchange / CSV / database
          ↓
    pineforge-data
          ↓
 pineforge-release container
          ↓
     backtest report

The provider layer is Python-only. You do not need a C++ compiler, Git submodules, or local engine and codegen checkouts.

Quick start

You need Python 3.11 or newer. Docker is required only for backtests; fetching and normalizing data does not use Docker.

1. Install an exchange provider

python -m pip install 'pineforge-data[ccxt]'

2. Fetch confirmed OHLCV

import asyncio

from pineforge_data import BarRequest, CcxtProvider


async def main() -> None:
    async with CcxtProvider("bitstamp") as provider:
        market = await provider.resolve_market("BTC/USD")
        bars = await provider.fetch_bars(
            BarRequest(
                instrument=market.instrument,
                timeframe="15m",
                start_ms=1_751_328_000_000,
                end_ms=1_751_414_400_000,
            )
        )
        print(bars[-1])


asyncio.run(main())

Symbols are resolved through the provider catalog. For example, CCXT spot BTC/USDT and linear swap BTC/USDT:USDT are distinct instruments with different contract metadata.

3. Backtest raw PineScript

Save a strategy as strategy.pine:

//@version=6
strategy("SMA cross", initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

fast = ta.sma(close, 2)
slow = ta.sma(close, 4)

if ta.crossover(fast, slow)
    strategy.entry("Long", strategy.long)

if ta.crossunder(fast, slow)
    strategy.close("Long")

Then run:

pineforge-backtest \
  --pine strategy.pine \
  --provider ccxt \
  --venue bitstamp \
  --symbol BTC/USD \
  --timeframe 15m \
  --start 2025-07-01T00:00:00Z \
  --end 2025-07-08T00:00:00Z \
  --warmup-bars 100 \
  --output report.json \
  --pretty

The first run pulls the digest-pinned pineforge-release 1.0.0 image (engine 1.0.0, codegen 1.0.0). Results can differ between releases, notably for scripts that omit their capital or order size; the runtime image policy explains why and how to pin another release with --runtime-image. The JSON report includes trades, performance statistics, the equity curve, data provenance, and exact runtime versions. The strategy is compiled inside an isolated Docker container; the provider and its credentials remain on the host.

Bring your own data

PineForge does not require a fixed table definition. Local providers inspect headers or reflected database columns at runtime, infer common OHLCV names, and accept an explicit mapping when your schema uses different names.

Source Install Guide
CSV pip install pineforge-data CSV API
SQLite pip install pineforge-data SQLite API
SQLAlchemy database pip install 'pineforge-data[database]' plus a database driver SQLAlchemy API
CCXT exchange pip install 'pineforge-data[ccxt]' CCXT API

The same pineforge-backtest command supports --provider csv, sqlite, and sqlalchemy. See the backtesting guide for provider configuration, warmup behavior, strategy inputs, reports, and local versus remote execution.

Documentation

I want to… Read…
Install and run the first request Getting started
Look up Python classes and signatures API reference
Choose or configure a provider Provider catalog
Understand instruments, contracts, and bars Data model
Run and reproduce backtests Backtesting
Deploy the concurrent compile/backtest service FastAPI server
Implement a broker or exchange adapter Provider contract

Contributing

Community providers are welcome. Keep vendor SDKs and schemas inside the adapter, resolve instruments through the upstream market catalog, normalize timestamps to Unix milliseconds, and add deterministic offline tests.

git clone https://github.com/pineforge-4pass/pineforge-data.git
cd pineforge-data
python -m pip install -e '.[dev,ccxt,database-e2e,server,docs,release]'
ruff check .
mypy src
pytest
mkdocs build --strict

Run ./scripts/run_database_e2e.sh to seed corpus OHLCV into disposable SQLite, MySQL, and PostgreSQL databases and verify the public provider API against all three.

Read CONTRIBUTING.md for the provider contract, entry points, security rules, and full validation checklist.

Apache-2.0 licensed.

Metadata

Release files for pineforge-data 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pineforge-data 0.3.0
File Size Uploaded
pineforge_data-0.3.0.tar.gz 101.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pineforge-data 0.3.0
File Interpreter ABI Platform
pineforge_data-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 158.1 kB

Release files / pineforge_data-0.3.0.tar.gz

Download URL pineforge_data-0.3.0.tar.gz
Size 101.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f29a2bd50f70ff46ebdf31f987260dec3123600ab5bf493741bbbd4e21aaacdc
BLAKE2b-256 checksum
How to use checksums
2735f47445a87f25518f1ce9774a9b908d63cc0992d5a7af5bdbe93d39685011
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / pineforge_data-0.3.0-py3-none-any.whl

Download URL pineforge_data-0.3.0-py3-none-any.whl
Size 56.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
609b3e9976ae55fc290c725731cf1dd0266c9b3eb6f3353122c8bcdc05e497bc
BLAKE2b-256 checksum
How to use checksums
7f0422539b2a53b9444ed0e3197c618dfa97f77ff902d0bcf67aaf16150cffac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page