semvec/pypi-packages huggingface dataset:
Han-BackTest 1.1.2
A naive backtest framework for stock trading in Chinese market
Requires Python: >=3.6

# Han_BackTest

**Han_BackTest** is a lightweight backtesting framework designed for the Chinese stock market. It allows users to quickly develop, test, and analyze quantitative investment strategies.

---

## Features

- **Efficient Data Management**: Load and cache financial data seamlessly with `DataClass`.
- **Flexible Factor Calculation**: Create custom factors with `FactorClass`.
- **Modular Strategy Design**: Build strategies by extending the `StrategyClass`.
- **Comprehensive Backtesting**: Use `BackTestClass` for visualizing performance and comparing strategies.

---

## Installation

Install via pip:

```bash
pip install Han-BackTest
```

## Quick Start

Here’s how to get started with Han_BackTest in just a few steps:

```python
from Han_BackTest.DataClass import DataClass
from Han_BackTest.BackTestClass import BackTestClass

from Strategies.ReversalStrategy import ReversalStrategy  # Import your strategy

# Load data
data_paths = {"daily": "path/to/data.feather"}
data = DataClass(data_paths)
data.generate_cache()

# Define strategy
strategy = ReversalStrategy(name="Reversal", n=5)

# Run backtest
backtest = BackTestClass(
    strategy=strategy,
    data_class=data,
    start_date=20200101,
    end_date=20231231,
)

# Plot results
backtest.plot_nav()
```

## Documentation

For detailed documentation and usage examples, please visit the [online documentation](https://disk.pku.edu.cn/link/AAEE32830117764DC79F93ACD9A6338CFA).

## Data Requirements

If you need sample data for testing, you can download it from [this link](https://disk.pku.edu.cn/link/AAEE32830117764DC79F93ACD9A6338CFA).

## Contributing

Contributions are welcome! Please feel free to submit issues or pull requests :)