Type/to search
Welcome to FMZ Quant Trading Platform
Programming Languages
JavaScript
TypeScript
Python
C++
MyLanguage
PINE Language
Blockly Visual Programming
Workflow
Key Security
Live Trading
Strategy Library
Docker
Deploy Docker
One-Click Docker Rental
Manual Deployment of Bot
Docker Operation Precautions
Global IP Address Specification
Command Line Parameters for Bot Program
Live Trading Data Migration
Docker Monitor
Exchange
Strategy Editor
Backtesting System
Strategy Entry Functions
Strategy Framework and API Functions
Template Library
Strategy Parameters
Interactive Controls
Options Trading
C++ Strategy Writing Guide
JavaScript Strategy Writing Guide
Web3
Built-in Libraries
Extended API Interface
MCP Service
Trading Terminal
Data Explorer
Alpha Factor Analysis Tool
General Protocol
Debugging Tool
Remote Editing
Import and Export of Complete Strategies
Multi-language Support
Live Trading and Strategy Grouping
Live Trading Display
Strategy Sharing and Renting
Live Trading Message Push
Common Causes of Live Trading Errors and Abnormal Exits
Exchange-Specific Notes

  • Setting the Python interpreter for Python strategy programs
    For strategies written in Python, during backtesting or live trading, if the host system has both Python2 and Python3 installed, you can set the Python version to launch at runtime in the first line of the strategy. For example: #!python3, #!python2, the system will automatically find the corresponding interpreter. You can also specify an absolute path, for example: #!/usr/bin/python3.

  • Security of Python-based strategies
    Strategies developed on the FMZ Quant Trading Platform are only visible to the holder of the FMZ Quant Trading Platform account. Additionally, complete localization of strategy code can be achieved on the FMZ Quant Trading Platform, such as packaging the strategy into a Python library and loading it in the strategy code, thus achieving strategy code localization.
    Python code security:
    Since Python is an open-source and easily decompilable language, if the strategy is not for personal use but for rental, and you are concerned about strategy leakage, you can run the strategy on your own deployed host and rent it out in the form of sub-account or fully managed management.

    Python strategy code encryption:
    By default, Python strategy code is not encrypted when used by the author themselves, but encrypted when rented to others. By writing the following code at the beginning of the Python strategy, you can specify whether to encrypt the strategy code when running for personal use or rental. Python versions that support strategy code encryption are: Python 2.7, Python 3.5, Python 3.6.

    • Encrypt strategy code both when the strategy author runs it themselves and when providing it to others via registration code:
      Use code #!python to specify the Python interpreter version, then use comma , as separator, and input the encryption command encrypt. If you don't specify the Python version, you can directly add #!encrypt.
      python
      #!python,encrypt
      or
      python
      #!encrypt
    • Do not encrypt strategy code when the strategy author runs it themselves or provides it to others via registration code:
      python
      #!python,not encrypted
      or
      python
      #!not encrypted

    To check if Python strategy code encryption is effective, use code os.getenv('__FMZ_ENV__'), which returns the string "encrypt" to indicate it's effective. Only valid in live trading, backtesting will not encrypt Python strategy code.

    python
    #!encrypt def main(): ret = os.getenv('__FMZ_ENV__') # Printing variable ret as string encrypt or ret == "encrypt" being true means encryption is effective Log(ret, ret == "encrypt")
  • Python custom module import functionality
    The FMZ platform supports importing custom modules in Python strategies, enabling modular development and code reuse.

    For example, if we need to design a module: mymath, save mymath.py as a separate file.

    python
    # mymath.py - save as a separate file """ Simple math utility module """ def add(a, b): """Addition""" return a + b

    Deploy the module file by placing mymath.py in the specified location under the host program directory (the folder name in the storage directory is the live trading Id, using live trading Id 123456 as an example):

    Host program directory/logs/storage/123456/mymath.py

    Finally, directly import the mymath module in the Python strategy on the FMZ platform.

    python
    import mymath def main(): Log("mymath.add(1, 2):", mymath.add(1, 2))

    The strategy bound to the live trading instance (strategy instance) with Id 123456 can then call methods from the mymath module.