Description Usage Arguments Value Note Author(s) References
The function creates a Nth Nearest futures contract specification which is passed onto the
futureseries
function for data extraction.
1 2 3 | nnearestspec(TargetForwardContract = 1, rollLogicType = -1, rollWhen = 1,
DayOfMonthToRoll = 5, MonthsPriorToRoll = 0, valid.months = "VVVVVVVVVVVV", GenerateForward = 0,
rollNDays = 5)
|
TargetForwardContract |
Specifies which forward contract to select. Must be at least 1. For example, the nearest future contract is the 1st nearest future, 1. The next contract out is the 2nd nearest future, 2. Using large numbers creates gaps (max allowed is 9). |
rollLogicType |
The logic to be used in deciding when to ignore a near contract. Valid values are -1 (RollOnOpenInterest), -2 (RollOnVolume), -3 (RollOnOpenInterestOrVolume),-4 (RollOnOpenInterestAndVolume), -5 (RollOnDayRelativeToStartOfMonth) or -6 (RollOnDayRelativeToEndOfMonth). |
rollWhen |
Controls how the time delay between when the days prices are published and when the day's volume and open interest are published is handled (there is almost always a one-day delay). Valid values are 0 (RollWhen Reported), 1 (RollWhe Known), 2 (RollWhen Anticipated) or 3 (RollWhen Lagged2). |
DayOfMonthToRoll |
The day of the month to roll (31 for expiration). |
MonthsPriorToRoll |
The number of months before the contract month to roll (0 for expiration month). |
valid.months |
This is a string of 12 characters. Each of those characters is either an “I” for inactive, “V” for active (valid), or “S” for switching (currently low volume.) During retrieval, the condition is “V” to retrieve and not “V” to ignore. If the active months have changed historically, it is up to the users to convert “S” to “V” to build representative contracts. Of course 12 “V” (“VVVVVVVVVVVV”) retrieves every contract ever traded (see note). |
GenerateForward |
Controls whether to begin with the earliest data and step day-by-day to the current, or begin with the current contract and prepend earlier data. |
rollNDays |
Controls the rolling days before expiration (see note). |
Returns an object of class uaSpec
valid.months
The user may find it useful to first call the marketprofile
which returns the active months.
rollNDays
The effects of this depend greatly on the GenerateForward option. If the UseAlternateBackAdjuster
is FALSE then GenerateFoward will have no effect. If you are generating forward (TRUE), then the alternate
back adjuster is applied. This back adjuster begins with the first day of data and steps forward backing
roll decisions based on the data as it becomes available. The rollNDays argument causes a roll to happen
if necessary to avoid getting too close to expiration. If you are not generating forward (FALSE), then
the standard back adjuster is applied. If the rollNDays is greater than zero, then the rollLogicType
is overridden so that rolls happen based only on expiration (Like a roll relative to month end).
Alexios Ghalanos
Commodity Systems Incorporated, UNFAIR ADVANTAGE API (API2) FUNCTIONAL SPECIFICATION, 2006.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.