How olehlohvyn/vbt-backtesting-engine works
Major Components
• Data Loader: Under core/data_loader, this module is composed of a generic “base_loader” as well as a Binance-specific loader (binance_loader) to fetch trading data.
• Data Processor: Located in core/data_processor, responsible for processing, validating, and building datasets from the loaded data.
• Backtester: Found in core/backtester, this component takes processed data, applies trading strategies, and evaluates their performance.
• Pairs Fetcher: Within core/pairs_fetcher, designed to obtain the 100 most liquid BTC trading pairs.
• Trading Strategies: In the strategies directory, containing the base strategy interface and specific implementations (e.g., sma_crossover), to be executed by the backtester.
• Configuration & Settings: Provided by files such as settings.py and the README description, which sets up the parameters for data range (e.g., February 2025) and exchange selections.
• Results: The results directory where outputs are stored, indicating the persistence or visualization layer.
• Utility Modules: The utils directory (with submodules for exceptions and logging) supports error management and log configuration across the system.
• Entry Point: The main.py script acts as the system’s primary execution flow which ties all the components together.
Relationships and Data Flow
• Data loading flows from the Data Loader to the Data Processor, which then validates and organizes the data.
• The Data Processor feeds the processed data into the Backtester that runs selected trading strategies.
• The Strategies module supplies the trading rules (like SMA crossover) that are applied on the processed data.
• Once backtesting is complete, results are stored/output in the Results module.
• The utility modules (logging and exceptions) are cross-cutting concerns used by all other components to ensure clean error handling and proper logging.
Architectural Patterns & Design Principles
• Modular Design: The separation into core modules (data_loader, data_processor, backtester, pairs_fetcher) highlights a clean separation of concerns.
• Extensibility through Strategies: The strategies folder indicates that new strategies can be added without major changes to the overall system, following the Open/Closed Principle.
• Layered Data Flow: Data moves through layers – from loading to processing to analysis – which can be visualized clearly.