code2month: Convert Maturity Code to Corresponding Month
Description
This function takes a character string representing the maturity code of a
futures contract and returns the corresponding month as an integer. It supports
both the new and old maturity code formats used in futures contracts.
Usage
code2month(x)
Value
A vector of integers corresponding to the months of the year, where
1 = January, 2 = February, ..., 12 = December.
Arguments
x
A character vector with the maturity code(s) of futures contracts.
The codes can be either a single letter (e.g., "F", "G", "H", ...)
representing the new code format or a three-letter abbreviation (e.g.,
"JAN", "FEV", "MAR", ...) representing the old code format.
Details
The function distinguishes between two maturity code formats:
The new code format uses a single letter (e.g., "F" = January,
"G" = February, etc.).
The old code format uses a three-letter abbreviation (e.g.,
"JAN" = January, "FEV" = February, etc.).