Skip to main content

StackSats

Python library for quantitative Bitcoin accumulation via DCA strategies.

Not a general crypto trading bot or brokerage wrapper—see What StackSats is.

StackSats Logo

PyPI version Python versions Package Check License: MIT

StackSats is a Python library for building, backtesting, and operationalizing quantitative dollar-cost averaging (DCA) strategies for Bitcoin accumulation. It helps you turn research signals and feature pipelines into validated BTC weight schedules and daily allocation decisions.

Use StackSats when you want to:

  • build custom Bitcoin accumulation strategies in Python
  • backtest DCA rules against BRK-derived canonical Bitcoin datasets
  • validate causal constraints before shipping a strategy
  • emit daily BTC allocation decisions for agents or external execution systems

StackSats is library-first: the CLI, demo flows, and hosted agent API all sit on top of the same Python package surface.

Learn more at www.stackingsats.org.

Hosted documentation: https://hypertrial.github.io/stacksats/ — start from docs/index.md.

What StackSats is

StackSats is not a general crypto trading bot or brokerage wrapper. It is a research and decision engine for Bitcoin accumulation strategies:

  • Python library: define strategies with BaseStrategy, run them with stable configs, and consume results from Python.
  • Quantitative DCA toolkit: model how much BTC to accumulate over time instead of placing exchange-specific orders directly.
  • Backtesting framework: compare strategies, validate constraints, and export artifact sets from repeatable runs.
  • Execution boundary: StackSats computes decisions; brokerage execution stays outside the package unless you wire in an adapter intentionally.

Documentation map

BRK compatibility

StackSats is a Python library with explicit compatibility for the Bitcoin Research Kit (BRK) project and BRK-derived canonical data workflows. We document BRK as the upstream project and link to the official BRK surfaces: bitcoinresearchkit/brk, brk on crates.io, and brk on docs.rs.

This is a project and data compatibility statement, not a promise that StackSats embeds BRK, re-exports Rust crates, or version-locks BRK crate APIs. StackSats remains a Python package with its own stable 1.x support boundary.

Framework principles

The framework owns budget math, iteration, feasibility clipping, and lock semantics; you own features, signals, hyperparameters, and daily intent (propose_weight or build_target_profile). The same sealed allocation kernel runs in local runs, backtests, and production. See docs/framework.md.

Primary production flow

  1. StackSats computes a validated BTC accumulation decision.
  2. An external agent or automation reads the decision payload.
  3. Brokerage execution stays outside StackSats.

Use stacksats strategy decide-daily (or strategy.decide_daily(...)) for the agent-facing interface; docs/run/decide-daily.md covers payloads and sensitivity. Use stacksats serve agent-api for a hosted /v1 HTTP service (docs/run/agent-api.md, including token policy). Use stacksats strategy run-daily when StackSats should submit through a configured adapter (docs/run/run-daily.md).

Security: follow SECURITY.md for reporting; treat decision and API tokens as secrets.

Installation

Use case Command
Use StackSats from PyPI pip install stacksats
Editable install from a checkout python -m pip install -c requirements/constraints-maintainer.txt -e ".[dev,all]"

Optional extras: pip install "stacksats[viz]" (animation/plots), [network] (HTTP BTC price helpers), [service] (agent API), [deploy] (Postgres/export helpers). The stacksats-plot-weights helper needs both [viz] and [deploy] plus a configured DATABASE_URL (it reads stored weight windows, then renders). Helper scripts are documented convenience tools, not part of the frozen stable 1.x CLI subset.

Development venv (from repo root):

python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -c requirements/constraints-maintainer.txt -e ".[dev,all]"
pip install pre-commit
venv/bin/python -m pre_commit install -t pre-commit

Quick start

Install, import the stable 1.x surface, then run the packaged demo:

pip install stacksats
from stacksats import BaseStrategy, StrategyRunner, list_strategies
stacksats demo backtest

Artifacts: output/<strategy_id>/<version>/<run_id>/

If you want to build strategies in Python next, start with docs/start/first-strategy-run.md and docs/start/minimal-strategy-examples.md. For the full CLI, use docs/commands.md. For BRK data setup (stacksats data fetch|prepare|doctor), use docs/start/full-data-setup.md. For the support boundary, use docs/stability.md. stacksats strategy validate is strict by default; use --no-strict only when you intend the lighter path.

Public API

The stable 1.x contract covers top-level exports, documented artifacts, and the documented CLI/agent API subset. See docs/reference/public-api.md and docs/stability.md. load_data() uses strict BRK validation; for long-format merged metrics exploration, see docs/start/eda-quickstart.md.

Development

See CONTRIBUTING.md for the full local quality matrix (tests, docs gates, coverage, release checks). Typical fast loop:

venv/bin/python -m pytest -q
venv/bin/python -m ruff check .
bash scripts/check_docs_refs.sh
venv/bin/python scripts/check_docs_ux.py
venv/bin/python -m mkdocs build --strict

If the repo path changes locally, rerun bash scripts/install_hooks.sh to refresh git hook paths.

Metadata

Release files for stacksats 1.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 stacksats 1.3.0
File Size Uploaded
stacksats-1.3.0.tar.gz 1.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for stacksats 1.3.0
File Interpreter ABI Platform
stacksats-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.8 MB

Release files / stacksats-1.3.0.tar.gz

Download URL stacksats-1.3.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
c2854949c5fba0329b830eb7b8ddbfa1da9879739274d84efae5c350ca04bcfb
BLAKE2b-256 checksum
How to use checksums
8f376d861078156106cac5ed0344c46afcc0096930b9971977a9a91da15229b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.12

Release files / stacksats-1.3.0-py3-none-any.whl

Download URL stacksats-1.3.0-py3-none-any.whl
Size 882.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
374783bc617ecae44e9d617d5011565beaaf35d989db21810b88b87a7e472839
BLAKE2b-256 checksum
How to use checksums
f350927c02d91a2261831d57b6c0b7bc04b34c712884c1f76a3d18321d0e3d6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.12
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