AlphaModelStrategy(ts: qf_lib.backtesting.trading_session.trading_session.TradingSession, model_tickers_dict: Dict[qf_lib.backtesting.alpha_model.alpha_model.AlphaModel, Sequence[qf_lib.common.tickers.tickers.Ticker]], use_stop_losses=True, max_open_positions: Optional[int] = None, time_in_force: Optional[qf_lib.backtesting.order.time_in_force.TimeInForce] = <TimeInForce.OPG: 3>)[source]¶
Puts together models and all settings around it and generates orders on before market open.
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.
The base function of every strategy.