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 in the same script could 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.
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.
|