Principle:51bitquant Ai hedge fund crypto Strategy Plugin Architecture
| Knowledge Sources | |
|---|---|
| Domains | Extensibility, Graph_Architecture |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
An extensibility pattern that lets users add new trading strategies by implementing a single interface and registering via configuration, without modifying the pipeline code.
Description
The strategy plugin architecture decouples strategy authorship from pipeline wiring. An abstract base class (`BaseNode`) defines the contract — `__call__(state) -> partial_state`. A dynamic loader (`import_strategy_class`) resolves a strategy by its dotted module path at runtime. The DAG builder (`Workflow.create_workflow`) reads strategy names from config and wires each as a node between the merge node and the risk node. Adding a strategy is therefore: (1) write a subclass, (2) add it to the package `__init__`, (3) list its name in `config.yaml`. No pipeline code changes.
This solves the closed/open principle problem: the pipeline is closed for modification but open for extension.
Usage
Use this pattern when you want users to drop in custom signal generators. Provide a concrete example strategy (`MyStrategy`) as a template, and fail fast (import error at graph construction) when a config names a non-existent strategy.
Theoretical Basis
The contract is the interface (the abstract base class). A plugin realizes . A loader maps a config string to a class. The pipeline composes:
Pseudo-code:
# Abstract pattern
class BaseNode:
def __call__(state): raise NotImplementedError
def load(name): return importlib.import_module(path(name)).getattr(name)
for name in config.strategies:
graph.add_node(name, load(name)())
Practical Guide
- Document the exact state keys a strategy may read (`tickers`, `intervals`, per-ticker DataFrames) and the keys it must write (`analyst_signals[<agent_name>]`).
- Provide a working template (`MyStrategy`) users can copy.
- Fail fast on a bad strategy name at graph compile time, not at bar N.
- Note which downstream consumers read specific agent-name keys (e.g. `PortfolioManagementNode` reads `technical_analyst_agent`) so custom strategies know to align or extend the consumer.
Related Pages
Implemented By
- Implementation:51bitquant_Ai_hedge_fund_crypto_BaseNode_call
- Implementation:51bitquant_Ai_hedge_fund_crypto_import_strategy_class
- Implementation:51bitquant_Ai_hedge_fund_crypto_Workflow_create_workflow
- Implementation:51bitquant_Ai_hedge_fund_crypto_MacdStrategy_call
- Implementation:51bitquant_Ai_hedge_fund_crypto_MyStrategy_call