How coding-kitties/investing-algorithm-framework works
Main components
• Application/Entry Point: Include elements like the “create_app” script and the overall application orchestrator found in investing_algorithm_framework/app. This component handles initialization, configuration, and running of algorithms.
• Domain Layer: Represent the core business logic. This includes the models (orders, portfolios, trades, positions, strategies, etc.) and domain services that define trading, backtesting, performance metrics, and configuration (see directories such as investing_algorithm_framework/domain/models and domain/services).
• Data Sources and Market Integration: Show the market data source integrations (OHLCV and ticker data providers via ccxt, CSV, Pandas/Polars integration), abstracted by market service components. These are crucial for obtaining real-time and historical market data.
• Infrastructure Layer: Add components for persistence and external integration. This includes:
• Database persistence (via sqlite and SQLAlchemy in infrastructure/database).
• Repositories for orders, portfolios, positions, and trades in infrastructure/repositories.
• External integrations (exchange interfaces via ccxt, upcoming support for Azure Functions, AWS Lambda, etc.).
• API & Web Layer: Show the web API and controllers (located under app/web/controllers) that expose RESTful endpoints for managing the bot, submitting orders, retrieving portfolio snapshots, and evaluating backtests.
• Command Line Interface (CLI): Represent how the CLI utilities (in investing_algorithm_framework/cli) are used for tasks like initialization, deployment, and backtesting.
• Testing/Examples: Although not part of production, include a note about how examples and tests are organized. These help illustrate usage scenarios and serve as integration tests to validate the architecture.
Relationships and interactions
• The Application Layer (created through create_app and orchestrated by app.py) initializes the system and wires up the domain, services, and infrastructure.
• The Domain components (models and service logic) encapsulate the business rules and data structures and interact with persistence repositories for saving orders, positions, etc.
• The Infrastructure layer acts as a bridge by implementing concrete repository classes and adapters that connect domain objects to external systems (like databases or market data sources).
• The API and CLI layers expose entry points which ultimately invoke domain logic and service operations.
• Market Data Sources provide data to strategies in a periodic or event-driven manner – the strategies (decorated and registered within the algorithm component) leverage data from both live feeds and backtest datasets.
• External integrations appear as dependencies such as ccxt for exchange connectivity, and planned integrations (Azure Functions, AWS Lambda) for different deployment modes.
Architectural patterns and design principles
• Layered Architecture: Separate components into presentation (web API/CLI), application, domain (business model, strategy definitions), and infrastructure (repositories, external services) layers.
• Separation of Concerns: Distinct directories (app, domain, infrastructure, services, cli) emphasize clear boundaries so that trading logic does not mix with persistence or external integrations.
• Extensibility: The framework’s design (with pluggable data providers, market credentials, and strategy registration via decorators) supports adding or replacing components without changing core logic.
• Testability: A rich set of unit and integration tests (in the tests directory) demonstrates the importance of ensuring that each component is independently verifiable.
Technologies, frameworks, and libraries
• Python 3.9+ as the core language.
• ccxt for exchange connectivity.
• SQLite (using SQLAlchemy for ORM) for persistence.
• Polars and Pandas for data processing.
• CLI and possibly Flask/FastAPI (or similar) for the web API (judging by the “controllers” in app/web).
• Environment configuration handled via dotenv.
• Areas that are planned or under development (for instance, built-in WebUI, Telegram integration, AWS Lambda support).