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

Due to the inherent characteristics of the JavaScript language (JavaScript's built-in strings only support ASCII and UTF-16 encoding, to avoid data loss), when encountering strings that cannot be encoded, an ArrayBuffer type will be returned. In all API interfaces of the FMZ Quant platform, wherever string parameters can be passed, ArrayBuffer type is also supported.

The following example demonstrates this feature in detail:

javascript
function stringToHex(str) { let hex = ''; for (let i = 0; i < str.length; i++) { const charCode = str.charCodeAt(i).toString(16); hex += charCode.length === 1 ? '0' + charCode : charCode; } return hex; } function main() { const inputString = "abc𠮷123"; // The Unicode code point of this "𠮷" character exceeds the 16-bit range // const inputString = "abcG123"; // If using abcG123 string for testing, the variable outputD will not be assigned as ArrayBuffer // Use the Encode function to encode inputString to hexadecimal encoding const encodedHex = Encode("raw", "string", "hex", inputString); Log(encodedHex); // Content: 61 62 63 f0a0aeb7 31 32 33 // Use custom stringToHex function to encode, unable to handle "𠮷" character, resulting in incorrect hexadecimal encoding const manuallyEncodedHex = stringToHex(inputString); Log(manuallyEncodedHex); // Content: 61 62 63 d842dfb7 31 32 33 // Successfully restore from hexadecimal encoding to string (variable inputString) const decodedString = Encode("raw", "hex", "string", encodedHex); Log(decodedString); // Unable to decode, returns ArrayBuffer, i.e., variable outputD is of ArrayBuffer type const outputD = Encode("raw", "hex", "string", manuallyEncodedHex); Log(outputD); // Verify the returned ArrayBuffer type variable outputD const bufferD = new Uint8Array(outputD); let hexBufferD = ''; for (let i = 0; i < bufferD.length; i++) { hexBufferD += bufferD[i].toString(16).padStart(2, '0'); } Log(hexBufferD); // 61 62 63 d842dfb7 31 32 33 }