Skip to main content

Add your description here

Project description

sf-backtester

SLURM-based parallel backtesting for quantitative finance. Distributes MVO optimization across compute nodes, processing one year per task.

Installation

pip install sf-backtester

Usage

CLI

# Run backtest
sf_backtester run config.yml

# Preview sbatch script without submitting
sf_backtester run config.yml --dry-run

Python API

from sf_backtester import BacktestRunner, BacktestConfig

slurm_config = SlurmConfig(
    n_cpus=8,
    mem="32G",
    time="03:00:00",
    mail_type="BEGIN,END,FAIL",
    max_concurrent_jobs=30,
)

config = BacktestConfig(
    signal_name="momentum",
    gamma=50,
    data_path="/path/to/alphas.parquet",
    project_root="/path/to/project",
    byu_email="you@byu.edu",
    constraints=["ZeroBeta", "ZeroInvestment"],
    slurm=slurm_config,
)

runner = BacktestRunner(config)

# Preview the sbatch script
print(runner.dry_run())

# Submit to SLURM
runner.submit()

Or load from YAML:

from sf_backtester import BacktestRunner

runner = BacktestRunner.from_yaml("config.yml")

runner.submit()

You can also pass a DataFrame directly:

from sf_backtester import BacktestRunner
import polars as pl

runner = BacktestRunner.from_yaml("config.yml")

data = pl.read_parquet("alphas.parquet")

runner.submit(data=data)

Configuration

YAML format

signal_name: momentum
gamma: 500
data_path: /path/to/alphas.parquet
project_root: /path/to/project
email: you@byu.edu

constraints:
  - ZeroBeta
  - ZeroInvestment

slurm:
  n_cpus: 8
  mem: 32G
  time: "03:00:00"
  mail_type: BEGIN,END,FAIL

Data format

Input parquet must have columns:

  • date: Date column
  • barrid: Asset identifier
  • alpha: Alpha signal values
  • predicted_beta: Predicted beta values

Output is one parquet per year in output_dir/{year}.parquet containing portfolio weights.

Publishing

  1. Bump the version
uv version v*.*.*
  1. Add changes (it can be just the version change)
git add .
git commit -m "Bumped version."
  1. Tag the branch
git tag v*.*.*
  1. Push to origin
git push origin/main --tags

Project details


Download files

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

Source Distribution

sf_backtester-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

sf_backtester-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file sf_backtester-0.1.1.tar.gz.

File metadata

  • Download URL: sf_backtester-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sf_backtester-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2fd475370e0b1687ea8fb30322ddc3706773300793ebf56cdb15010a7560d486
MD5 2681b71184301eb9588cd4c9bb6e6e2a
BLAKE2b-256 53ebc5af00b80ec56f643be33e61dc44b8f0f82a010fa8fcaee589dd91f81be8

See more details on using hashes here.

File details

Details for the file sf_backtester-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sf_backtester-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sf_backtester-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8859ddeb39ed8aefb6166e3d367995cace412cb16f01589573c136952e60205c
MD5 f08efd36208b21574053ca420c754c27
BLAKE2b-256 29f8d19b52a4da0041dc71e7c90801a38a24211973dfbf81d8e5ca1a6b39e47b

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