A simple function in R that accomplishes the following:
1. Reads a CSV file of option data (example file provided); data includes individual option contract information
2. Identifies the 3 closest expirations that have greater than or equal to 4 days remaining.
3. Determines the at-the-money put and call strikes, as well as strikes that are 20, 30, and 40 points away
4. Returns the prices of a hypothetical iron butterfly constructed by selling an at-the-money put and call, and buying an out-of-the-money put and call (width based on the 20, 30, and 40 strikes determined above), based on the 3 closest expirations.
5. Returns the implied volatility spread of hypothetical butterflies, computed as: the sum of the implied volatility of out-of-the-money put and call, minus the sum of the implied volatility of the at-the-money put and call
This is more of a data importing/manipulating problem, so financial knowledge is not absolutely crucial.