Skip to main content

No project description provided

Project description

Hawk Backtester

A high-performance portfolio backtesting system implemented in Rust with Python bindings.

Features

  • Fast backtesting engine written in Rust
  • Python bindings using PyO3
  • Compatible with Polars DataFrames
  • Support for date-based rebalancing events

Installation

From PyPI (not yet available)

pip install hawk_backtester

From source

# Clone the repository
git clone https://github.com/Hawk-Center/hawk-backtester.git
cd hawk-backtester

# Install maturin if you don't have it
pip install maturin

# Build and install the package
maturin develop

Usage

Here's a simple example of how to use the backtester:

import polars as pl
from hawk_backtester import PyBacktester

# Load your price data with a timestamp column (MM/DD/YYYY format)
# and columns for each asset's price
prices_df = pl.read_csv("data/prices.csv")

# Load your weight data with a timestamp column (MM/DD/YYYY format)
# and columns for each asset's weight
weights_df = pl.read_csv("data/weights.csv")

# Create a backtester with an initial portfolio value
backtester = PyBacktester(initial_value=10_000.0)

# Run the backtest
results = backtester.run(prices_df, weights_df)

# Display results
print(results)

Input Data Format

Price Data

The price DataFrame should have the following structure:

  • A timestamp column with dates in MM/DD/YYYY format (e.g., "01/15/2023")
  • One column per asset with the price at that timestamp

Example:

timestamp,AAPL,MSFT,GOOG,AMZN
01/01/2023,150.00,250.00,2000.00,100.00
01/02/2023,152.50,255.00,2020.00,102.00
...

Weight Data

The weight DataFrame should have the following structure:

  • A timestamp column with dates in MM/DD/YYYY format (e.g., "01/15/2023")
  • One column per asset with the target weight at that timestamp (0.0 to 1.0)

Example:

date ,AAPL,MSFT,GOOG,AMZN
2023/01/04,0.30,0.30,0.20,0.10
2023/01/05,0.25,0.35,0.20,0.15
...

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

hawk_backtester-0.3.0.tar.gz (384.5 kB view details)

Uploaded Source

Built Distributions

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

hawk_backtester-0.3.0-cp312-cp312-macosx_14_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

hawk_backtester-0.3.0-cp310-cp310-macosx_14_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file hawk_backtester-0.3.0.tar.gz.

File metadata

  • Download URL: hawk_backtester-0.3.0.tar.gz
  • Upload date:
  • Size: 384.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for hawk_backtester-0.3.0.tar.gz
Algorithm Hash digest
SHA256 aadd423e6cd82bc463fdb64ee314a0b5a8517674a01fcd2ca8d3c4a10a4a64e7
MD5 af71dde2c4ccf398c678252e831be366
BLAKE2b-256 e24ea797457fa58fa13bb80d56c03d7bf6e110860bcc5bbcc36704da91a19d07

See more details on using hashes here.

File details

Details for the file hawk_backtester-0.3.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hawk_backtester-0.3.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5b1ed820bbf6971ddc3b1527f63d1a8cfa7ba7007288f6f524def376170385b4
MD5 5746083ea6c4b68cf5bc923788b81158
BLAKE2b-256 849875f8e4fd9cba09c34525fbe8d6a50c0c67dc1b589a6d6612659f2cc1b03a

See more details on using hashes here.

File details

Details for the file hawk_backtester-0.3.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for hawk_backtester-0.3.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 89faff6f2d45f5d37915c3b5480c06b9530eee438f56339284efd23d1836552e
MD5 14aa828d678e6fd8bd0e1cc704915736
BLAKE2b-256 128a5128c69bc0f122e0e1b8f530e9b329fa3189d1d7354e3f7da2f8ccf5d01c

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