Skip to main content

A naive backtest framework for stock trading in Chinese market

Project description

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:

pip install Han-BackTest

Quick Start

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

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.

Data Requirements

If you need sample data for testing, you can download it from this link.

Contributing

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

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

Han_BackTest-1.1.2.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

Han_BackTest-1.1.2-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file Han_BackTest-1.1.2.tar.gz.

File metadata

  • Download URL: Han_BackTest-1.1.2.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.5

File hashes

Hashes for Han_BackTest-1.1.2.tar.gz
Algorithm Hash digest
SHA256 584a82dfb747dfbe4e9410f7aa6e8552574b9402d592a878e52f100a3ec7375d
MD5 e04802e0609406dd3248c28deb3512a2
BLAKE2b-256 00527db9e78edc1c6f78b2dcaec205f354199aac214c80cf07ead966fff31a1e

See more details on using hashes here.

File details

Details for the file Han_BackTest-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: Han_BackTest-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.5

File hashes

Hashes for Han_BackTest-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb4cb0a1ed9e72035f894c680fcfe9635fd82f19d402beb33693d1992fcba703
MD5 6d2bdbe8d9be3dda1a27a1c8ed6fc297
BLAKE2b-256 ad890e7f970df12c115bddd40a49040951df06bd0a3ba22d188ce23fc0f67136

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