Article Contents
Print

Finding And Fixing Trading Spec Compilation Errors

Reference Errors

These errors are caused when one definition A references the output of a second definition B and that second definition B is changed in a way that its output no longer ‘fits’ in the first definition A. There are two ways this can happen:

  1. the referenced definition B’s currency requirement has changed, so that while it’s output didn’t previously need a currency to be specified in definition A, it needs one now, 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 referenced in definition A but if it’s subsequently changed to a share’s price, then it will.
  2. the referenced definition B’s output type has changed, so that while the previous type ‘fitted’ in definition A, the new type doesn’t. 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.

When an error is detected, RuleTrader beeps and displays an error message dialog and a message in the Console showing the location of the error. If you click Cancel in the error dialog, you’ll lose the changes you just made to the Trading Specification and RuleTrader will revert to the last good version of your Trading Spec. So to fix the error, click Ok, which will take you back to the Trading Specification Dialog.

Go to the erroneous definition, tick the checkmark next to it and choose Show Selected from the Operation drop-down, then click Do It!. This displays the definition, and any Private Terms it has, in the Console. You’ll find this handy to refer to if you need to rebuild the definition from the point where the error occurred.

Now click the Edit button, next to the definiton, to go back to the DEfT Wizard, which will open with that definition ready to be edited. If the error was in one of the definition’s Private Terms then click Edit next to that term.

With the faulty definition now in edit mode, keep clicking Next (don’t use the Finish Editing button until you’ve found the error), while watching the evolution of the ‘NOW’ sentence that describes the definition, as it is edited, and the ‘WAS’ sentence, which describes how the definition was originally. One of three things will happen, either:

  1. The ‘WAS’ sentence will disappear and you’ll be left with a partially completed sentence, as the Wizard switches from edit mode to create mode. This happens because something has changed in the definition that meant the flow of entries has changed, so this is where the error has occurred. From here you’ll need to recreate the rest of the definition using the options that are now available to you. This type of issue most often occurs when a currency specifier is now, or is no longer, required.
  2. Or you’ll get to the end of the definition and it will successfully complete. This happens when the error doesn’t affect the flow of the definition, but nevertheless it was there in the background and you’ll have fixed it without realising it. You can now exit and recompile your Spec.
  3. Or you’ll get to a location where the option you had previously selected is no longer available. This may be the name of another definition, whose type has changed, or it may be a security value that is no longer available for the security specified earlier in the definition. This type of error is often because the referenced definition (or an earlier referenced definition that defined the security) has changed.

To fix it, you’ll either have to change the current, referencing definition to accommodate the new type of the referenced definition. Or you’ll want to press Escape to exit editing of the current referencing definition, so you can edit the referenced definition, so it conforms to the type expectations of that referencing definition.

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.

Scroll to Top