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.

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.0.tar.gz (7.5 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.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sf_backtester-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.17

File hashes

Hashes for sf_backtester-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9789a8d091b22747a538815bbaaf0d5015705af04dd606a7e5f196f6ec722667
MD5 f78b444881ef61178265c10e49194286
BLAKE2b-256 13f86c6f4169436786220e1146c4b8f947aa5dab7ae241e91c06aeec0d005fce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sf_backtester-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f012eb85474efcac876eaa7727400990e237560632f3711fc4b77ed57ea48bb9
MD5 34ca79b0845b56b6b3972a6b4d6e5202
BLAKE2b-256 ec8864c965b9fa0475012a8825fa3f134af2baad17cddda27f69ed14e0f81116

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