Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:51bitquant Ai hedge fund crypto Strategy Plugin Architecture

From Leeroopedia
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 I (the abstract base class). A plugin Pk realizes I. A loader L:name→Pk maps a config string to a class. The pipeline composes:

Pipeline=Fetch→{L(n):n∈config}→Risk→Decide

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

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment