Extended API Interface
FMZ Quant Trading Platform provides extended API interfaces, supporting programmatic access to various functions of the FMZ quantitative trading platform.
Create ApiKey
FMZ Quant Trading Platform supports permission management for extended API interfaces, allowing you to set permissions for API KEY. On the platform's Account Settings page under the "API Interface" option, click the "Create New ApiKey" button to create an extended API KEY.
When creating an API KEY, you can enter the * symbol in the "API Permissions" input box to enable all extended API interface permissions. To specify specific interface permissions, enter the corresponding extended API function names separated by commas, for example: GetRobotDetail,DeleteRobot, which will grant this API KEY permission to call the Get Live Trading Details interface and Delete Live Trading interface.
On the API KEY management page, you can also perform operations such as modify, disable, and delete on created API KEYs.
Extended API Interface Return Codes
The data structure returned by the extended API interface is as follows:
json
{
"code":0,
"data":{
// ...
}
}
The code field indicates the status code returned when calling the extended API interface.
| Description | Code |
|---|---|
| Execution successful | 0 |
| Invalid API KEY | 1 |
| Invalid signature | 2 |
| Nonce error | 3 |
| Incorrect method | 4 |
| Incorrect parameters | 5 |
| Internal unknown error | 6 |
Live Trading Status Codes
The status field in the data returned by GetRobotList, GetRobotDetail, and GetRobotLogs interfaces represents: Live Trading Status Code.
- Normal Start
Status Code Idle 0 Running 1 Stopping 2 Exited 3 Stopped 4 Strategy Error 5 - Exception
Status Code Strategy expired, please contact author to repurchase -1 Docker not found -2 Strategy compilation error -3 Live trading already running -4 Insufficient balance -5 Strategy concurrency limit exceeded -6
Authentication Methods
Two authentication methods are supported when calling extended API interfaces: token authentication and direct authentication.
Token Authentication
Use md5 encryption for verification. Below are calling examples in Python and Golang:
python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import json
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
try:
import md5
import urllib2
from urllib import urlencode
except:
import hashlib as md5
import urllib.request as urllib2
from urllib.parse import urlencode
accessKey = '' # your API KEY
secretKey = ''
def api(method, *args):
d = {
'version': '1.0',
'access_key': accessKey,
'method': method,
'args': json.dumps(list(args)),
'nonce': int(time.time() * 1000),
}
d['sign'] = md5.md5(('%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], secretKey)).encode('utf-8')).hexdigest()
# Note: urllib2.urlopen function may have timeout issues, you can set timeout, for example: urllib2.urlopen('https://www.fmz.com/api/v1', urlencode(d).encode('utf-8'), timeout=10) sets timeout to 10 seconds
return json.loads(urllib2.urlopen('https://www.fmz.com/api/v1', urlencode(d).encode('utf-8')).read().decode('utf-8'))
# Return docker list
print(api('GetNodeList'))
# Return exchange list
print(api('GetPlatformList'))
# GetRobotList(offset, length, robotStatus, label), pass -1 to get all
print(api('GetRobotList', 0, 5, -1, 'member2'))
# CommandRobot(robotId, cmd) send command to live trading bot
print(api('CommandRobot', 123, 'ok'))
# StopRobot(robotId) return live trading bot status code
print(api('StopRobot', 123))
# RestartRobot(robotId) return live trading bot status code
print(api('RestartRobot', 123))
# GetRobotDetail(robotId) return live trading bot detailed information
print(api('GetRobotDetail', 123))
mylang
package main
import (
"fmt"
"time"
"encoding/json"
"crypto/md5"
"encoding/hex"
"net/http"
"io/ioutil"
"strconv"
"net/url"
)
// Fill in your FMZ platform API key
var apiKey string = ""
// Fill in your FMZ platform secret key
var secretKey string = ""
var baseApi string = "https://www.fmz.com/api/v1"
func api(method string, args ... interface{}) (ret interface{}) {
// Process parameters
jsonStr, err := json.Marshal(args)
if err != nil {
panic(err)
}
params := map[string]string{
"version" : "1.0",
"access_key" : apiKey,
"method" : method,
"args" : string(jsonStr),
"nonce" : strconv.FormatInt(time.Now().UnixNano() / 1e6, 10),
}
data := fmt.Sprintf("%s|%s|%s|%v|%s", params["version"], params["method"], params["args"], params["nonce"], secretKey)
h := md5.New()
h.Write([]byte(data))
sign := h.Sum(nil)
params["sign"] = hex.EncodeToString(sign)
// http request
client := &http.Client{}
// request
urlValue := url.Values{}
for k, v := range params {
urlValue.Add(k, v)
}
urlStr := urlValue.Encode()
request, err := http.NewRequest("GET", baseApi + "?" + urlStr, nil)
if err != nil {
panic(err)
}
resp, err := client.Do(request)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
ret = string(b)
return
}
func main() {
settings := map[string]interface{}{
"name": "hedge test",
"strategy": 104150,
// K-line period parameter, 60 means 60 seconds
"period": 60,
"node" : 73938,
"appid": "member2",
"exchanges": []interface{}{
map[string]interface{}{
"eid": "Exchange",
"label" : "test_bjex",
"pair": "BTC_USDT",
"meta" : map[string]interface{}{
// Fill in access key
"AccessKey": "",
// Fill in secret key
"SecretKey": "",
"Front" : "http://127.0.0.1:6666/exchange",
},
},
},
}
method := "RestartRobot"
fmt.Println("Call interface:", method)
ret := api(method, 124577, settings)
fmt.Println("main ret:", ret)
}
Direct Verification
Supports authentication without using token (direct secret_key authentication), allowing generation of URLs for direct access. For example, URLs for sending interactive commands directly to live trading bots can be used for Trading View or other WebHook callback scenarios. For the extended API interface CommandRobot() function, nonce verification is not performed, and there are no limits on access frequency or number of accesses for this interface.
For example: If the AccessKey in the created extended API KEY is: xxx, and the SecretKey is: yyy. Accessing the following link will send an interactive command message to the live trading bot with ID 186515, with the message content being the string: "ok12345".
plaintext
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyy&method=CommandRobot&args=%5B186515%2C%22ok12345%22%5D
When direct authentication is supported, the Body data from the request can be obtained, only supporting the CommandRobot interface. For example, setting in Trading View's WebHook URL:
plaintext
https://www.fmz.com/api/v1?access_key=xxx&secret_key=yyy&method=CommandRobot&args=%5B186515%2C+%22%22%5D
Note that it must be set in this format: %5B186515%2C+%22%22%5D (before encoding: [186515, ""]), where 186515 is the live trading bot ID on the FMZ Quant Trading Platform.
Simulating Trading View sending WebHook URL alerts:
javascript
function main() {
var options = {
method: "POST",
body: `{"test": 123}`,
headers: {"Content-Type": "application/json"}
}
// WebHook URL alerts will automatically send POST requests, including required headers settings
return HttpQuery("https://www.fmz.com/api/v1?access_key=xxx&secret_key=xxx&method=CommandRobot&args=%5B186515%2C+%22%22%5D", options)
}
Setting in Trading View message box (Body data to be sent in the request):
-
JSON format:
plaintext{"close": {{close}}, "name": "aaa"}The live trading bot with ID
186515will receive the interactive command string:{"close": 39773.75, "name": "aaa"}. -
Text format:
plaintextBTCUSDTPERP Crossing 39700.00 close: {{close}}The live trading bot with ID
186515will receive the interactive command string:BTCUSDTPERP Crossing 39700.00 close: 39739.4.
Python, Golang language call examples:
python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
try:
import urllib2
except:
import urllib.request as urllib2
accessKey = 'your accessKey'
secretKey = 'your secretKey'
def api(method, *args):
return json.loads(urllib2.urlopen(('https://www.fmz.com/api/v1?access_key=%s&secret_key=%s&method=%s&args=%s' % (accessKey, secretKey, method, json.dumps(list(args)))).replace(' ', '')).read().decode('utf-8'))
# If the API KEY doesn't have permission for this interface, calling print(api('RestartRobot', 186515)) will fail, returning data: {'code': 4, 'data': None}
# print(api('RestartRobot', 186515))
# Print detailed information of the live trading bot with ID: 186515
print(api('GetRobotDetail', 186515))
mylang
package main
import (
"fmt"
"encoding/json"
"net/http"
"io/ioutil"
"net/url"
)
// Fill in your own FMZ platform api key
var apiKey string = "your access_key"
// Fill in your own FMZ platform secret key
var secretKey string = "your secret_key"
var baseApi string = "https://www.fmz.com/api/v1"
func api(method string, args ... interface{}) (ret interface{}) {
jsonStr, err := json.Marshal(args)
if err != nil {
panic(err)
}
params := map[string]string{
"access_key" : apiKey,
"secret_key" : secretKey,
"method" : method,
"args" : string(jsonStr),
}
// http request
client := &http.Client{}
// request
urlValue := url.Values{}
for k, v := range params {
urlValue.Add(k, v)
}
urlStr := urlValue.Encode()
request, err := http.NewRequest("GET", baseApi + "?" + urlStr, nil)
if err != nil {
panic(err)
}
resp, err := client.Do(request)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
ret = string(b)
return
}
func main() {
method := "GetRobotDetail"
fmt.Println("Calling interface:", method)
ret := api(method, 186515)
fmt.Println("main ret:", ret)
}
Implementing TradingView Alert Signal Trading Using FMZ Quant Trading Platform Extended API
Implementing TradingView Alert Signal Trading Using FMZ Quant Trading Platform Extended API, Bilibili Video Link
Extended API Interface Details
-
FMZ Quant Trading Platform Extended API Interface
Append query parameters directly afterhttps://www.fmz.com/api/v1(separated by?). Below are the request parameters expressed inPython:json{ "version" : "1.0", "access_key": "xxx", "method" : "GetNodeList", "args" : [], "nonce" : 1516292399361, "sign" : "085b63456c93hfb243a757366600f9c2" }Field Description version Version number. access_key AccessKey, apply on the account management page. method The specific method to call. args Parameter list for calling the method. nonce Timestamp in milliseconds, allowing a 1-hour deviation from standard timestamp. The nonce must be greater than the nonce value from the previous access. sign Signature. Parameters are separated by
&, parameter names and values are connected by=. Complete request URL (usingmethod=GetNodeListas an example):plaintexthttps://www.fmz.com/api/v1?access_key=xxx&nonce=1516292399361&args=%5B%5D&sign=085b63456c93hfb243a757366600f9c2&version=1.0&method=GetNodeListNote: The request parameters do not include the
secret_keyparameter. -
Signature Method
The encryption method for thesignparameter in the request is as follows, formatted as:plaintextversion + "|" + method + "|" + args + "|" + nonce + "|" + secretKeyAfter concatenating the string, use the
MD5encryption algorithm to encrypt the string and convert it to a hexadecimal string. This value is used as the value of thesignparameter. For the signature part, refer to thePythoncode Extended API Interface "Authentication Method":python# Parameters d = { 'version': '1.0', 'access_key': accessKey, 'method': method, 'args': json.dumps(list(args)), 'nonce': int(time.time() * 1000), } # Calculate sign signature d['sign'] = md5.md5(('%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], secretKey)).encode('utf-8')).hexdigest() -
Interface Business Errors:
- Insufficient parameters:json{ "code":0, "data":{ "result":null, "error":"Params length incorrect" } }
- Insufficient parameters:
GetNodeList
The GetNodeList method is used to retrieve the list of docker nodes under the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code": 0,
"data": {
"result": {
"all": 1,
"nodes": [{
"build": "3.7",
"city": "...",
"created": "2024-11-08 09:21:08",
"date": "2024-11-08 16:37:16",
"forward": "...",
"guid": "...",
"host": "node.fmz.com:9902",
"id": 123,
"ip": "...",
"is_owner": true,
"loaded": 0,
"name": "MacBook-Pro-2.local",
"online": true,
"os": "darwin/amd64",
"peer": "...",
"public": 0,
"region": "...",
"tunnel": false,
"version": "...",
"wd": 0
}]
},
"error": null
}
}
Return value field descriptions (fields with obvious literal meanings are not elaborated):
- all: Total number of docker nodes associated with the current account.
- nodes: List of detailed information for docker nodes.
- build: Version number.
- city: City location.
- is_owner: true indicates private docker, false indicates public docker.
- loaded: Load amount, i.e., the number of currently running strategy instances.
- public: 0 indicates private docker, 1 indicates public docker.
- region: Geographic location.
- version: Detailed version information of the docker.
- wd: Offline alarm switch, 0 indicates not enabled.
One-click deployed dockers contain additional information, with related fields prefixed byecs_andunit_, recording information about the one-click deployed docker server (operator name, configuration, status, etc.), billing cycle, price, and other information, which will not be detailed here.
Arguments
No parameters
GetRobotGroupList
The GetRobotGroupList method is used to get the list of live trading groups under the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code": 0,
"data": {
"result": {
"items": [{
"id": 3417,
"name": "Test"
}, {
"id": 3608,
"name": "Live Trading Demo"
}]
},
"error": null
}
}
- items: Live trading group information.
- id: Live trading group ID.
- name: Live trading group name.
Theitemsfield only records newly created groups, the "Default" group is not included initems.
Arguments
No parameters
GetPlatformList
The GetPlatformList method is used to get the list of configured exchanges under the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code": 0,
"data": {
"result": {
"all": 2,
"platforms": [{
"category": "加密货币||Crypto",
"date": "2023-12-07 13:44:52",
"eid": "Binance",
"id": 123,
"label": "币安",
"logo": "...",
"name": "币安现货|Binance",
"stocks": ["BTC_USDT", "LTC_USDT", "ETH_USDT", "ETC_USDT", "BTC_TUSD", "ETH_TUSD", "BNB_TUSD"],
"website": "..."
}, {
"category": "通用协议|Custom Protocol",
"date": "2020-11-09 11:23:48",
"eid": "Exchange",
"id": 123,
"label": "XX交易所REST协议",
"logo": "...",
"name": "通用协议|Custom Protocol",
"stocks": ["BTC_USDT", "ETH_USDT"],
"website": ""
}]
},
"error": null
}
}
- all: Total number of configured exchange objects.
- platforms: Exchange related information.
- eid: Exchange identifier on the FMZ Quant Trading Platform,
eidis required in certain configurations and parameters.
- eid: Exchange identifier on the FMZ Quant Trading Platform,
Arguments
No parameters
GetRobotList
The GetRobotList method is used to get the list of live trading bots under the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code": 0,
"data": {
"result": {
"all": 1,
"concurrent": 0,
"robots": [{
"charge_time": 1731654846,
"date": "2024-11-12 14:05:29",
"end_time": "2024-11-15 14:56:32",
"fixed_id": 4509153,
"id": 591026,
"is_sandbox": 0,
"name": "Test",
"node_guid": "45891bcf3d57f99b08a43dff76ee1ea1",
"node_id": 4519153,
"node_public": 0,
"profit": 0,
"public": 0,
"refresh": 1731651257000,
"start_time": "2024-11-15 14:56:30",
"status": 3,
"strategy_id": 411670,
"strategy_isowner": true,
"strategy_language": 0,
"strategy_name": "Test",
"strategy_public": 0,
"uid": "105ed6e511cc977921610fdbb7e2a1d6",
"wd": 0
}]
},
"error": null
}
}
- robots: Live trading bot information
- group_id: Live trading bot group ID; if the live trading bot is in the default group, the
group_idfield is not included.
- group_id: Live trading bot group ID; if the live trading bot is in the default group, the
Arguments
| Name | Type | Required | Description |
offset | number | No | Offset setting for pagination query. |
length | number | No | Data length setting for pagination query. |
robotStatus | number | No | Specify the status of live trading bots to query, refer to Extended API Interface "Live Trading Status Codes", pass |
label | string | No | Specify the custom label of live trading bots to query, can filter all live trading bots containing this label. |
keyWord | string | No | Query keyword. |
Remarks
Taking the Extended API Interface "Authentication Method" in Python language as an example:
print(api('GetRobotList')): Get all live trading bot information.
print(api('GetRobotList', 'member2')): Print all live trading bot information with custom label member2.
print(api('GetRobotList', 0, 5, -1, 'member2')): Pagination query, starting from offset 0, returning at most 5 live trading bots with label member2.
CommandRobot
The CommandRobot method is used to send interactive commands to a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The bot Id that receives the interactive command is specified by the robotId parameter, and the interactive command is captured and returned by the GetCommand() function called in the strategy.
Returns
json
{
"code":0,
"data":{
"result":true,
"error":null
}
}
- result: Whether the interactive command was sent successfully. When sending a command to a bot that is not running, the result in the returned data will be false.
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
cmd | string | Yes | The |
Remarks
Example of bot strategy (assuming this strategy bot is running with bot Id 123):
javascript
function main() {
while (true) {
var cmd = GetCommand()
if (cmd) {
Log(cmd)
}
Sleep(2000)
}
}
If you use the Python test script in this section to access the FMZ Quant Trading Platform's extended API: api("CommandRobot", 123, "test command"), the bot with Id 123 will receive the interactive command: test command, and output it through the Log function.
StopRobot
The StopRobot method is used to stop a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The bot Id to be stopped is specified by the robotId parameter.
Returns
json
{
"code":0,
"data":{
"result":2,
"error":null
}
}
- result: Bot status code, 2 indicates stopping.
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
RestartRobot
The RestartRobot method is used to restart a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The bot ID to be restarted is specified by the robotId parameter.
Returns
json
{
"code":0,
"data":{
"result":1,
"error":null
}
}
- result: Live trading status code, 1 indicates running.
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
settings | JSON object | No | Live trading configuration parameters. The
|
Remarks
If the live trading bot was created through the extended API interface, it must be restarted using the extended API interface RestartRobot, and the settings parameter must be passed. For live trading bots created on the platform page, they can be restarted through the extended API interface or by clicking the button on the live trading page. The settings parameter can be passed or not. If only the robotId parameter is passed, it will start running according to the current settings of the live trading bot.
GetRobotDetail
The GetRobotDetail method is used to get detailed information of a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The detailed information of the live trading bot to be retrieved is specified by the robotId parameter.
Returns
json
{
"code": 0,
"data": {
"result": {
"robot": {
"charge_time": 1732246539,
"charged": 5850000,
"consumed": 5375000000,
"date": "2018-12-28 14:34:51",
"favorite": {
"added": false,
"type": "R"
},
"fixed_id": 123,
"hits": 1,
"id": 123,
"is_deleted": 0,
"is_manager": true,
"is_sandbox": 0,
"name": "Test",
"node_id": 123,
"pexchanges": {
"123": "Futures_OKCoin"
},
"phash": {
"123": "ca1aca74b9cf7d8624f2af2dac01e36d"
},
"plabels": {
"123": "OKEX Futures V5"
},
"priority": 0,
"profit": 0,
"public": 0,
"refresh": 1732244453000,
"robot_args": "[]",
"start_time": "2024-11-22 11:00:48",
"status": 1,
"strategy_args": "[]",
"strategy_exchange_pairs": "[60,[123],[\"ETH_USDT\"]]",
"strategy_id": 123,
"strategy_last_modified": "2024-11-21 16:49:25",
"strategy_name": "Test",
"strategy_public": "0",
"uid": "105ed6e51bcc17792a610fdbb7e2a1d6",
"username": "abc",
"wd": 0
}
},
"error": null
}
}
- charge_time: Next billing time, i.e., the valid expiration time after current billing.
- charged: Time consumed.
- consumed: Amount consumed (0.125 USD = 12500000 / 1e8).
- date: Creation date.
- fixed_id: Docker ID assigned during live trading. If auto-assigned, this value is -1.
- is_manager: Whether has permission to manage this live trading bot.
- is_sandbox: Whether it is a simulated trading bot.
- name: Live trading bot name.
- node_id: Docker ID.
- pexchanges: Exchange objects configured for the live trading bot, where 123 is the pid and "Futures_OKCoin" is the exchange name.
- plabels: Label information for the exchange objects configured for the live trading bot.
- profit: Live trading bot profit data.
- public: Whether the live trading bot is public.
- refresh: Last active time.
- strategy_exchange_pairs: Configured exchange objects and their trading pair information.
- wd: Whether offline alert is enabled.
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
Remarks
Explanation of the strategy_exchange_pairs attribute, using the following data as an example:
plaintext
"[60,[44314,42960,15445,14703],[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"]]"
The first data 60 indicates that the default K-line period set for the live trading bot is 1 minute, i.e., 60 seconds.
[44314,42960,15445,14703] are the pid values of the exchange objects configured for the live trading bot (arranged in the order they were added).
[\"BTC_USDT\",\"BTC_USDT\",\"ETH_USDT\",\"ETH_USDT\"] are the trading pairs set for the exchange objects configured for the live trading bot (corresponding one-to-one with the pid values in the order they were added).
GetAccount
The GetAccount method is used to retrieve account information for the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code":0,
"data":{
"result":{
"balance":22944702436,
"concurrent":0,
"consumed":211092719653,
"currency":"USD",
"email":"[email protected]",
"openai":false,
"settings":null,
"sns":{"wechat":true},
"uid":"105ea6e51bcc177926a10fdbb7e2a1d6",
"username":"abc"
},
"error":null
}
}
- balance: Account balance
The value here is represented as an integer to ensure precision. The actual value needs to be divided by 1e8 (10 to the power of 8) for conversion. In this example, the actual balance is: 229.44702436
GetExchangeList
The GetExchangeList method is used to get the list of exchanges supported by the FMZ quantitative trading platform and their configuration information.
Returns
When the isSummary parameter is false, the returned data:
json
{
"code": 0,
"data": {
"result": {
"exchanges": [{
"category": "加密货币||Crypto",
"eid": "Futures_Binance",
"id": 74,
"logo": "/upload/asset/d8d84b23e573e9326b99.svg",
"meta": "[{\"desc\": \"Access Key\", \"qr\":\"apiKey\",\"required\": true, \"type\": \"string\", \"name\": \"AccessKey\", \"label\": \"Access Key\"}, {\"encrypt\": true, \"qr\":\"secretKey\",\"name\": \"SecretKey\", \"required\": true, \"label\": \"Secret Key\", \"type\": \"password\", \"desc\": \"Secret Key\"}]",
"name": "币安期货|Futures_Binance",
"priority": 200,
"stocks": "BTC_USDT,ETH_USDT,ETH_USD",
"website": "https://accounts.binance.com/zh-TC/register?ref=45110270"
}]
},
"error": null
}
}
When the isSummary parameter is true, the returned data:
json
{
"code": 0,
"data": {
"result": {
"exchanges": [{
"category": "加密货币||Crypto",
"eid": "Futures_Binance",
"id": 74,
"logo": "/upload/asset/d8d84b23e573e9326b99.svg",
"name": "币安期货|Futures_Binance",
"priority": 200,
"website": "https://accounts.binance.com/zh-TC/register?ref=45110270"
}]
},
"error": null
}
}
- meta: Exchange configuration metadata.
Arguments
| Name | Type | Required | Description |
isSummary | bool | Yes | The |
DeleteNode
The DeleteNode method is used to delete a docker node under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The docker node ID to be deleted is specified by the nid parameter.
Returns
json
{
"code":0,
"data":{
"result":true,
"error":null
}
}
- result: Whether the associated docker program was successfully deleted.
Arguments
| Name | Type | Required | Description |
nid | number | Yes | The |
DeleteRobot
The DeleteRobot method is used to delete a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The deleted bot ID is specified by the robotId parameter.
Returns
json
{
"code":0,
"data":{
"result":0,
"error":null
}
}
- result: Feedback result of the bot deletion operation.
- 0: Normal deletion.
- -2: Deletion successful, but unable to contact the docker associated with the bot, please manually delete the file 123.db3!
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
deleteLogs | bool | Yes | The |
GetStrategyList
The GetStrategyList method is used to retrieve platform strategy information.
Returns
json
{
"code": 0,
"data": {
"result": {
"all": 123,
"strategies": [{
"category": 9,
"date": "2024-11-10 20:40:04",
"description": "",
"forked": 0,
"hits": 0,
"id": 123,
"is_buy": false,
"is_owner": false,
"language": 2,
"last_modified": "2024-11-11 17:23:52",
"name": "HedgeGridStrategy",
"profile": {
"avatar": "...",
"nickname": "abc",
"uid": "4ed225440db1eda23fe05ed10184113e"
},
"public": 0,
"tags": "",
"uid": "4ed225440db1eda23fe05ed10184113e",
"username": "abc"
}]
},
"error": null
}
}
- all: Total number of strategies matching the filter criteria.
- strategies: Detailed information of strategies returned by the query.
Arguments
| Name | Type | Required | Description |
offset | number | Yes | The |
length | number | Yes | The |
strategyType | number | Yes | The
|
category | number | Yes | The
|
needArgs | number | Yes | The
|
language | number | Yes | The
|
kw | string | Yes | The
|
NewRobot
The NewRobot method is used to create a live trading bot under the FMZ Quant Trading Platform account corresponding to the API KEY in the request.
Returns
json
{
"code":0,
"data":{
"result":591988,
"error":null
}
}
- result: Successfully created, returns the live trading ID.
Arguments
| Name | Type | Required | Description |
settings | JSON Object | Yes | Live trading configuration parameters. The
|
Remarks
Sensitive information such as "meta":{"AccessKey": "123", "SecretKey": "123"} configured in the eid of the settings parameter will not be stored by the FMZ Quant Trading Platform. This data will be directly forwarded to the docker program, so this information must be configured each time a live trading bot is created or restarted.
When creating a live trading bot using a general protocol exchange object, the exchanges property can use the following settings when configuring the settings parameter:
json
{
"eid": "Exchange",
"label": "test",
"pair": "ETH_BTC",
"meta": {
"AccessKey": "123",
"SecretKey": "123",
"Front": "http://127.0.0.1:6666/test"
}
}
The label property is used to set a label for the current general protocol connected exchange object, which can be retrieved in the strategy using the exchange.GetLabel() function.
PluginRun
The PluginRun method is used to call the debugging tool functionality of the FMZ Quant Trading Platform; only JavaScript language is supported.
Returns
json
{
"code": 0,
"data": {
"result": "{\"logs\":[{\"PlatformId\":\"\",\"OrderId\":\"0\",\"LogType\":5,\"Price\":0,\"Amount\":0,\"Extra\":\"Hello FMZ\",\"Currency\":\"\",\"Instrument\":\"\",\"Direction\":\"\",\"Time\":1732267473108}],\"result\":\"\"}",
"error": null
}
}
- result: Test result data returned after the debugging tool successfully executes the passed JavaScript code.
Arguments
| Name | Type | Required | Description |
settings | JSON object | Yes | Setting parameters in the debugging tool, the
|
Remarks
{"eid": "OKEX", "pair": "ETH_BTC", "meta" :{"AccessKey": "123", "SecretKey": "123"}}
{"eid": "Huobi", "pair": "BCH_BTC", "meta" :{"AccessKey": "123", "SecretKey": "123"}}
For the exchanges attribute in settings, only one needs to be set when calling the PluginRun method (only one exchange object is supported when using the debugging tool page). Setting 2 exchange objects in settings will not cause an error, but accessing the second exchange object in the code will cause an error.
GetRobotLogs
The GetRobotLogs method is used to get the live trading log information under the FMZ Quant Trading Platform account corresponding to the API KEY in the request. The live trading ID for which to get log information is specified by the robotId parameter.
Returns
json
{
"code": 0,
"data": {
"result": {
"chart": "",
"chartTime": 0,
"logs": [{
"Total": 20,
"Max": 20,
"Min": 1,
"Arr": []
}, {
"Total": 0,
"Max": 0,
"Min": 0,
"Arr": []
}, {
"Total": 0,
"Max": 0,
"Min": 0,
"Arr": []
}],
"node_id": 123,
"online": true,
"refresh": 1732201544000,
"status": 4,
"summary": "...",
"updateTime": 1732201532636,
"wd": 0
},
"error": null
}
}
- logs: Log information; the queried log data entries are stored in the Arr field.
The first data structure in logs contains log records from the strategy log table in the live trading database.
The second data structure in logs contains log records from the profit log table in the live trading database.
The third data structure in logs contains log records from the chart log table in the live trading database. - summary: Live trading status bar data.
Arguments
| Name | Type | Required | Description |
robotId | number | Yes | The |
logMinId | number | Yes | The |
logMaxId | number | Yes | The |
logOffset | number | Yes | The |
logLimit | number | Yes | The |
profitMinId | number | Yes | The |
profitMaxId | number | Yes | The |
profitOffset | number | Yes | The |
profitLimit | number | Yes | The |
chartMinId | number | Yes | The |
chartMaxId | number | Yes | The |
chartOffset | number | Yes | The |
chartLimit | number | Yes | The |
chartUpdateBaseId | number | Yes | The |
chartUpdateDate | number | Yes | The |
summaryLimit | number | Yes | The Setting it to 0 means not querying status bar information; setting it to a non-zero value indicates the number of bytes of status bar information to query (this interface does not limit the amount of data, you can specify a larger summaryLimit parameter to get all status bar information). The status bar data is stored in the |
Remarks
-
Strategy log table in database
The description of theArrattribute value in the first element (log data) of thelogsattribute value (array structure) in the returned data is as follows:plaintext"Arr": [ [3977, 3, "Futures_OKCoin", "", 0, 0, "Sell(688.9, 2): 20016", 1526954372591, "", ""], [3976, 5, "", "", 0, 0, "OKCoin:this_week Position too large, long: 2", 1526954372410, "", ""] ],id logType eid orderId price amount extra date contractType direction 3977 3 "Futures_OKCoin" "" 0 0 "Sell(688.9, 2): 20016" 1526954372591 "" "" 3976 5 "" "" 0 0 "OKCoin:this_week Position too large, long: 2" 1526954372410 "" "" extrais the additional information for the printed log.The log type descriptions corresponding to
logTypevalues are as follows:logType: 0 1 2 3 4 5 6 logType meaning: BUY SALE RETRACT ERROR PROFIT MESSAGE RESTART English meaning Buy order log Sell order log Cancel order Error Profit Message Restart -
Profit chart log table in database
The data in this chart log table is consistent with the profit logs in the strategy log table.plaintext"Arr": [ [202, 2515.44, 1575896700315], [201, 1415.44, 1575896341568] ]Taking one log data as an example:
plaintext[202, 2515.44, 1575896700315]202is the log ID,2515.44is the profit value,1575896700315is the timestamp. -
Chart log table in database
plaintext"Arr": [ [23637, 0, "{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"], [23636, 5, "{\"x\":1575960300000,\"y\":3.0735}"] ]Taking one log data as an example:
plaintext[23637, 0, "{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"],23637is the log ID,0is the chart data series index, and the final data"{\"close\":648,\"high\":650.5,\"low\":647,\"open\":650,\"x\":1575960300000}"is the log data, which is the K-line data on the chart.

