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
timestampcolumn 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
timestampcolumn 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hawk_backtester-0.3.1.tar.gz.
File metadata
- Download URL: hawk_backtester-0.3.1.tar.gz
- Upload date:
- Size: 472.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66e07ba4bbf8564014fd48f0315a41eca83b3963f23770c41e3ad0191cdc0cec
|
|
| MD5 |
2c999b3868025ae9c863542add9b5d41
|
|
| BLAKE2b-256 |
847972b06d73908765c1a27a1c0e7e7522a6a5ccded01dbba7ddb1054df027e5
|
File details
Details for the file hawk_backtester-0.3.1-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: hawk_backtester-0.3.1-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1a26971db4929b15beebf8d2564bd3d1329c0d54a4e82e2cdf875dfdec83258
|
|
| MD5 |
f5412ee29cda96de50475941df65ddaa
|
|
| BLAKE2b-256 |
d58261c600716d2d96dedb3e8ea60bed2594a08fa66b8662b9090b87cf0016d4
|