Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Advanced Topics
Data and Research
Integrations
Export Functions of Template Libraries
Export functions are the interface functions of template libraries, which can be called by strategies that reference the template library.
Examples
-
Different programming languages have different formats for writing template libraries. The following are example codes for declaring and implementing export functions in template libraries:
javascript/* -- 策略引用该模板以后直接用 $.Test() 调用此方法 -- main 函数在策略中不会触发, 只做为模板调试的入口 */ $.Test = function() { Log('Test') } function main() { $.Test() }pythondef Test(): Log("template call") # 导出Test函数, 主策略可以通过ext.Test()调用 ext.Test = Testrust// after referencing this template, a strategy calls it as ext::Test() // functions called by the strategy must be declared pub pub fn Test() { Log!("template call"); } -
Strategies written in
Blockly visualmode can implement library functions throughJavaScriptlanguage template libraries. Please use the following format.javascript/*blockly { "type": "ext_testA", "message0": "testA|testA", "template": "function(){return 99;}()", "order": "ORDER_ATOMIC", "output": "Number" },{ "type": "ext_MA", "message0": "MA 周期 %1| MA Period %1", "args0": [{ "type": "input_value", "check": "Number" }], "template": "(function(){var r = exchange.GetRecords(); return (!r || r.length < %1) ? false : TA.MA(r, %1); })()", "order": "ORDER_ATOMIC", "output": null, "colour": 85 } */