AlphaModelStrategy
- class qf_lib.backtesting.strategies.alpha_model_strategy.AlphaModelStrategy(ts: TradingSession, model_tickers_dict: Dict[AlphaModel, Sequence[Ticker]], use_stop_losses=True, max_open_positions: Optional[int] = None, time_in_force: Optional[TimeInForce] = TimeInForce.OPG)[source]
Bases:
AbstractStrategy
Puts together models and all settings around it and generates orders on before market open.
- Parameters:
ts (TradingSession) – Trading session
model_tickers_dict (Dict[AlphaModel, Sequence[Ticker]]) – Dict mapping models to list of tickers that the model trades. (The tickers for which the model gives recommendations)
use_stop_losses (bool) – flag indicating if the stop losses should be used or not. If False, all stop orders are ignored. By default, the value is set to True.
max_open_positions (Optional[int]) – maximal number of positions that may be open at the same time in the portfolio. If the value is set to None, the number of maximal open positions is not limited. By default this value is set to None.
time_in_force (Optional[TimeInForce]) – time in force for the orders that will be generated by the AlphaModelStrategy (length of time over which the generated orders will continue working before they are canceled). By default, the OPG time in force is used.
Methods:
The base function of every strategy.