Skip to content

stefansimik/suite_trading

Repository files navigation

SUITE Trading

Simple, Understandable, Intuitive Trading Engine

⚠️ Work in Progress: This project is in active development (~60-70% complete). Core event-driven architecture and strategy framework are implemented.

Overview

SUITE Trading is a modern algorithmic trading framework built on event-driven architecture with independent strategy timelines. Designed with simplicity, understandability, and intuitive use in mind, it provides a unified interface for both backtesting strategies with historical data and running live trading operations.

Getting Started

Requirements

  • Python 3.13+
  • Dependencies managed via uv (see pyproject.toml)

Installation

# Clone the repository
git clone <repository-url>
cd suite_trading

# Install dependencies
uv sync

# Verify installation by running tests
uv run pytest

Basic Usage

from suite_trading.platform.engine.trading_engine import TradingEngine
from suite_trading.strategy.strategy import Strategy
from suite_trading.platform.event_feed.demo_bar_event_feed import DemoBarEventFeed
from suite_trading.platform.event_feed.event_feed import EventFeed
from suite_trading.domain.market_data.bar.bar_event import NewBarEvent

# Create a strategy with demo market data
class MyStrategy(Strategy):
    def on_start(self):
        # Add market data
        demo_feed: EventFeed = DemoBarEventFeed(num_bars=20)  # Provides series of bars for testing
        self.add_event_feed("demo_feed", demo_feed, self.on_event)

    def on_event(self, event):
        if isinstance(event, NewBarEvent):
            self.on_bar(event.bar, event)
        else:
            print(f"Received event: {event}")

    def on_bar(self, bar, event: NewBarEvent):
        print(f"Received bar: {bar}")
        # Your trading logic here

    def on_stop(self):
        print("Strategy stopped!")

# Create and configure the trading engine
engine = TradingEngine()
engine.add_strategy("my_strategy", MyStrategy())

# Start the engine (demo data will begin flowing)
engine.start()

Key Features

  • Unified trading scenarios: Single strategy design supports all trading modes:
    • Backtesting: Historical data + simulated broker execution
    • Paper trading: Live data + simulated broker execution
    • Live trading: Live data + live broker execution
  • Flexible architecture: Each strategy can connect to:
    • Multiple market data sources: Receive data from one or more data providers simultaneously
    • Multiple brokers: Submit orders to one or more connected brokers
  • Event-driven architecture: Chronological event processing with automatic ordering and syncing after adding new data sources during runtime
  • Independent strategy timelines: Each strategy maintains its own timeline and processes events independently, allowing simultaneous backtests and live strategies
  • Comprehensive and intuitive domain models: Complete Event, Order, Instrument, and Market Data hierarchies
  • Strategy framework: Lifecycle management with on_start(), on_stop(), on_error(), and universal on_event() methods
  • Broker agnostic: Framework designed to work with multiple brokers
  • Python native: Built specifically for Python with type hints throughout

Architecture

SUITE Trading uses an event-driven architecture.

  • All market data flows through timestamped Event objects into Strategy callbacks (default on_event() method`).
  • Each Strategy runs in isolation from other strategies
  • Each Strategy processes own events in chronological order (sorted by Event.dt_event) and maintains its own timeline
  • Source of events for each strategy is an EventFeed. One strategy can have multiple EventFeeds.

Core Philosophy

  • Event-driven architecture: All market data flows through timestamped events
  • Independent strategy timelines: Each strategy operates with its own chronological timeline
  • Domain-driven design: Clear separation between business logic and technical infrastructure
  • User-centric API: Designed for developer convenience

Core Components

  • TradingEngine: Central coordinator managing strategies, event feeds, and brokers
  • Strategy: Base class with independent timeline and universal on_event() method
  • EventFeed: Serves as generic convenience factories for EventFeeds.
  • EventFeedProvider: Provides chronologically ordered event streams for backtesting and live data.
  • Event: Base class for all data (Bar, TradeTick, QuoteTick) with chronological sorting
  • MessageBus: Topic-based routing system with wildcard pattern support (bar::EURUSD@FOREX::5-MINUTE::LAST)
  • Domain models: Complete financial object hierarchy (Instruments, Orders, Money, etc.)

Data Flow

SUITE Trading provides three main data flow paths for different use cases:

  1. EventFeed
  2. Broker integration
  3. MessageBus

1. EventFeed - Universal event source for strategies

EventFeed produces Events → which are delivered to Strategy.on_event()

2. Broker integration - Order execution

Strategy → generates Orders → Broker (Live / Simulated) → publish ExecutionEvent
  • Real-time order placement and execution with multiple brokers
  • Order state management and fill event processing
  • Position and portfolio tracking

3. MessageBus - Publish / subscribe event delivery

Publishers → MessageBus Topics → Subscribers → Event Handlers
  • Topic-based routing with wildcard patterns (bar::EURUSD@FOREX::5-MINUTE::LAST)
  • Especially suitable for live events and live trading coordination
  • Decoupled communication between system components

Timeline independence

Each strategy maintains its own independent timeline, which allows running simultaneously without interference:

  • Multiple backtests (with historical data in different periods)
  • Live strategies
  • Mixed backtesting and live trading

Events are processed sequentially within each strategy's timeline:

  • Events: All market data inherits from Event with dt_event and dt_received timestamps
  • Strategies: Independent entities with their own timeline processing events sequentially
  • EventFeeds: Data sources that provide chronologically ordered events to strategies
  • Timeline isolation: Each strategy processes its own timeline independently from others

Development & Testing

Running tests

The project includes comprehensive test configuration with built-in logging support. Test logging is configured in [tool.pytest.ini_options] section of pyproject.toml.

# Run all tests with default INFO-level logging
uv run pytest

# Run tests with DEBUG-level logging for detailed output
uv run pytest --log-cli-level=DEBUG

# Run specific test file
uv run pytest tests/integration/suite_trading/test_playground.py

# Run specific test with DEBUG logging
uv run pytest tests/integration/suite_trading/test_playground.py --log-cli-level=DEBUG

Available log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL

Project Status

This project is in active development with approximately 60-70% of core functionality implemented.

Development status & roadmap

Completed:

  • ✅ Complete event-driven architecture with chronological processing
  • ✅ Comprehensive domain models (Event, Bar, Order hierarchy, Instrument, Monetary)
  • ✅ TradingEngine with multi-strategy management and independent timelines
  • ✅ Strategy framework with lifecycle management (on_start, on_stop, on_error)
  • ✅ Message Bus with topic-based routing and wildcard patterns
  • ✅ EventFeed system with timeline filtering and management
  • ✅ State machines for engine and strategy lifecycle control
  • ✅ Market data events (Bar, TradeTick, QuoteTick) with proper event wrappers

Next Priority (Roadmap):

  1. EventFeedProvider(s) ❌ - Real-time market data integration
  2. Broker(s) ❌ - Live order execution with multiple brokers + SimulatedBroker (with simulated execution, positions and portfolio)
  3. Advanced order types ❌ - Stop-loss, take-profit, bracket orders
  4. Performance analytics ❌ - Strategy performance metrics and reporting

License

See LICENSE file for details.

Disclaimer

This software is for educational and research purposes. Use at your own risk in live trading environments.

About

Trading framework designed with simplicity, understandability, and intuitive use in mind

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages