Replies: 1 comment 2 replies
-
A long time has passed since this discussion started, but the idea has stuck with me ever since. So let me draft a few thoughts: Obtaining high-resolution market data for a large number of instruments is a known bottleneck, which highlights the need for a local cache—especially for storing historical data. This will significantly improve performance and reduce dependency on IB's rate-limited historic data API. Additionally, while IB provides portfolio accounting for paper and live trading, backtesting portfolio accounting needs to be simulated. 1. Store ModulePurpose: Manages entities, handles local cache, and synchronizes data between IB, a local master database, and a session-level cache. Key Components:
2. Session ModulePurpose: Facilitates running or testing strategies in both live and simulated environments. Key Components:
3. UI ModulePurpose: Provides analytics and monitoring capabilities for live and simulated trading sessions. Key Features:
|
Beta Was this translation helpful? Give feedback.
-
Architecture Design: Backtesting Engine with Historical Data Integration
I wanted to start conversation and create initial idea how we can implement backtesting engine on top of historical data from IB.
This is initial draft. Comment, extend, edit, change, update, add or remove. Literally anything. Think of it as a design document. As it is always the best to scope out before implementing. :)
Cheers!
Overview
This document provides a detailed design for a Backtesting Engine capable of simulating market movements based on historical data fetched via IBKit. The engine will allow users to specify the start and end dates for the simulation, adjust playback speed, and configure market data granularity, such as bar intervals or tick data.
The below setup ensures that the DataManager, MarketSimulator, handle data asynchronously, reacting to the data availability in real-time or as fast as the simulation parameters allow. This integration pattern is crucial for ensuring the backtesting engine can handle the data dynamics similar to live trading scenarios, making for a more robust and realistic testing environment.
Key Features
Components
DataManager
Responsible for fetching and storing historical market data from IBKit.
Responsibilities: Fetches historical data based on the BacktestConfig.
Methods:
fetchHistoricalData(config):
Retrieves data from IBKit based on specified dates and resolution.BacktestConfig
Stores user-defined settings such as start/end dates, playback speed, and data resolution.
Attributes:
startDate
: When the backtest should start.endDate
: Optional end date; defaults to the current date if not specified.playbackSpeed
: Multiplier for the speed at which the backtest runs (1x, 2x, etc.).resolution
: Granularity of the data (e.g., tick, 1-minute bars, daily bars).MarketSimulator
Simulates the market by replaying historical data at a user-defined speed and interval.
Methods:
simulateMarket(data)
: Simulates market conditions by replaying data at the speed and resolution defined in BacktestConfig.BacktestConfig.swift
DataManager.swift
MarketSimulator.swift
Moreover, we can provide component that will help facilitate user their own strategies. But not necessary as every consumer of SDK should be able to do it on their own. Maybe just an example in playground
StrategyExecutor.swift
Beta Was this translation helpful? Give feedback.
All reactions