Type/to search
Getting Started
Platform Basics
Writing Strategies
Strategy Structure
Programming Languages
Strategy Parameters
Interactive Controls
Strategy Frontend
Template Library
Export Functions of Template Libraries
Template Library Parameters
Reference Template Library
Built-in Libraries
UI Text Localization
API Quick Reference
Development Tools
Backtesting System
Advanced Topics
Data and Research
Extended API Interface

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.

Create Template Library Page

How template functions are exported and called in each language:

LanguageExport in the templateCall in the strategy
JavaScriptattach to $: $.Test = function() {...}$.Test()
Pythonattach to ext: ext.Test = Testext.Test()
Rustthe template code goes into the ext module; functions the strategy calls are declared pub fnext::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.
  • JavaScript templates can define init() and destroy(): init() runs when the template is loaded (before the strategy's init()), and destroy() runs when the strategy exits, after onexit() or onerror(). Python templates can define init(), which runs when the template is loaded.
  • Both Rust templates 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

NameDescription
Export Functions of Template LibrariesExported functions are the interface a template library offers; strategies that reference the template library can call them.
Template Library ParametersTemplate libraries can also set their own interface parameters.
Reference Template LibraryWhen a strategy references a template library, the currently logged-in FMZ Quant Trading Platform account must have available template libraries in its strategy…