alpheast.strategy.common.bollinger_bands_strategy module

class alpheast.strategy.common.bollinger_bands_strategy.BollingerBandsStrategy(symbol, bb_period=20, num_std_dev=Decimal('2'), **kwargs)[source]

Bases: BaseStrategy

A Bollinger Bands trading strategy.

Generates BUY signals when the close price crosses below the lower band and SELL signals when it crosses above the upper band

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

  • bb_period (int) – The period over which to calculate the Simple Moving Average (SMA) for the middle band. (e.g., 20)

  • num_std_dev (Decimal) – The number of standard deviations for the upper and lower bands. (e.g., 2)

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

on_market_event(event)[source]

Called when a new MarketEvent (e.g. a new bar of data) is received. Strategies should implement their trading logic here.