Compilation Errors
When you press the Exit button in the Trading Spec Definition dialog, RuleTrader compiles your specification into computer code, so it can run at the full speed of your computer. The compilation process may reveal errors in your specification.
Don’t worry if this happens, as the errors are easy to fix. They generally arise when you referenced some definition B (often a Named Term) in some other definition A but then changed definition B, so it is no longer compatible with its usage in definition A. This is usually because either:
- Definition A didn’t require a currency specifier when you created definition B but now it does, or vice-versa. For example, if B was defined as a share’s volume, then it wouldn’t require a currency to be defined, when it is used in definition A, but if it’s subsequently changed to a share’s price, then it will.
- Definition A’s output type has changed, making it incompatible with its usage in B. The different types of output are: numeric value, percentage value, condition result (i.e. true or false), security (share), security (instrument), and security-list. So, for example:
- a numeric value can’t be replaced by a percentage value, and vice-versa
- conditions, security lists, securities, and values are not inter-changeable between types
- data that may be available for a share, may not be available for an instrument e.g. bonds and exchange-rates obviously don’t have profit values available
- etc.
Finding And Fixing The Error
When an error occurs, RuleTrader will beep, display a warning dialog, and display in the Console the names and locations of the definitions it can’t process. If you press Cancel in the warning dialog, you will lose the changes you have made to your Spec and revert to the previous ‘good’ version that RuleTrader was able to compile.
So to fix the problem, press Ok and RuleTrader will take you back to the Trading Spec Definition dialog. Then:
- Navigate to the problem definition and click the Edit button next to it, which opens the DEfT Wizard. Before doing this it’s a good idea to Show the definition in the dialog using the ‘Show selected’ option in the Operation drop-down list, so you have a copy of the original definition to refer to.
- In the Wizard, repeatedly click the Next button (don’t use the Finish Editing button until you’ve found the error) to step through each part of your definition:
- Sometimes, you’ll step through the entire definition and not see any change but, behind the scenes, you will have redefined it in a subtle way and fixed the issue.
- More often you’ll reach a point in your definition where the sequence of the definition changes and you’ll be required to select/enter something new (e.g. a currency), or not select/enter something you previously had entered.
Often this causes the Wizard to switch from Edit mode back to Create mode (indicated by the ‘WAS’ and ‘NOW’ descriptions being replaced by a single, truncated description of your definition up to that point). You’ll then have to redefine the remaining part of your definition, which is why it’s a good idea to Show the definition in the console first.
Alternatively, if the error is caused by a reference to a definition whose, e.g. type, has changed, then you may want to edit that referenced definition instead. In this case, press Escape on your keyboard to exit editing of the current definition, then modify the referenced definition to fix the issue.
3. Once you have fixed all the definitions listed in the Console, navigate back to the Shared level of the Trading Spec Definition dialog and click Exit to re-compile your Spec.
4. Sometimes the changes you make, while fixing your definitions, introduce new errors in other definitions that refer to them. In this case the compiler will report the new errors, which you can fix using the same steps above. Fortunately it is rare for this to happen, if at all, more than 2 or 3 times.
Cyclic Definition Errors
Another type of error you may see is a cyclic definition error, where a sequence of definitions have been defined in a way that creates an irresolvable cycle e.g. A = B = C = D = A. RuleTrader will display in the Console a list of the definitions that make up the cycle so, again, it is very easy to fix simply by redefining one or more of these definitions to break the loop.
Bias Warnings
The compiler will also warn you if any of your definitions may inadvertently bias your results e.g. if you use the FTSE 350 as a source list this would bias your back-test, as ShareScope only stores the constituents of the FTSE 350 index as it stands today. So having access to this list, when the back-test starts running sometime in the past, would give your trading system an unfair advantage, as it would know which companies have been successful enough to make it into the FTSE 350.
Similarly, because ShareScope does not store a history of company results forecasts, RuleTrader uses the actual future results when forecast results are requested in back-tests in past periods, which also may bias your tests.