alpheast.strategy.common.macd_strategy module

class alpheast.strategy.common.macd_strategy.MACDStrategy(symbol, fast_period=12, slow_period=26, signal_period=9, **kwargs)[source]

Bases: BaseStrategy

A Moving Average Convergence Divergence (MACD) trading strategy.

Generates BUY signals when the MACD line crosses above its Signal line. Generates SELL signals when the MACD line crosses below its Signal line.

Parameters:
  • symbol (str) – The financial instrument symbol this strategy will trade.

  • fast_period (int) – The period for the fast Exponential Moving Average (EMA) (e.g., 12).

  • slow_period (int) – The period for the slow Exponential Moving Average (EMA) (e.g., 26).

  • signal_period (int) – The period for the EMA of the MACD line (Signal Line) (e.g., 9).

  • kwargs (Any) – Arbitrary keyword arguments passed to the base strategy.

on_market_event(event)[source]

Handles incoming market events to update MACD indicator and generate trading signals.

Parameters:

event (MarketEvent) – The MarketEvent containing new market data.