FuturesRollingOrdersGenerator¶
-
class
qf_lib.containers.futures.futures_rolling_orders_generator.
FuturesRollingOrdersGenerator
(future_tickers: Sequence[qf_lib.containers.futures.future_tickers.future_ticker.FutureTicker], timer: qf_lib.common.utils.dateutils.timer.Timer, broker: qf_lib.backtesting.broker.broker.Broker, order_factory: qf_lib.backtesting.order.order_factory.OrderFactory)[source]¶ Bases:
object
Class responsible for generating close orders for expired future contracts. The close order is generated after the expiration date is reached (which is the original future ticker expiration date - days before exp date). If there still exists a position open for a contract even though the original future ticker expiration date is reached, an additional warning is generated.
- Parameters
future_tickers (Sequence[FutureTicker]) – Future tickers for which the contract rolling should be performed
timer (Timer) – Timer used to verify, whether the final expiration dates of any contract have not been reached
broker (Broker) – Broker used to get the list of currently open positions in the portfolio
order_factory (OrderFactory) – Order Factory used to create orders to close the expired contracts
Methods
Close contracts for which a new futures contract from the same futures family should be open.
-
generate_close_orders
() → List[qf_lib.backtesting.order.order.Order][source]¶ Close contracts for which a new futures contract from the same futures family should be open.