Files
2026-02-21 07:43:33 +01:00

1.2 KiB

strategy

aiomql.lib.strategy — Strategy base class.

Overview

The Strategy class is the abstract base for all trading strategies. Subclasses implement trade() to define entry/exit logic. The strategy lifecycle is managed by the Bot / Executor.

Inherits from _Base.

Classes

Strategy

Abstract base class for trading strategies.

Attribute Type Description
name str Strategy name (defaults to class name)
symbol Symbol The trading instrument
sessions Sessions | None Optional session restrictions
params dict Strategy parameters

Lifecycle

Method Description
__init__(symbol, params, sessions, …) Initialises the strategy with a symbol and parameters
init() Async setup hook (called once before trading begins)
run() Main loop — calls trade() repeatedly
sleep(secs) Suspends the strategy for a duration

Trading Logic

Method Description
trade() Abstract — implement entry/exit logic here