This repository implements an incremental dlt connector for the Kraken Futures REST API. It focuses on Futures endpoints (executions, account log, position history) with snapshot resources for tickers and open positions.
# Install dependencies
uv sync
# Configure Futures credentials
export KRAKEN_FUTURES__API_KEY="your_futures_public_key"
export KRAKEN_FUTURES__API_SECRET="your_futures_base64_secret"
# Run first sync (from last 7 days)
uv run python -m pipelines.run_pipeline \
--resources executions \
--since "2024-01-01T00:00:00Z"
# Subsequent runs automatically resume from last cursor
uv run python -m pipelines.run_pipeline --resources executionsData is stored in .dlt/kraken_futures.duckdb. See Running the pipeline for all options.
src/kraken_dlt_source/– unified source package:futures/– Kraken Futures API implementationauth.pysigns private REST calls (nonce + HMAC-SHA512)resources.pydefines incremental/snapshot resources and shared HTTP client logic__init__.pywires the publickraken_futures_source()factory
spot/– (Coming soon) Kraken Spot API implementationcommon/– shared utilities across all Kraken APIs
pipelines/run_pipeline.py– CLI entry point with logging, JSON output, and resource selection flagstests/– pytest suites backed by recorded fixtures undertests/fixtures/documentation/plans/– numbered plan files with implementation details and reference notes
- Python 3.12+
- uv for environment management (
pip install uv). - DuckDB is used as the default destination; no external service is required.
uv sync # install runtime + dev dependencies
cp .env.example .env # populate with secrets (create file if needed)Export the Kraken Futures credentials before running private resources:
export KRAKEN_FUTURES__API_KEY=...
export KRAKEN_FUTURES__API_SECRET=...Note the double underscore (__) - this is dlt's convention for nested configuration.
KRAKEN_FUTURES__API_SECRET must be the base64-encoded secret provided by Kraken Futures. Never commit secrets; .gitignore already excludes .env and .dlt/.
When Spot support is added, you'll use separate credentials:
export KRAKEN_SPOT__API_KEY=...
export KRAKEN_SPOT__API_SECRET=...uv run python -m pipelines.run_pipeline \
--resources executions account_log position_history \
--since "2024-01-01T00:00:00Z" \
--strict \
--jsonFlags:
--resourcesfilters the@dlt.resources to load (defaults to all).--sinceseeds the first incremental run (state will persist afterwards).--strictraises if any job fails.--jsonprints the structuredLoadInfopayload; logs always include per-resource row counts and last cursor.
For snapshots only:
uv run python -m pipelines.run_pipeline --resources tickers open_positionsAfter a run, inspect cursor positions:
uv run python -c "
import dlt
pipeline = dlt.pipeline(pipeline_name='kraken_futures')
state = pipeline.state
for resource in ['executions', 'account_log', 'position_history']:
print(f'{resource}:', state.get('resources', {}).get(resource, {}))
"Reset all state and data:
dlt pipeline kraken_futures drop --drop-allReset just one resource (requires Python):
import dlt
pipeline = dlt.pipeline(pipeline_name='kraken_futures')
if 'executions' in pipeline.state.get('resources', {}):
del pipeline.state['resources']['executions']
pipeline.sync_state()Run the full suite (unit + integration-style fixtures):
uv run pytestKey scenarios covered:
- Pagination and state persistence for incremental resources.
- Fallback paging (account log) and nested normalization (position history).
- Auth header signing, retry/backoff behaviour, and error handling.
- The client already implements exponential backoff with jitter for HTTP 429/5xx responses.
- Resource logs include row counts and cursor checkpoints; use them for monitoring.
- Extend
tests/fixtures/with new payloads when adding endpoints or edge cases (e.g., API permission failures, malformed records).
Run tests with coverage:
uv run pytest --cov=kraken_dlt_source --cov-report=term-missing- ✅ Kraken Futures REST API
- Incremental: executions, account log, position history
- Snapshots: tickers, open positions
- More endpoints for the futures REST API
- 🔄 Kraken Spot REST API (planned)
- Account balances, trade history, order history
- Ledger entries, deposits, withdrawals
Contributions welcome! Open an issue to discuss new features or improvements.
dlt uses a double underscore (__) convention for nested configuration:
# Futures API
export KRAKEN_FUTURES__API_KEY="your_futures_public_key"
export KRAKEN_FUTURES__API_SECRET="your_futures_base64_secret"
# Spot API (when available)
export KRAKEN_SPOT__API_KEY="your_spot_public_key"
export KRAKEN_SPOT__API_SECRET="your_spot_secret"Alternatively, create .dlt/secrets.toml:
[kraken_futures]
api_key = "your_futures_public_key"
api_secret = "your_futures_base64_secret"
[kraken_spot]
api_key = "your_spot_public_key"
api_secret = "your_spot_secret"This allows you to run both Futures and Spot sources with separate credentials in the same pipeline.
MIT License - see LICENSE for details.