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
...

To Publish the project (Developer)

PYPI_API_TOKEN="your-token-here"
maturin publish --username __token__ --password $PYPI_API_TOKEN

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.2.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded CPython 3.12macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hawk_backtester-0.3.2.tar.gz
Algorithm Hash digest
SHA256 02da4ee9663fce2674c7312fd29f8683d07324635b4a29322a3c15e623335074
MD5 69646690d446dc445a1a55572850fffb
BLAKE2b-256 e999566b2257e028d179533748c4d5eaf81814910121064cf7cea193a3b12476

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hawk_backtester-0.3.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fb149d056e61956cf6cc5f9415711678929a1dbf439d8f2a815dd50eced4007c
MD5 b978cf5476f47a80f5cd1ce1dd696e76
BLAKE2b-256 430a556d81486279da101dc755288e85098fd16857ed00421e7ab473d0e3ca17

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