FuturesRollingOrdersGenerator

class qf_lib.containers.futures.futures_rolling_orders_generator.FuturesRollingOrdersGenerator(future_tickers: Sequence[FutureTicker], timer: Timer, broker: Broker, 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:

generate_close_orders()

Close contracts for which a new futures contract from the same futures family should be open.

generate_close_orders() List[Order][source]

Close contracts for which a new futures contract from the same futures family should be open.