Skip to main content

BacktesterLib

A lightweight vectorized backtesting library for testing trading strategies.

Installation

pip install backtesterlib

Usage

import pandas as pd
from backtesterlib import Backtester, BuyAndHold

MINUTES_PER_DAY = 60 * 24
MINUTES_PER_MONTH = MINUTES_PER_DAY * 30
MINUTES_PER_YEAR = MINUTES_PER_DAY * 365

# Load csv containing a column of close prices. This one has minute intervals
df = pd.read_csv("data/SOLUSDT-1.csv", sep="|", index_col=0) 

# Select the last month of data for example purposes
df = df.iloc[-MINUTES_PER_MONTH:].reset_index() 
    
# Create Backtester object
backtester = Backtester(
    df=df, close_column="close", # Name of close price column in your data
    bars_per_year=MINUTES_PER_YEAR, 
    windows_per_year=12, # 12 months per year
    fee_rate=0.00001, fee_in_usd=False # False since we specify fees in SOL
)

# Example buy and hold strategy holding 2 SOL
backtester.run(BuyAndHold(amount=2.0), n_mote_carlo_paths=1000)

# Baseline strategy
backtester.run(BuyAndHold(amount=1.0), n_mote_carlo_paths=0, baseline=True)

# Display strategy performance
backtester.plot_results(figsize=(12, 8), plot_correlations=False)
backtester.log_results()

Metadata

Release files for backtesterlib 0.1.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 backtesterlib 0.1.0
File Size Uploaded Provenance
backtesterlib-0.1.0.tar.gz 5.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 11.3 kB

Release files / backtesterlib-0.1.0.tar.gz

Download URL backtesterlib-0.1.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fc3807900c4722a228ed908c08638a33355ccd1ae4e1d5159990db958e89c164
BLAKE2b-256 checksum
How to use checksums
6ef1f262ac7481ea1b4531be2c46dcca9dce283a8a7d5bbd862add2b32fa1e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / backtesterlib-0.1.0-py3-none-any.whl

Download URL backtesterlib-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a3046e3068dc72473462ba89678be23a736e5bb4977ce49f01d0518ee7b4825
BLAKE2b-256 checksum
How to use checksums
4a3dceef754902dc3a9f09a8fb33e3ba90a983eadcab92a0868dc7a2147a4ef9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for backtesterlib 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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