Navigation: Realtest Script Language > Formula Syntax >

Special Syntax for Individual Futures Contract Testing





This category of external item reference is somewhat more specialized.

If you import all of the individual historical contracts for a futures market, you can, of course, refer to any specific contract by symbol, but how can you model something like a realistic roll-over strategy?

To solve this problem, RealTest does some extra processing on futures symbols during import. To take advantage of this feature, futures symbols must have a specific format:

The symbol must contain a non-alphabetic character delimiter between the root and the date, as in "ES-2016Z" or "CL.Z16"

A standard ASCII sort must result in the symbols being in correct date order. So for example, if your symbols are named using month names rather than the standard one-letter codes (e.g. "ES-MAR-16"), then this feature will not work.

Given that your symbols permit valid alphabetic sorting and root/date differentiation using the above rules, RealTest is able to construct a "symbol chain" during import, which it can later use to permit REALTIVE external symbol references.

The syntax for a relative reference is Extern(&n, expression), where ‘n’ is a numeric offset in either direction. Positive directions refer to newer contracts (ones that expire farther in the future) and negative directions to older ones (ones that expire sooner).

For example, if your current symbol is ES-2016Z, then Extern(&1, C) would give you today’s close for ES-2017H, and Extern(&-1,C) would give today’s close for ES-2016U.

The simplest application of this syntax is to accurately model "buy and hold" of a futures market using any desired rollover rule. For example, this strategy will hold 1 ES and roll at the open after the first day where the new contract has more volume than the old one:

You can also use this technique to model spread trading, calculate contango/backwardation indicators, or who knows what else.

The script es_compare.rts in the example scripts directory includes the above strategy and runs a comparison study of modeling "buy and hold" ES since its inception using (1) individual contracts with accurate rollover transaction modeling, (2) a single continuous price series without back-adjustment, and (3) a single continues back-adjusted price series.

If your futures data comes from Norgate then you will already have futures symbols in the correct format and can easily use this feature. The example mentioned above also shows how to structure the import to make this work.






Copyright © 2020-2022 Systematic Solutions, LLC