RealTest User Guide
RealTest User Guide

 

 

Navigation: RealTest Script Language > Syntax Element Details >

Namespace

 

 

 

 

Category

Script Sections

Description

Specifies a prefix for user-defined items, to prevent duplication when including multiple scripts

Syntax

Namespace: xxx

Notes

All names defined after a Namespace statement are internally converted to have the specified prefix.

For example, Data: Universe: InSPX would internally become Data: xxx.Universe: InSPX.

Subsequent statements, while the same Namespace is still in effect, can then refer to Universe as EITHER Universe or xxx.Universe.

However, if the above Data statement was in an Included script, references in the including script would be required to use xxx.Universe.

An item can be referred to by its bare name only while its Namespace is in effect. From a different Namespace, after Namespace: none, or from an including script, it must be referred to by its full xxx.name. An item defined with no Namespace has no prefix, so it cannot be referred to from within a Namespace.

To share one value across several namespaces, define it under its own Namespace and refer to it by its full name. For example, define Param1 under Namespace: Globals, then refer to it elsewhere as Globals.Param1.

The most common use case for Namespace is e.g.:

Namespace: ns1

Include: myscript1.rts

Namespace: ns2

Include: myscript2.rts

// etc.

This would ensure that all names defined in each included script remain unique.

Use Namespace: none to remove the current Namespace and revert to not auto-prefixing the item names.

A Namespace prefix, when specified, is applied to all User-Defined Item names.

Namespace is also applied to these special-use names:

Import IncludeList user-defined names, e.g. IncludeList: SPY,TLT,GLD {"my_etfs"} would internally be named xxx.my_etfs

InList references to the above, e.g., InList("my_etfs"), would internally become InList("xxx.my_etfs")

Names derived by the Item function, e.g., Item("factor{#}", factor_number) would return e.g. xxx.factor3

Another use case for Namespace is to prevent Item Name Overrides. By default, in most script sections, RealTest will replace the formula associated with a name with the new one found under the same name. Use Namespace to ensure that both formulas are preserved and given unique names.

Finally, in many cases, it may be preferable to simply use unique item names across all of your scripts, rather than relying on Namespace to differentiate them.

See also Combining Scripts.

 

 

 

Copyright © 2020-2026 Systematic Solutions, LLC