When your algo is dealing with Futures, you need to specify the correct futures contract name as the symbol ticker to trade. This introduces challenges in backtesting, as the algo has to have the logic of changing the futures contract name per each month of backtesting.
Algorum allows you to specify the futures contract in a more generic way, based on the fact that at any point of time there are only three futures contracts trading on NSE. Current Month, Mid Month and Far Month. And since the futures are based on a underlying asset or index, Algorum allows you to specify a futures contract using the underlying asset/index ticker symbol, along with the number of the month of the contract that your strategy want to deal with. For instance below code snippet shows how to subscribe for NIFTY futures for various monthly contracts.
The value of 0 for FNOMonth property of Symbol object indicates current month contract, value of 1 indicates mid month contract and value of 2 indicates far month contract. For instance in the above code snippet, if the current month is Jan 2022, the current month symbol indicates NIFTY futures for Jan 2022, mid month symbol indicates NIFTY futures for Feb 2022 and far month symbol indicates NIFTY futures for Mar 2022.
Auto handling of monthly expiry dates during Backtesting
The monthly futures contracts expire every Thursday of the month, and if Thursday is a holiday, a day before that (and goes back in time based on holidays). For instance, Jan 2022 NIFTY futures expire on Jan 27, 2022 (Thursday). So on Jan 28, the current month futures will become Feb 2022 futures. Algorum backtesting, paper trading and live trading engines takes care of this changes and will stream the correct tick data from correct futures contract to your strategy when the expiry happens every month.