Skip to main content

An event-driven backtesting engine for trading strategies.

Project description

AlphEast Backtesting Engine

Python Version License

🌟 Overview

AlphEast is an event-driven backtesting engine designed for developing and evaluating quantitative trading strategies. While still in its early stages of development, it provides a robust, extensible framework for simulating and evaluating multi-symbol trading strategies with realistic considerations like transaction costs and slippage.

Our goal is to offer a flexible tool for researchers and traders to quickly prototype and test their ideas, without getting bogged down in boilerplate.


✨ Key Features

  • Event-Driven Architecture: Simulates market conditions and trade executions with a clear, sequential event flow.
  • Multi-Symbol Backtesting: Simultaneously test strategies across multiple financial instruments.
  • Pluggable Strategies: Easily define and integrate your own custom trading strategies.
  • Customizable Position Sizing: Implement various position sizing methods to manage risk and allocate capital.
  • Realistic Simulations: Accounts for transaction costs (commissions) and slippage to provide more accurate results.
  • Performance Metrics & Visualization: Generates standard trading performance metrics and plots equity curves for quick analysis.
  • Flexible Data Ingestion: Designed to integrate with various data sources, from direct in-memory data to custom database repositories.

🚀 Quick Start

Get your first backtest running in minutes!

Installation

pip install alpheast

Basic Usage Example

from datetime import datetime
from typing import Dict, List
from alpheast.config.data_source import DataSource, DataSourceType
from alpheast.engine import BacktestingEngine
from alpheast.config.backtest_config import BacktestingOptions
from alpheast.models.interval import Interval
from alpheast.models.price_bar import PriceBar
from examples.basic.example_strategy import ExampleStrategy


if __name__ == "__main__":
    symbol = "AAPL"
    options = BacktestingOptions(
        symbols=[symbol],
        start_date=datetime(2021, 1, 1),
        end_date=datetime(2025, 1, 1),
        interval=Interval.DAILY,
        initial_cash=100_000.0
    )

    price_bar_data: Dict[str, List[PriceBar]] = {
        symbol: [] # Provide your data
    }
    data_source = DataSource(
        type=DataSourceType.DIRECT,
        price_bar_data=price_bar_data,
    )

    engine = BacktestingEngine(
        options=options,
        data_source=data_source,
        strategies=[ExampleStrategy(symbol)],
    )
    
    results = engine.run()

    if results:
        results.print_summary()
        results.plot_equity_curve()

equity-curve

⚡️ Performance

AlphEast is designed for efficiency and demonstrates strong scaling characteristics with both the number of symbols and the backtesting duration. Below are some example execution times measured on a standard setup:

Execution Time (seconds)

Symbols \ Duration 1 Year 5 Years
1 0.2124 0.9258
2 0.3027 1.2424
10 0.9525 3.6243

Status

In mid stages of development.

Contributing

All contributions are warmly welcomed. Head over to CONTRIBUTING.md 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

alpheast-0.1.0.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

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

alpheast-0.1.0-py3-none-any.whl (55.7 kB view details)

Uploaded Python 3

File details

Details for the file alpheast-0.1.0.tar.gz.

File metadata

  • Download URL: alpheast-0.1.0.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for alpheast-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4307a3f99a61b974a767c43eac31be0b6ef336251083cf20b3b0dc76bd76ad9
MD5 bb5a1fc3ff9ec672c69bee1f89da6e7e
BLAKE2b-256 c66e1504c00ee55888d5b3c2e04f00132bb3ad98d7d5071ec27a6b4b4de2cbb1

See more details on using hashes here.

File details

Details for the file alpheast-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alpheast-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 55.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for alpheast-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51793d78c3d79c0c14903a521913d586f462310fba852d204739a1f273da0cac
MD5 c22aa5d4132759ac595457edfbdc92ba
BLAKE2b-256 774403fb0fea00dddbe90139014a9812725c6ad4070def8604328213867521b0

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