How it works
PyEventBT is built around an event-driven architecture. It simulates real-world trading conditions by processing market events sequentially, just as they would occur in live trading. This eliminates look-ahead bias by design and ensures your backtest results accurately reflect live performance.
How It Works
Section titled “How It Works”PyEventBT is built around an event-driven architecture that processes market data sequentially:
- Market Data arrives as
BarEventobjects (OHLCV bars) - Your Strategy processes the data and generates
SignalEventobjects - Position Sizing calculates how much to trade
- Risk Engine validates the trade against your risk rules
- Execution Engine places the order (simulated or real)
- Portfolio tracks positions, P&L, and account state
This flow ensures that your strategy only sees data that would have been available at that moment, just like in real trading.
Core Components
Section titled “Core Components”Strategy
Section titled “Strategy”The main entry point where you define your trading logic using simple decorators.
Data Provider
Section titled “Data Provider”Access historical data for backtesting or live data from MT5. Supports multiple timeframes and symbols.
Signal Engine
Section titled “Signal Engine”Your strategy logic runs here, generating trading signals based on market conditions.
Sizing Engine
Section titled “Sizing Engine”Calculates position sizes based on your account equity and risk parameters.
Risk Engine
Section titled “Risk Engine”Validates trades against your risk management rules before execution.
Execution Engine
Section titled “Execution Engine”Handles order execution, working with simulated brokers in backtests and real MT5 in live trading.
Portfolio
Section titled “Portfolio”Tracks your account state, positions, orders, and P&L throughout the trading session.