-
-
Notifications
You must be signed in to change notification settings - Fork 1
Strategy
Welcome to the pyBacktest wiki!
The Strategy
class is an abstract base class for implementing trading strategies in the backtesting framework. It provides a structure for defining the setup and step logic for a strategy, as well as utility methods for managing positions and applying risk management.
Initializes the strategy with default values.
Initializes the strategy with the backtest instance and sets up the historical data.
A method to be overridden by subclasses to set up the strategy-specific parameters.
Deprecated method for processing the next row of data. Use step()
instead.
Abstract method to be implemented by subclasses to define the strategy logic for each step.
Returns the current position (number of shares) held by the strategy.
Returns the current market state, including cash, position, and total value.
Applies risk management by setting stop loss and take profit levels.
Rebalances the portfolio according to the target allocations.