AFL Code for Rollover


#1

HI everyone, I have been trying to put together afl code for computing rollover on index and stock futures using near, next and far month data. I plan to use it to scan for rollovers above or below 3 month averages, highest/lowest rollovers. If anyone has done this, could you share the same? Many thanks


#2

There is no standard formula for rollover. Because the symbols keep changing every expiry.

Example logic of code:

  1. If current date is date of expiry
  2. If there is Long position in current month future
  3. Using buy-sell conditions and Foreign(), create Sell in current month future, and create Buy in next month future.

#3

There is a generic logic to the symbols in my data feed- for example - Nifty-I, Nifty-II, Nifty-III for the 1st, 2nd and 3rd month futures. Similarly for other symbols. While I could write code for Nifty, I couldnt figure out how to make it generic so that it could be applied to ANY symbol. Grateful if you could suggest, thanks.