Metadata-Version: 2.4
Name: backtesterlib
Version: 0.1.0
Summary: A vectorized backtesting library for trading strategies
Author: Juan Santhosh
License: MIT
Project-URL: Homepage, https://github.com/juan-santhosh/BacktesterLib
Project-URL: Repository, https://github.com/juan-santhosh/BacktesterLib
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: setuptools
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: matplotlib
Requires-Dist: seaborn

# BacktesterLib

A lightweight vectorized backtesting library for testing trading strategies.

## Installation

```bash
pip install backtesterlib
```

## Usage

```python
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()
```
