AbstractStrategy

class qf_lib.backtesting.strategies.abstract_strategy.AbstractStrategy(ts: TradingSession)[source]

Bases: object

Basic interface used to create a generic strategy.

Methods:

calculate_and_place_orders()

The base function of every strategy.

subscribe(event)

Subscribes the strategy to a given Time event.

abstract calculate_and_place_orders()[source]

The base function of every strategy. Its purpose is the computation of desired signals, creation of corresponding orders and afterwards sending them to the broker.

subscribe(event: Type[TimeEventType])[source]

Subscribes the strategy to a given Time event. Most commonly this will be CalculateAndPlaceOrdersPeriodicEvent or CalculateAndPlaceOrdersRegularEvent that calls calculate_and_place_orders method