Template Library
A reusable code module on the FMZ Quant Trading Platform and a category of strategy code. Languages that support template libraries: JavaScript, Python and Rust. If the category is set to template library when a strategy is created, a template library is created in the strategy library of the logged-in account; its category cannot be changed to an ordinary strategy afterwards.

How template functions are exported and called in each language:
| Language | Export in the template | Call in the strategy |
|---|---|---|
| JavaScript | attach to $: $.Test = function() {...} | $.Test() |
| Python | attach to ext: ext.Test = Test | ext.Test() |
| Rust | the template code goes into the ext module; functions the strategy calls are declared pub fn | ext::Test() |
- A template's
main()function is not run by the strategy; it is only the entry point for backtesting or debugging the template on its own. JavaScripttemplates can defineinit()anddestroy():init()runs when the template is loaded (before the strategy'sinit()), anddestroy()runs when the strategy exits, afteronexit()oronerror().Pythontemplates can defineinit(), which runs when the template is loaded.- Both
Rusttemplates and strategies can declare third-party crates in a frontmatter block, but the dependency block may appear in only one of them; declaring it in both fails the build.
In this sectionRead the whole section
| Name | Description |
| Export Functions of Template Libraries | Exported functions are the interface a template library offers; strategies that reference the template library can call them. |
| Template Library Parameters | Template libraries can also set their own interface parameters. |
| Reference Template Library | When a strategy references a template library, the currently logged-in FMZ Quant Trading Platform account must have available template libraries in its strategy… |