Skip to content

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.

PyEventBT is built around an event-driven architecture that processes market data sequentially:

  1. Market Data arrives as BarEvent objects (OHLCV bars)
  2. Your Strategy processes the data and generates SignalEvent objects
  3. Position Sizing calculates how much to trade
  4. Risk Engine validates the trade against your risk rules
  5. Execution Engine places the order (simulated or real)
  6. 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.

The main entry point where you define your trading logic using simple decorators.

Access historical data for backtesting or live data from MT5. Supports multiple timeframes and symbols.

Your strategy logic runs here, generating trading signals based on market conditions.

Calculates position sizes based on your account equity and risk parameters.

Validates trades against your risk management rules before execution.

Handles order execution, working with simulated brokers in backtests and real MT5 in live trading.

Tracks your account state, positions, orders, and P&L throughout the trading session.